summaryrefslogtreecommitdiff
path: root/lib/algorithm.rb
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2011-05-16 16:50:13 +0200
committerAndreas Maunz <andreas@maunz.de>2011-05-16 16:50:13 +0200
commit5c6cb977db89b12ddeb822eb09370c9ad32ad84b (patch)
tree2973814d523369e2857271f4793bee4055c23bb3 /lib/algorithm.rb
parent5acd3b8cd36a0f5017e4858df3d4516876858324 (diff)
Fixed log taking (for exclusively positive values only)
Diffstat (limited to 'lib/algorithm.rb')
-rw-r--r--lib/algorithm.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb
index abf10d4..130d305 100644
--- a/lib/algorithm.rb
+++ b/lib/algorithm.rb
@@ -167,9 +167,17 @@ module OpenTox
def self.local_svm_regression(neighbors,params )
sims = neighbors.collect{ |n| Algorithm.gauss(n[:similarity]) } # similarity values between query and neighbors
conf = sims.inject{|sum,x| sum + x }
+
+ # AM: Control log taking
+ take_logs=true
+ neighbors.each do |n|
+ if (! n[:activity].nil?) && (n[:activity].to_f < 0.0)
+ take_logs = false
+ end
+ end
acts = neighbors.collect do |n|
act = n[:activity]
- Math.log10(act.to_f)
+ take_logs ? Math.log10(act.to_f) : act.to_f
end # activities of neighbors for supervised learning
neighbor_matches = neighbors.collect{ |n| n[:features] } # as in classification: URIs of matches