summaryrefslogtreecommitdiff
path: root/lib/compound.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-05-08 12:57:10 +0200
committerChristoph Helma <helma@in-silico.ch>2016-05-08 12:57:10 +0200
commitab652ac85036c5b372e7f1a08cdb75a19db5b19a (patch)
tree3f2c99604f202e7000d0cf4b947f06ef8218d932 /lib/compound.rb
parent06fc914653face2c58fd4e6c47161cb03e217582 (diff)
regression crossvalidation fixed
Diffstat (limited to 'lib/compound.rb')
-rw-r--r--lib/compound.rb5
1 files changed, 4 insertions, 1 deletions
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