From 7794086d367fb256c3673d7578b23ec2fb83e6ed Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 9 May 2016 14:05:29 +0200 Subject: physchem crossvalidation fixed --- lib/regression.rb | 3 ++- lib/validation-statistics.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/regression.rb b/lib/regression.rb index 13e1380..b8a7e5f 100644 --- a/lib/regression.rb +++ b/lib/regression.rb @@ -80,7 +80,7 @@ module OpenTox neighbors = params[:neighbors].select{|n| n["toxicities"][params[:prediction_feature_id].to_s] and n["toxicities"][params[:prediction_feature_id].to_s][params[:training_dataset_id].to_s]} # use only neighbors with measured activities return {:value => nil, :confidence => nil, :warning => "No similar compounds in the training data"} unless neighbors.size > 0 - return {:value => neighbors.first["toxicities"][params[:prediction_feature_id].to_s][params[:training_dataset_id].to_s], :confidence => nil, :warning => "Only one similar compound in the training set"} unless neighbors.size > 1 + return {:value => neighbors.first["toxicities"][params[:prediction_feature_id].to_s][params[:training_dataset_id].to_s].median, :confidence => nil, :warning => "Only one similar compound in the training set"} unless neighbors.size > 1 activities = [] weights = [] @@ -94,6 +94,7 @@ module OpenTox data_frame[0][i] = act n["tanimoto"] ? weights << n["tanimoto"] : weights << 1.0 # TODO cosine ? neighbor.physchem_descriptors.each do |pid,values| + values = [values] if values.is_a? Float values.uniq! warn "More than one value for '#{Feature.find(pid).name}': #{values.join(', ')}. Using the median." unless values.size == 1 j = pc_ids.index(pid)+1 diff --git a/lib/validation-statistics.rb b/lib/validation-statistics.rb index b7c95f6..0079bae 100644 --- a/lib/validation-statistics.rb +++ b/lib/validation-statistics.rb @@ -68,7 +68,7 @@ module OpenTox x = [] y = [] predictions.each do |cid,pred| - if pred[:value] and pred[:measured] #and pred[:measured] != [nil] + if pred[:value] and pred[:measured] x << pred[:measured].median y << pred[:value] error = pred[:value]-pred[:measured].median -- cgit v1.2.3