From 66c34e4682965272060a121b6e362af67ed4be5f Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 27 Aug 2015 20:28:25 +0200 Subject: Initial GUI for Nestec models --- lib/regression.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/regression.rb') diff --git a/lib/regression.rb b/lib/regression.rb index 020bb3a..2580a1e 100644 --- a/lib/regression.rb +++ b/lib/regression.rb @@ -19,9 +19,10 @@ module OpenTox class Regression - def self.weighted_average compound, neighbors + def self.weighted_average compound, params weighted_sum = 0.0 sim_sum = 0.0 + neighbors = params[:neighbors] neighbors.each do |row| n,sim,acts = row acts.each do |act| @@ -29,7 +30,7 @@ module OpenTox sim_sum += sim end end - confidence = sim_sum/neighbors.size.to_f + 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 -- cgit v1.2.3