From ab652ac85036c5b372e7f1a08cdb75a19db5b19a Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Sun, 8 May 2016 12:57:10 +0200 Subject: regression crossvalidation fixed --- lib/compound.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/compound.rb') diff --git a/lib/compound.rb b/lib/compound.rb index 3af6f6c..0a9111b 100644 --- a/lib/compound.rb +++ b/lib/compound.rb @@ -288,7 +288,10 @@ module OpenTox training_dataset.compounds.each do |compound| candidate_fingerprint = compound.fingerprint params[:type] sim = (query_fingerprint & candidate_fingerprint).size/(query_fingerprint | candidate_fingerprint).size.to_f - neighbors << {"_id" => compound.id, "toxicities" => {prediction_feature.id.to_s => {training_dataset_id.to_s => compound.toxicities[prediction_feature.id.to_s][training_dataset_id.to_s]}}, "tanimoto" => sim} if sim >= params[:min_sim] + fid = prediction_feature.id.to_s + did = params[:training_dataset_id].to_s + v = compound.toxicities[prediction_feature.id.to_s] + neighbors << {"_id" => compound.id, "toxicities" => {fid => {did => v[params[:training_dataset_id].to_s]}}, "tanimoto" => sim} if sim >= params[:min_sim] and v end neighbors.sort!{|a,b| b["tanimoto"] <=> a["tanimoto"]} end -- cgit v1.2.3