summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2011-05-27 09:40:39 +0200
committerAndreas Maunz <andreas@maunz.de>2011-05-27 09:40:39 +0200
commit355f2f97e3323ba8b60109e6c9524ef1f692ea1a (patch)
treef6e4695f218810878d3d04cd2f06047ff99e3813
parentdd52bf371136322b9effb0640f6bc6538b8ba10c (diff)
Added prop models
-rw-r--r--lazar.rb48
1 files changed, 47 insertions, 1 deletions
diff --git a/lazar.rb b/lazar.rb
index a8b8de9..a88801d 100644
--- a/lazar.rb
+++ b/lazar.rb
@@ -25,7 +25,7 @@ class LazarTest < Test::Unit::TestCase
=end
def test_create_regression_model
model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@regression_training_dataset.uri, :subjectid => @@subjectid}).to_s
- puts model_uri
+ #puts model_uri
validate_owl model_uri,@@subjectid
lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid
@models << lazar
@@ -41,6 +41,24 @@ class LazarTest < Test::Unit::TestCase
assert_equal prediction.neighbors(compound).size, 61
end
+ def test_create_regression_prop_model
+ model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@regression_training_dataset.uri, :subjectid => @@subjectid, :local_svm_kernel => "propositionalized"}).to_s
+ #puts model_uri
+ validate_owl model_uri,@@subjectid
+ lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid
+ @models << lazar
+ assert_equal 219, lazar.features.size
+ compound = OpenTox::Compound.from_smiles("c1ccccc1NN")
+ prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid).to_s
+ prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid)
+ @predictions << prediction
+ assert_equal prediction.value(compound).round_to(1),0.1.round_to(1)
+ assert_equal prediction.confidence(compound).round_to(3), 0.276.round_to(3)
+ #assert_equal prediction.value(compound).round_to(4), 0.2847.round_to(4)
+ #assert_equal prediction.confidence(compound).round_to(4), 0.3223.round_to(4)
+ assert_equal prediction.neighbors(compound).size, 61
+ end
+
def test_classification_model
# create model
@@ -104,6 +122,34 @@ class LazarTest < Test::Unit::TestCase
compound = OpenTox::Compound.from_smiles "CC(=Nc1ccc2c(c1)Cc1ccccc21)O"
assert_equal prediction.value(compound), nil
assert_equal prediction.measured_activities(compound).first, true
+ end
+
+ def test_classification_svm_prop_model
+
+
+ # create model
+ model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@classification_training_dataset.uri, :subjectid => @@subjectid, :prediction_algorithm => "local_svm_classification", :local_svm_kernel => "propositionalized"}).to_s
+ lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid
+ @models << lazar
+ assert_equal lazar.features.size, 52
+
+ # single prediction
+ compound = OpenTox::Compound.from_smiles("c1ccccc1NN")
+ prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid)
+ prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid)
+ @predictions << prediction
+ assert_equal prediction.value(compound), false
+ assert_equal prediction.confidence(compound).round_to(4), 0.4131.round_to(4)
+ assert_equal prediction.neighbors(compound).size, 14
+
+ # dataset prediction
+ test_dataset = OpenTox::Dataset.create_from_csv_file("data/multicolumn.csv", @@subjectid)
+ prediction = OpenTox::LazarPrediction.find lazar.run(:dataset_uri => test_dataset.uri, :subjectid => @@subjectid), @@subjectid
+ @predictions << prediction
+ assert_equal prediction.compounds.size, 4
+ compound = OpenTox::Compound.from_smiles "CC(=Nc1ccc2c(c1)Cc1ccccc21)O"
+ assert_equal prediction.value(compound), nil
+ assert_equal prediction.measured_activities(compound).first, true
end