measurement added for single neighbors triples_data_entries
authorChristoph Helma <helma@in-silico.ch>
Fri, 21 Jun 2019 10:55:21 +0000 (12:55 +0200)
committerChristoph Helma <helma@in-silico.ch>
Fri, 21 Jun 2019 10:55:21 +0000 (12:55 +0200)
lib/model.rb
test/regression-model.rb

index 05cd113..d7b2df6 100644 (file)
@@ -272,7 +272,7 @@ module OpenTox
         elsif neighbor_similarities.size == 1
           prediction[:value] = nil
           prediction[:warnings] << "Cannot create prediction: Only one similar compound for threshold #{threshold} in the training set (Threshold: #{algorithms[:similarity][:min].last})."
-          prediction[:neighbors] = [{:id => neighbor_ids.first, :similarity => neighbor_similarities.first}]
+          prediction[:neighbors] = [{:id => neighbor_ids.first, :measurement => neighbor_dependent_variables[0], :similarity => neighbor_similarities.first}]
           if threshold == algorithms[:similarity][:min].last
             prediction[:confidence] = "Out of applicability domain: Only one similar compound in the training set."
             return prediction
index 3b41171..378ebc7 100644 (file)
@@ -195,4 +195,12 @@ class LazarRegressionTest < MiniTest::Test
     end
   end
 
+  def test_fhm_prediction
+    #p File.join(File.dirname(__FILE__),"..","data","Acute_toxicity-Fathead_minnow.csv")
+    training_dataset = Dataset.from_csv_file File.join(File.dirname(__FILE__),"..","data","Acute_toxicity-Fathead_minnow.csv")
+    model = Model::Lazar.create training_dataset: training_dataset
+    prediction = model.predict Compound.from_smiles("N=Nc1ccccc1")
+    assert_equal 0.65, prediction[:neighbors][0][:measurement].round(2)
+  end
+
 end