summaryrefslogtreecommitdiff
path: root/test/validation-nanoparticle.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-11-11 13:07:53 +0100
committerChristoph Helma <helma@in-silico.ch>2016-11-11 13:07:53 +0100
commitb6116bc4705066da30668ff3370f3b1c307e44e7 (patch)
tree387c3f43cd9cc4d8fecbaeaf80773a83e52c93ff /test/validation-nanoparticle.rb
parent9a06f2ff5ae6bdbe7dc90555599e186f1585e0d2 (diff)
enm import fixed
Diffstat (limited to 'test/validation-nanoparticle.rb')
-rw-r--r--test/validation-nanoparticle.rb43
1 files changed, 19 insertions, 24 deletions
diff --git a/test/validation-nanoparticle.rb b/test/validation-nanoparticle.rb
index 5ed70f2..9351e1b 100644
--- a/test/validation-nanoparticle.rb
+++ b/test/validation-nanoparticle.rb
@@ -5,74 +5,72 @@ class NanoparticleValidationTest < MiniTest::Test
def setup
@training_dataset = Dataset.where(:name => "Protein Corona Fingerprinting Predicts the Cellular Interaction of Gold and Silver Nanoparticles").first
- unless @training_dataset
- Import::Enanomapper.import File.join(File.dirname(__FILE__),"data","enm")
- @training_dataset = Dataset.where(name: "Protein Corona Fingerprinting Predicts the Cellular Interaction of Gold and Silver Nanoparticles").first
- end
@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
- p cv.rmse
- p cv.r_squared
#File.open("tmp.pdf","w+"){|f| f.puts cv.correlation_plot}
refute_nil cv.r_squared
refute_nil cv.rmse
end
- def test_validate_pls_nanoparticle_model
+ 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.rmse
- p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
- def test_validate_proteomics_pls_nanoparticle_model
+=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
- p cv.rmse
- p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
+=end
- def test_validate_all_default_nanoparticle_model
+ 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
- p cv.rmse
- p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
- def test_nanoparticle_fingerprint_model
+ def test_nanoparticle_fingerprint_model_without_feature_selection
algorithms = {
:descriptors => {
:method => "fingerprint",
@@ -86,13 +84,11 @@ class NanoparticleValidationTest < MiniTest::Test
}
model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms
cv = CrossValidation.create model
- p cv.rmse
- p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
- def test_nanoparticle_fingerprint_weighted_average_model
+ def test_nanoparticle_fingerprint_weighted_average_model_without_feature_selection
algorithms = {
:descriptors => {
:method => "fingerprint",
@@ -107,8 +103,6 @@ class NanoparticleValidationTest < MiniTest::Test
}
model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms
cv = CrossValidation.create model
- p cv.rmse
- p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
@@ -123,11 +117,12 @@ class NanoparticleValidationTest < MiniTest::Test
: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
- p cv.rmse
- p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end