From 5c6cb977db89b12ddeb822eb09370c9ad32ad84b Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Mon, 16 May 2011 16:50:13 +0200 Subject: Fixed log taking (for exclusively positive values only) --- lib/algorithm.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/algorithm.rb') 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 -- cgit v1.2.3