diff options
author | Andreas Maunz <andreas@maunz.de> | 2011-05-18 14:44:25 +0200 |
---|---|---|
committer | Andreas Maunz <andreas@maunz.de> | 2011-05-18 14:44:25 +0200 |
commit | ea199e2a75e3ce5f9dab07f29d6f55fdef6b860d (patch) | |
tree | 589085ca4a33e41659b83fb0062fe34eeaf267ad /lazar.rb | |
parent | 9e3c8678d895466939d7c4feb8d0a27fe030e01f (diff) |
Added local svm classification
Diffstat (limited to 'lazar.rb')
-rw-r--r-- | lazar.rb | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -72,6 +72,34 @@ class LazarTest < Test::Unit::TestCase assert_equal prediction.measured_activities(compound).first, true end + def test_classification_svm_model + + # create model + model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@classification_training_dataset.uri, :subjectid => @@subjectid, :prediction_algorithm => "local_svm_classification"}).to_s + lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid + @models << lazar + assert_equal lazar.features.size, 53 + + # 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 + def test_ambit_classification_model # create model |