summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavor <vorgrimmlerdavid@gmx.de>2011-12-27 20:30:42 +0100
committerdavor <vorgrimmlerdavid@gmx.de>2011-12-27 20:30:42 +0100
commit8e8bf220c2f8ac9c2950dfe39bf3300341445a12 (patch)
tree77d26341d927c431f19f9f8282c84429a7a20c9b
parent21954fd5831e14b274c071fde7251974b298a0b7 (diff)
Added two tests
-rw-r--r--lazar.rb71
1 files changed, 50 insertions, 21 deletions
diff --git a/lazar.rb b/lazar.rb
index f7403bf..f69e60e 100644
--- a/lazar.rb
+++ b/lazar.rb
@@ -80,6 +80,16 @@ class LazarTest < Test::Unit::TestCase
cleanup
end
+ def test_create_regression_prop_nr_hits_model
+ create_model :dataset_uri => @@regression_training_dataset.uri, :local_svm_kernel => "propositionalized", :nr_hits => "false"
+ predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN")
+ assert_equal 0.478, @predictions.first.confidence(@compounds.first).round_to(3)
+ assert_equal 123, @predictions.first.neighbors(@compounds.first).size
+ assert_equal 131, @model.features.size
+ cleanup
+ end
+
+
def test_classification_model
create_model :dataset_uri => @@classification_training_dataset.uri
# single prediction
@@ -127,6 +137,7 @@ class LazarTest < Test::Unit::TestCase
cleanup
end
+
def test_classification_svm_prop_model
create_model :dataset_uri => @@classification_training_dataset.uri, :prediction_algorithm => "local_svm_classification", :local_svm_kernel => "propositionalized"
predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN")
@@ -144,6 +155,24 @@ class LazarTest < Test::Unit::TestCase
cleanup
end
+ def test_classification_svm_prop_nr_hits_model
+ create_model :dataset_uri => @@classification_training_dataset.uri, :prediction_algorithm => "local_svm_classification", :local_svm_kernel => "propositionalized", :nr_hits => "true"
+ predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN")
+ predict_dataset OpenTox::Dataset.create_from_csv_file("data/multicolumn.csv", @@subjectid)
+
+ assert_equal "false", @predictions[0].value(@compounds[0])
+ assert_in_delta @predictions[0].confidence(@compounds[0]), 0.53, 0.01
+ assert_equal 22, @predictions[0].neighbors(@compounds[0]).size
+
+ c = OpenTox::Compound.from_smiles("c1ccccc1NN")
+ assert_equal 4, @predictions[1].compounds.size
+ assert_equal "false", @predictions[1].value(c)
+
+ assert_equal 41, @model.features.size
+ 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")
@@ -153,27 +182,27 @@ class LazarTest < Test::Unit::TestCase
# 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.154, @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}
- 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
+# 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.154, @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}
+# 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