diff options
-rw-r--r-- | lib/model.rb | 3 | ||||
-rw-r--r-- | lib/regression.rb | 1 | ||||
-rw-r--r-- | test/regression.rb | 3 |
3 files changed, 6 insertions, 1 deletions
diff --git a/lib/model.rb b/lib/model.rb index 5da5dc8..8e657b8 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -63,10 +63,11 @@ module OpenTox end neighbors.delete_if{|n| n['features'].empty? or n['features'][prediction_feature.id.to_s] == [nil] } if neighbors.empty? - prediction.merge!({:value => nil,:confidence => nil,:warning => "Could not find similar compounds with experimental data in the training dataset."}) + prediction.merge!({:value => nil,:confidence => nil,:warning => "Could not find similar compounds with experimental data in the training dataset.",:neighbors => []}) else prediction.merge!(Algorithm.run(prediction_algorithm, compound, {:neighbors => neighbors,:training_dataset_id=> training_dataset_id,:prediction_feature_id => prediction_feature.id})) prediction[:neighbors] = neighbors + prediction[:neighbors] ||= [] end prediction end diff --git a/lib/regression.rb b/lib/regression.rb index af72d7d..5021fb3 100644 --- a/lib/regression.rb +++ b/lib/regression.rb @@ -66,6 +66,7 @@ module OpenTox prediction[:warning] = "Could not create local PLS model. Using weighted average of similar compounds." return prediction else + prediction[:prediction_interval] = [10**(prediction[:value]-1.96*prediction[:rmse]), 10**(prediction[:value]+1.96*prediction[:rmse])] prediction[:value] = 10**prediction[:value] prediction[:rmse] = 10**prediction[:rmse] prediction diff --git a/test/regression.rb b/test/regression.rb index 8dfb6d7..ad460b5 100644 --- a/test/regression.rb +++ b/test/regression.rb @@ -26,7 +26,10 @@ class LazarRegressionTest < MiniTest::Test model = Model::LazarRegression.create(training_dataset, :prediction_algorithm => "OpenTox::Algorithm::Regression.local_fingerprint_regression") compound = Compound.from_smiles "NC(=O)OCCC" prediction = model.predict compound + p prediction refute_nil prediction[:value] + refute_nil prediction[:prediction_interval] + refute_empty prediction[:neighbors] end def test_local_physchem_regression |