diff options
author | Christoph Helma <helma@in-silico.ch> | 2015-10-07 12:45:10 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2015-10-07 12:45:10 +0200 |
commit | 72e2a77fb0b72f7d525ce4b51fc03c8ee9920da2 (patch) | |
tree | 3410deb787e8c6ac6ab00c2cf526eae167b731c5 /lib/regression.rb | |
parent | 8d2f1c8a0f6cc9f7a481d1117bf8b3351130b1ea (diff) |
confidence = similarity to nearest neighbor
Diffstat (limited to 'lib/regression.rb')
-rw-r--r-- | lib/regression.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/regression.rb b/lib/regression.rb index 2580a1e..9062a9e 100644 --- a/lib/regression.rb +++ b/lib/regression.rb @@ -22,15 +22,18 @@ module OpenTox def self.weighted_average compound, params weighted_sum = 0.0 sim_sum = 0.0 + confidence = 0.0 neighbors = params[:neighbors] neighbors.each do |row| n,sim,acts = row + confidence = sim if sim > confidence # distance to nearest neighbor + # TODO add LOO errors acts.each do |act| weighted_sum += sim*Math.log10(act) sim_sum += sim end end - confidence = sim_sum*neighbors.size.to_f/params[:training_dataset_size] + #confidence = sim_sum*neighbors.size.to_f/params[:training_dataset_size] sim_sum == 0 ? prediction = nil : prediction = 10**(weighted_sum/sim_sum) {:value => prediction,:confidence => confidence} end |