summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2011-07-21 16:01:34 +0200
committerAndreas Maunz <andreas@maunz.de>2011-07-21 16:01:34 +0200
commit97a1154ee924074e8d22e2982a184432587e2530 (patch)
tree9e4a3e082592af7f809117759bc1c6a9f04aa6a5
parent10b3774101226beb1f03dd1deb76b8f2c539b9a1 (diff)
Added Tests
-rw-r--r--lazar.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/lazar.rb b/lazar.rb
index b038619..1631da7 100644
--- a/lazar.rb
+++ b/lazar.rb
@@ -147,6 +147,48 @@ class LazarTest < Test::Unit::TestCase
cleanup
end
+ def test_regression_mlr_prop_model
+ create_model :dataset_uri => @@regression_training_dataset.uri, :prediction_algorithm => "local_mlr_prop"
+ predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN")
+ assert_equal 0.262, @predictions.first.confidence(@compounds.first).round_to(3)
+ assert_equal 0.168, @predictions.first.value(@compounds.first).round_to(3)
+ assert_equal 123, @predictions.first.neighbors(@compounds.first).size
+ assert_equal 131, @model.features.size
+ end
+
+ def test_regression_mlr_prop_conf_stdev
+ create_model :dataset_uri => @@regression_training_dataset.uri, :prediction_algorithm => "local_mlr_prop", :conf_stdev => "true"
+ predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN")
+ assert_equal 0.056, @predictions.first.confidence(@compounds.first).round_to(3)
+ assert_equal 0.168, @predictions.first.value(@compounds.first).round_to(3)
+ assert_equal 123, @predictions.first.neighbors(@compounds.first).size
+ assert_equal 131, @model.features.size
+ end
+
+
+ def test_regression_mlr_prop_weighted_model
+ create_model :dataset_uri => @@regression_training_dataset.uri, :prediction_algorithm => "local_mlr_prop", :nr_hits => "true"
+ predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN")
+ assert_equal 0.453, @predictions.first.confidence(@compounds.first).round_to(3)
+ assert_equal 0.265, @predictions.first.value(@compounds.first).round_to(3)
+ assert_equal 253, @predictions.first.neighbors(@compounds.first).size
+ assert_equal 131, @model.features.size
+ end
+
+ def test_conf_stdev
+ params = {:sims => [0.6,0.72,0.8], :acts => [1,1,1], :neighbors => [1,1,1], :conf_stdev => true} # stdev = 0
+ params2 = {:sims => [0.6,0.7,0.8], :acts => [3.4,2,0.6], :neighbors => [1,1,1,1], :conf_stdev => true } # stev ~ 1.4
+ params3 = {:sims => [0.6,0.7,0.8], :acts => [1,1,1], :neighbors => [1,1,1], }
+ params4 = {:sims => [0.6,0.7,0.8], :acts => [3.4,2,0.6], :neighbors => [1,1,1] }
+ 2.times {
+ assert_in_delta OpenTox::Algorithm::Neighbors::get_confidence(params), 0.72, 0.0001
+ assert_in_delta OpenTox::Algorithm::Neighbors::get_confidence(params2), 0.172617874759125, 0.0001
+ assert_in_delta OpenTox::Algorithm::Neighbors::get_confidence(params3), 0.7, 0.0001
+ assert_in_delta OpenTox::Algorithm::Neighbors::get_confidence(params4), 0.7, 0.0001
+ }
+ end
+
+
=begin
def test_ambit_classification_model