From a8368dda776c05331474adf7eaf9a6e413a3b1eb Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 13 Apr 2016 15:15:51 +0200 Subject: validation tests pass --- test/classification.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test/classification.rb') diff --git a/test/classification.rb b/test/classification.rb index bedbe14..af23db6 100644 --- a/test/classification.rb +++ b/test/classification.rb @@ -33,8 +33,10 @@ class LazarClassificationTest < MiniTest::Test prediction = model.predict compound_dataset assert_equal compound_dataset.compounds, prediction.compounds - assert_equal "Could not find similar compounds with experimental data in the training dataset.", prediction.data_entries[7][3] - assert_equal "1 compounds have been removed from neighbors, because they have the same structure as the query compound.", prediction.data_entries[14][3] + cid = prediction.compounds[7].id.to_s + assert_equal "Could not find similar compounds with experimental data in the training dataset.", prediction.predictions[cid][:warning] + cid = prediction.compounds[9].id.to_s + assert_equal "1 compounds have been removed from neighbors, because they have the same structure as the query compound.", prediction.predictions[cid][:warning] # cleanup [training_dataset,model,compound_dataset].each{|o| o.delete} end -- cgit v1.2.3 From 753fcc204d93d86c76860bee6e2f7d0468c3c940 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 14 Apr 2016 19:43:24 +0200 Subject: features/toxicities fixed --- test/classification.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/classification.rb') diff --git a/test/classification.rb b/test/classification.rb index af23db6..7412714 100644 --- a/test/classification.rb +++ b/test/classification.rb @@ -30,14 +30,14 @@ class LazarClassificationTest < MiniTest::Test # 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 + prediction_dataset = model.predict compound_dataset + assert_equal compound_dataset.compounds, prediction_dataset.compounds - cid = prediction.compounds[7].id.to_s - assert_equal "Could not find similar compounds with experimental data in the training dataset.", prediction.predictions[cid][:warning] - cid = prediction.compounds[9].id.to_s - assert_equal "1 compounds have been removed from neighbors, because they have the same structure as the query compound.", prediction.predictions[cid][:warning] + cid = prediction_dataset.compounds[7].id.to_s + assert_equal "Could not find similar compounds with experimental data in the training dataset.", prediction_dataset.predictions[cid][:warning] + cid = prediction_dataset.compounds[9].id.to_s + assert_equal "1 compounds have been removed from neighbors, because they have the same structure as the query compound.", prediction_dataset.predictions[cid][:warning] # cleanup - [training_dataset,model,compound_dataset].each{|o| o.delete} + [training_dataset,model,compound_dataset,prediction_dataset].each{|o| o.delete} end end -- cgit v1.2.3 From acf19c81e345ceccde834653a0f0edce27827958 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 28 Apr 2016 11:05:05 +0200 Subject: compound classification fixed --- test/classification.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'test/classification.rb') diff --git a/test/classification.rb b/test/classification.rb index 7412714..99fde3b 100644 --- a/test/classification.rb +++ b/test/classification.rb @@ -4,7 +4,7 @@ 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 + model = Model::LazarClassification.create training_dataset.features.first, training_dataset [ { :compound => OpenTox::Compound.from_inchi("InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"), @@ -25,8 +25,8 @@ class LazarClassificationTest < MiniTest::Test compound = Compound.from_smiles "CCO" prediction = model.predict compound - assert_equal ["false"], prediction[:database_activities] assert_equal "true", prediction[:value] + assert_equal ["false"], prediction[:database_activities] # make a dataset prediction compound_dataset = OpenTox::Dataset.from_csv_file File.join(DATA_DIR,"EPAFHM.mini.csv") @@ -35,7 +35,10 @@ class LazarClassificationTest < MiniTest::Test cid = prediction_dataset.compounds[7].id.to_s assert_equal "Could not find similar compounds with experimental data in the training dataset.", prediction_dataset.predictions[cid][:warning] - cid = prediction_dataset.compounds[9].id.to_s + prediction_dataset.predictions.each do |cid,pred| + assert_equal "Could not find similar compounds with experimental data in the training dataset.", pred[:warning] if pred[:value].nil? + end + cid = Compound.from_smiles("CCOC(=O)N").id.to_s assert_equal "1 compounds have been removed from neighbors, because they have the same structure as the query compound.", prediction_dataset.predictions[cid][:warning] # cleanup [training_dataset,model,compound_dataset,prediction_dataset].each{|o| o.delete} -- cgit v1.2.3 From 48234554ea99b972a01718ac36c4e8332dd9159b Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Sat, 7 May 2016 10:34:03 +0200 Subject: -log10 for regression datasets, test cleanups --- test/classification.rb | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'test/classification.rb') diff --git a/test/classification.rb b/test/classification.rb index 99fde3b..78f22a6 100644 --- a/test/classification.rb +++ b/test/classification.rb @@ -9,18 +9,12 @@ class LazarClassificationTest < MiniTest::Test [ { :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" @@ -29,7 +23,7 @@ class LazarClassificationTest < MiniTest::Test assert_equal ["false"], prediction[:database_activities] # make a dataset prediction - compound_dataset = OpenTox::Dataset.from_csv_file File.join(DATA_DIR,"EPAFHM.mini.csv") + compound_dataset = OpenTox::Dataset.from_csv_file File.join(DATA_DIR,"EPAFHM.mini_log10.csv") prediction_dataset = model.predict compound_dataset assert_equal compound_dataset.compounds, prediction_dataset.compounds @@ -43,4 +37,19 @@ class LazarClassificationTest < MiniTest::Test # cleanup [training_dataset,model,compound_dataset,prediction_dataset].each{|o| o.delete} end + + def test_lazar_kazius + t = Time.now + dataset = Dataset.from_csv_file File.join(DATA_DIR,"kazius.csv") + t = Time.now + model = Model::LazarClassification.create(dataset.features.first,dataset) + t = Time.now + 2.times do + compound = Compound.from_smiles("Clc1ccccc1NN") + prediction = model.predict compound + assert_equal "1", prediction[:value] + #assert_in_delta 0.019858401199860445, prediction[:confidence], 0.001 + end + dataset.delete + end end -- cgit v1.2.3 From b8bb12c8a163c238d7d4387c1914e2100bb660df Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 12 May 2016 15:23:01 +0200 Subject: enm study import fixed --- test/classification.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/classification.rb') diff --git a/test/classification.rb b/test/classification.rb index 78f22a6..df7cba9 100644 --- a/test/classification.rb +++ b/test/classification.rb @@ -28,12 +28,12 @@ class LazarClassificationTest < MiniTest::Test assert_equal compound_dataset.compounds, prediction_dataset.compounds cid = prediction_dataset.compounds[7].id.to_s - assert_equal "Could not find similar compounds with experimental data in the training dataset.", prediction_dataset.predictions[cid][:warning] + assert_equal "Could not find similar substances with experimental data in the training dataset.", prediction_dataset.predictions[cid][:warning] prediction_dataset.predictions.each do |cid,pred| - assert_equal "Could not find similar compounds with experimental data in the training dataset.", pred[:warning] if pred[:value].nil? + assert_equal "Could not find similar substances with experimental data in the training dataset.", pred[:warning] if pred[:value].nil? end cid = Compound.from_smiles("CCOC(=O)N").id.to_s - assert_equal "1 compounds have been removed from neighbors, because they have the same structure as the query compound.", prediction_dataset.predictions[cid][:warning] + assert_equal "1 substances have been removed from neighbors, because they are identical with the query substance.", prediction_dataset.predictions[cid][:warning] # cleanup [training_dataset,model,compound_dataset,prediction_dataset].each{|o| o.delete} end -- cgit v1.2.3 From b515a0cfedb887a2af753db6e4a08ae1af430cad Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 31 May 2016 18:08:08 +0200 Subject: cleanup of validation modules/classes --- test/classification.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/classification.rb') diff --git a/test/classification.rb b/test/classification.rb index df7cba9..9104022 100644 --- a/test/classification.rb +++ b/test/classification.rb @@ -20,7 +20,7 @@ class LazarClassificationTest < MiniTest::Test compound = Compound.from_smiles "CCO" prediction = model.predict compound assert_equal "true", prediction[:value] - assert_equal ["false"], prediction[:database_activities] + assert_equal ["false"], prediction[:measurements] # make a dataset prediction compound_dataset = OpenTox::Dataset.from_csv_file File.join(DATA_DIR,"EPAFHM.mini_log10.csv") -- cgit v1.2.3 From ec87f7e079f3a7ef8ea6a0fa57f3b40e81ecaed0 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 5 Oct 2016 14:43:18 +0200 Subject: classification and regression tests --- test/classification.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/classification.rb') diff --git a/test/classification.rb b/test/classification.rb index 9104022..6638a79 100644 --- a/test/classification.rb +++ b/test/classification.rb @@ -4,7 +4,7 @@ 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.features.first, training_dataset + model = Model::Lazar.create training_dataset: training_dataset [ { :compound => OpenTox::Compound.from_inchi("InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"), @@ -40,9 +40,9 @@ class LazarClassificationTest < MiniTest::Test def test_lazar_kazius t = Time.now - dataset = Dataset.from_csv_file File.join(DATA_DIR,"kazius.csv") + training_dataset = Dataset.from_csv_file File.join(DATA_DIR,"kazius.csv") t = Time.now - model = Model::LazarClassification.create(dataset.features.first,dataset) + model = Model::Lazar.create training_dataset: training_dataset t = Time.now 2.times do compound = Compound.from_smiles("Clc1ccccc1NN") @@ -50,6 +50,6 @@ class LazarClassificationTest < MiniTest::Test assert_equal "1", prediction[:value] #assert_in_delta 0.019858401199860445, prediction[:confidence], 0.001 end - dataset.delete + training_dataset.delete end end -- cgit v1.2.3 From 8d325866dd7cacdd04bd2306a9144a5e7300c7c8 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 13 Oct 2016 10:11:09 +0200 Subject: molecular_weight fixed --- test/classification.rb | 53 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'test/classification.rb') diff --git a/test/classification.rb b/test/classification.rb index 6638a79..c670bb5 100644 --- a/test/classification.rb +++ b/test/classification.rb @@ -2,10 +2,25 @@ require_relative "setup.rb" class LazarClassificationTest < MiniTest::Test - def test_lazar_classification + def test_classification_default + algorithms = { + :descriptors => [ "MP2D" ], + :similarity => { + :method => "Algorithm::Similarity.tanimoto", + :min => 0.1 + }, + :prediction => { + :method => "Algorithm::Classification.weighted_majority_vote", + }, + :feature_selection => nil, + } training_dataset = Dataset.from_csv_file File.join(DATA_DIR,"hamster_carcinogenicity.csv") - model = Model::Lazar.create training_dataset: training_dataset - + model = Model::Lazar.create training_dataset: training_dataset + assert_kind_of Model::LazarClassification, model + assert_equal algorithms, model.algorithms + substance = training_dataset.substances[10] + prediction = model.predict substance + assert_equal "false", prediction[:value] [ { :compound => OpenTox::Compound.from_inchi("InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"), :prediction => "false", @@ -33,12 +48,31 @@ class LazarClassificationTest < MiniTest::Test assert_equal "Could not find similar substances with experimental data in the training dataset.", pred[:warning] if pred[:value].nil? end cid = Compound.from_smiles("CCOC(=O)N").id.to_s - assert_equal "1 substances have been removed from neighbors, because they are identical with the query substance.", prediction_dataset.predictions[cid][:warning] + assert_match "excluded", prediction_dataset.predictions[cid][:warning] # cleanup [training_dataset,model,compound_dataset,prediction_dataset].each{|o| o.delete} end + + def test_classification_parameters + algorithms = { + :descriptors => ['MACCS'], + :similarity => { + :min => 0.4 + }, + } + training_dataset = Dataset.from_csv_file File.join(DATA_DIR,"hamster_carcinogenicity.csv") + model = Model::Lazar.create training_dataset: training_dataset, algorithms: algorithms + assert_kind_of Model::LazarClassification, model + assert_equal "Algorithm::Classification.weighted_majority_vote", model.algorithms[:prediction][:method] + assert_equal "Algorithm::Similarity.tanimoto", model.algorithms[:similarity][:method] + assert_equal algorithms[:similarity][:min], model.algorithms[:similarity][:min] + substance = training_dataset.substances[10] + prediction = model.predict substance + assert_equal "false", prediction[:value] + assert_equal 4, prediction[:neighbors].size + end - def test_lazar_kazius + def test_kazius t = Time.now training_dataset = Dataset.from_csv_file File.join(DATA_DIR,"kazius.csv") t = Time.now @@ -48,8 +82,15 @@ class LazarClassificationTest < MiniTest::Test compound = Compound.from_smiles("Clc1ccccc1NN") prediction = model.predict compound assert_equal "1", prediction[:value] - #assert_in_delta 0.019858401199860445, prediction[:confidence], 0.001 end training_dataset.delete end + + def test_fingerprint_feature_selection + skip + end + + def test_physchem_classification + skip + end end -- cgit v1.2.3 From ad7ec6a1e33f69557fe64371581d5f42a65ecaa8 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 13 Oct 2016 17:34:31 +0200 Subject: classification fixed --- test/classification.rb | 96 -------------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 test/classification.rb (limited to 'test/classification.rb') diff --git a/test/classification.rb b/test/classification.rb deleted file mode 100644 index c670bb5..0000000 --- a/test/classification.rb +++ /dev/null @@ -1,96 +0,0 @@ -require_relative "setup.rb" - -class LazarClassificationTest < MiniTest::Test - - def test_classification_default - algorithms = { - :descriptors => [ "MP2D" ], - :similarity => { - :method => "Algorithm::Similarity.tanimoto", - :min => 0.1 - }, - :prediction => { - :method => "Algorithm::Classification.weighted_majority_vote", - }, - :feature_selection => nil, - } - training_dataset = Dataset.from_csv_file File.join(DATA_DIR,"hamster_carcinogenicity.csv") - model = Model::Lazar.create training_dataset: training_dataset - assert_kind_of Model::LazarClassification, model - assert_equal algorithms, model.algorithms - substance = training_dataset.substances[10] - prediction = model.predict substance - assert_equal "false", prediction[:value] - [ { - :compound => OpenTox::Compound.from_inchi("InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"), - :prediction => "false", - },{ - :compound => OpenTox::Compound.from_smiles("c1ccccc1NN"), - :prediction => "false", - } ].each do |example| - prediction = model.predict example[:compound] - assert_equal example[:prediction], prediction[:value] - end - - compound = Compound.from_smiles "CCO" - prediction = model.predict compound - assert_equal "true", prediction[:value] - assert_equal ["false"], prediction[:measurements] - - # make a dataset prediction - compound_dataset = OpenTox::Dataset.from_csv_file File.join(DATA_DIR,"EPAFHM.mini_log10.csv") - prediction_dataset = model.predict compound_dataset - assert_equal compound_dataset.compounds, prediction_dataset.compounds - - cid = prediction_dataset.compounds[7].id.to_s - assert_equal "Could not find similar substances with experimental data in the training dataset.", prediction_dataset.predictions[cid][:warning] - prediction_dataset.predictions.each do |cid,pred| - assert_equal "Could not find similar substances with experimental data in the training dataset.", pred[:warning] if pred[:value].nil? - end - cid = Compound.from_smiles("CCOC(=O)N").id.to_s - assert_match "excluded", prediction_dataset.predictions[cid][:warning] - # cleanup - [training_dataset,model,compound_dataset,prediction_dataset].each{|o| o.delete} - end - - def test_classification_parameters - algorithms = { - :descriptors => ['MACCS'], - :similarity => { - :min => 0.4 - }, - } - training_dataset = Dataset.from_csv_file File.join(DATA_DIR,"hamster_carcinogenicity.csv") - model = Model::Lazar.create training_dataset: training_dataset, algorithms: algorithms - assert_kind_of Model::LazarClassification, model - assert_equal "Algorithm::Classification.weighted_majority_vote", model.algorithms[:prediction][:method] - assert_equal "Algorithm::Similarity.tanimoto", model.algorithms[:similarity][:method] - assert_equal algorithms[:similarity][:min], model.algorithms[:similarity][:min] - substance = training_dataset.substances[10] - prediction = model.predict substance - assert_equal "false", prediction[:value] - assert_equal 4, prediction[:neighbors].size - end - - def test_kazius - t = Time.now - training_dataset = Dataset.from_csv_file File.join(DATA_DIR,"kazius.csv") - t = Time.now - model = Model::Lazar.create training_dataset: training_dataset - t = Time.now - 2.times do - compound = Compound.from_smiles("Clc1ccccc1NN") - prediction = model.predict compound - assert_equal "1", prediction[:value] - end - training_dataset.delete - end - - def test_fingerprint_feature_selection - skip - end - - def test_physchem_classification - skip - end -end -- cgit v1.2.3