diff options
author | Christoph Helma <helma@in-silico.ch> | 2019-08-24 15:06:53 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2019-08-24 15:06:53 +0200 |
commit | 8e1e8b94539dbdd74bd4ac28295cbfd1b84036ab (patch) | |
tree | 28528e19dc6ed4cca7ed824e939dedd6c4acc94c /test/validation-nanoparticle.rb~ | |
parent | 1ee7de09c969e16fd11522d22179224e694b0161 (diff) | |
parent | 488ce9fe6d4b715680675861105b8c52a7535140 (diff) |
Merge remote-tracking branch 'origin/development'
Diffstat (limited to 'test/validation-nanoparticle.rb~')
-rw-r--r-- | test/validation-nanoparticle.rb~ | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/test/validation-nanoparticle.rb~ b/test/validation-nanoparticle.rb~ new file mode 100644 index 0000000..0c7d355 --- /dev/null +++ b/test/validation-nanoparticle.rb~ @@ -0,0 +1,133 @@ +require_relative "setup.rb" + +class NanoparticleValidationTest < MiniTest::Test + include OpenTox::Validation + + def setup + @training_dataset = Dataset.where(:name => "Protein Corona Fingerprinting Predicts the Cellular Interaction of Gold and Silver Nanoparticles").first + @prediction_feature = @training_dataset.features.select{|f| f["name"] == 'log2(Net cell association)'}.first + end + + def test_validate_default_nanoparticle_model + model = Model::Lazar.create training_dataset: @training_dataset, prediction_feature: @prediction_feature + cv = CrossValidation.create model + p cv.id + #File.open("tmp.pdf","w+"){|f| f.puts cv.correlation_plot format:"pdf"} + refute_nil cv.r_squared + refute_nil cv.rmse + end + + def test_validate_pls_pchem_model + algorithms = { + :descriptors => { + :method => "properties", + :categories => ["P-CHEM"] + }, + :prediction => {:method => 'Algorithm::Caret.pls' }, + :feature_selection => { + :method => "Algorithm::FeatureSelection.correlation_filter", + }, + } + model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms + assert_equal "Algorithm::Caret.pls", model.algorithms[:prediction][:method] + cv = CrossValidation.create model + p cv.id + #File.open("tmp2.pdf","w+"){|f| f.puts cv.correlation_plot format:"pdf"} + refute_nil cv.r_squared + refute_nil cv.rmse + end + +=begin + def test_validate_proteomics_pls_pchem_model + algorithms = { + :descriptors => { + :method => "properties", + :categories => ["Proteomics"] + }, + :prediction => {:method => 'Algorithm::Caret.pls' }, + :feature_selection => { + :method => "Algorithm::FeatureSelection.correlation_filter", + }, + } + model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms + assert_equal "Algorithm::Caret.pls", model.algorithms[:prediction][:method] + cv = CrossValidation.create model + refute_nil cv.r_squared + refute_nil cv.rmse + end +=end + + def test_validate_proteomics_pchem_default_model + algorithms = { + :descriptors => { + :method => "properties", + :categories => ["Proteomics","P-CHEM"] + }, + :feature_selection => { + :method => "Algorithm::FeatureSelection.correlation_filter", + }, + } + model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms + cv = CrossValidation.create model + refute_nil cv.r_squared + refute_nil cv.rmse + end + + def test_nanoparticle_fingerprint_model_without_feature_selection + algorithms = { + :descriptors => { + :method => "fingerprint", + :type => "MP2D", + }, + :similarity => { + :method => "Algorithm::Similarity.tanimoto", + :min => 0.1 + }, + :feature_selection => nil + } + model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms + cv = CrossValidation.create model + refute_nil cv.r_squared + refute_nil cv.rmse + end + + def test_nanoparticle_fingerprint_weighted_average_model_without_feature_selection + algorithms = { + :descriptors => { + :method => "fingerprint", + :type => "MP2D", + }, + :similarity => { + :method => "Algorithm::Similarity.tanimoto", + :min => 0.1 + }, + :prediction => { :method => "OpenTox::Algorithm::Regression.weighted_average" }, + :feature_selection => nil + } + model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms + cv = CrossValidation.create model + refute_nil cv.r_squared + refute_nil cv.rmse + end + + def test_nanoparticle_fingerprint_model_with_feature_selection + algorithms = { + :descriptors => { + :method => "fingerprint", + :type => "MP2D", + }, + :similarity => { + :method => "Algorithm::Similarity.tanimoto", + :min => 0.1 + }, + :feature_selection => { + :method => "Algorithm::FeatureSelection.correlation_filter", + }, + } + model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms + cv = CrossValidation.create model + refute_nil cv.r_squared + refute_nil cv.rmse + end + +end |