From ca2bb0f90335b1f2c4ecc28ee423e85b281ffcf0 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 4 Nov 2015 17:50:17 +0100 Subject: neighbor search delegated to database backend --- test/lazar-classification.rb | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/lazar-classification.rb (limited to 'test/lazar-classification.rb') diff --git a/test/lazar-classification.rb b/test/lazar-classification.rb new file mode 100644 index 0000000..e8b2181 --- /dev/null +++ b/test/lazar-classification.rb @@ -0,0 +1,42 @@ +require_relative "setup.rb" + +class LazarClassificationTest < MiniTest::Test + + def test_lazar_classification + training_dataset = Dataset.from_csv_file File.join(DATA_DIR,"hamster_carcinogenicity.csv") + model = Model::LazarClassification.create training_dataset#, feature_dataset + #assert_equal 'C-C-C=C', feature_dataset.features.first.smarts + + [ { + :compound => OpenTox::Compound.from_inchi("InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"), + :prediction => "false", + :confidence => 0.25281385281385277, + :nr_neighbors => 11 + },{ + :compound => OpenTox::Compound.from_smiles("c1ccccc1NN"), + :prediction => "false", + :confidence => 0.3639589577089577, + :nr_neighbors => 14 + } ].each do |example| + prediction = model.predict example[:compound] + assert_equal example[:prediction], prediction[:value] + #assert_equal example[:confidence], prediction[:confidence] + #assert_equal example[:nr_neighbors], prediction[:neighbors].size + end + + compound = Compound.from_smiles "CCO" + prediction = model.predict compound + assert_equal ["false"], prediction[:database_activities] + assert_equal "true", prediction[:value] + + # make a dataset prediction + compound_dataset = OpenTox::Dataset.from_csv_file File.join(DATA_DIR,"EPAFHM.mini.csv") + prediction = model.predict compound_dataset + assert_equal compound_dataset.compounds, prediction.compounds + + assert_equal "Cound not find similar compounds.", prediction.data_entries[7][2] + assert_equal "measured", prediction.data_entries[14][1] + # cleanup + [training_dataset,model,compound_dataset].each{|o| o.delete} + end +end -- cgit v1.2.3