summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2011-07-20 15:19:42 +0200
committerAndreas Maunz <andreas@maunz.de>2011-07-20 15:19:42 +0200
commit6b322f37618139af79680941c8da0293cc803e6a (patch)
tree30bb8e50a493b6cc0379ed1ec3a35b4daaaa2199
parent4fa97d6bec952fdb3ceb6175c6b39b51aab45f4b (diff)
Fixed nr_hits to bool
-rw-r--r--lib/algorithm.rb14
-rw-r--r--lib/model.rb4
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb
index 56ab94c..9982995 100644
--- a/lib/algorithm.rb
+++ b/lib/algorithm.rb
@@ -161,8 +161,8 @@ module OpenTox
#LOGGER.debug "dv --------------- common: #{common_features}, all: #{all_features}"
if common_features.size > 0
if weights
- LOGGER.debug "nr_hits: #{params[:nr_hits]}"
- if params[:nr_hits] == "true"
+ #LOGGER.debug "nr_hits: #{params[:nr_hits]}"
+ if !params.nil? && params[:nr_hits]
params[:weights] = weights
params[:mode] = "min"
params[:features] = common_features
@@ -176,10 +176,10 @@ module OpenTox
all_p_sum = 0.0
all_features.each{|f| all_p_sum += Algorithm.gauss(weights[f])}
end
- LOGGER.debug "common_p_sum: #{common_p_sum}, all_p_sum: #{all_p_sum}, c/a: #{common_p_sum/all_p_sum}"
+ #LOGGER.debug "common_p_sum: #{common_p_sum}, all_p_sum: #{all_p_sum}, c/a: #{common_p_sum/all_p_sum}"
common_p_sum/all_p_sum
else
- LOGGER.debug "common_features : #{common_features}, all_features: #{all_features}, c/a: #{(common_features.size/all_features.size).to_f}"
+ #LOGGER.debug "common_features : #{common_features}, all_features: #{all_features}, c/a: #{(common_features.size/all_features.size).to_f}"
(common_features.size/all_features.size).to_f
end
else
@@ -225,7 +225,7 @@ module OpenTox
sims = params[:neighbors].collect { |n| Algorithm.gauss(n[:similarity]) }
LOGGER.debug "Local MLR (Propositionalization / GSL)."
prediction = mlr( {:n_prop => props[0], :q_prop => props[1], :sims => sims, :acts => acts} )
- transformer = eval "OpenTox::Algorithm::Transform::#{params[:transform]["class"]}.new ([#{prediction}], #{params[:transform]["offset"]})"
+ transformer = eval("OpenTox::Algorithm::Transform::#{params[:transform]["class"]}.new ([#{prediction}], #{params[:transform]["offset"]})")
prediction = transformer.values[0]
LOGGER.debug "Prediction is: '" + prediction.to_s + "'."
params[:conf_stdev] = "false" if params[:conf_stdev].nil?
@@ -334,7 +334,7 @@ module OpenTox
acts = params[:neighbors].collect{ |n| n[:activity].to_f }
sims = params[:neighbors].collect{ |n| Algorithm.gauss(n[:similarity]) }
prediction = props.nil? ? local_svm(acts, sims, "nu-svr", params) : local_svm_prop(props, acts, "nu-svr")
- transformer = eval "OpenTox::Algorithm::Transform::#{params[:transform]["class"]}.new ([#{prediction}], #{params[:transform]["offset"]})"
+ transformer = eval("OpenTox::Algorithm::Transform::#{params[:transform]["class"]}.new ([#{prediction}], #{params[:transform]["offset"]})")
prediction = transformer.values[0]
LOGGER.debug "Prediction is: '" + prediction.to_s + "'."
params[:conf_stdev] = "false" if params[:conf_stdev].nil?
@@ -870,7 +870,7 @@ module OpenTox
params[:features].each{|f|
compound_hits = params[:compound_features_hits][f]
neighbor_hits = Algorithm.support(f,params)
- p_sum += eval "(Algorithm.gauss(params[:weights][f]) * ([compound_hits, neighbor_hits].compact.#{params[:mode]}))"
+ p_sum += eval("(Algorithm.gauss(params[:weights][f]) * ([compound_hits, neighbor_hits].compact.#{params[:mode]}))")
}
p_sum
end
diff --git a/lib/model.rb b/lib/model.rb
index 4cbe95a..d920f19 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -311,7 +311,7 @@ module OpenTox
# Adds a neighbor to @neighbors if it passes the similarity threshold.
def add_neighbor(training_features, training_compound)
compound_features_hits = {}
- if @nr_hits == "true"
+ if @nr_hits
compound_features_hits = @compound.match_hits(@compound_features) #OpenTox::Compound.new(training_compound).match_hits(@compound_features)
LOGGER.debug "dv ------------ compound_features_hits: #{@compound_features_hits}"
end
@@ -319,7 +319,7 @@ module OpenTox
params[:training_compound] = training_compound
params[:compound] = @compound.uri #query compound
params[:fingerprints] = @fingerprints
- params[:nr_hits] = nr_hits
+ params[:nr_hits] = @nr_hits
params[:compound_features_hits] = compound_features_hits
sim = eval("#{@similarity_algorithm}(training_features, @compound_features, @p_values, params )")