summaryrefslogtreecommitdiff
path: root/test
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
parent9a06f2ff5ae6bdbe7dc90555599e186f1585e0d2 (diff)
enm import fixed
Diffstat (limited to 'test')
-rw-r--r--test/descriptor.rb1
-rw-r--r--test/model-nanoparticle.rb1
-rw-r--r--test/nanomaterial-prediction-models.rb1
-rw-r--r--test/setup.rb4
-rw-r--r--test/validation-nanoparticle.rb43
-rw-r--r--test/validation-regression.rb1
6 files changed, 23 insertions, 28 deletions
diff --git a/test/descriptor.rb b/test/descriptor.rb
index 6eb4316..563cdce 100644
--- a/test/descriptor.rb
+++ b/test/descriptor.rb
@@ -6,7 +6,6 @@ class DescriptorTest < MiniTest::Test
# check available descriptors
assert_equal 15,PhysChem.openbabel_descriptors.size,"incorrect number of Openbabel descriptors"
assert_equal 45,PhysChem.joelib_descriptors.size,"incorrect number of Joelib descriptors"
- p PhysChem.cdk_descriptors
assert_equal 286,PhysChem.cdk_descriptors.size,"incorrect number of Cdk descriptors"
assert_equal 346,PhysChem.descriptors.size,"incorrect number of physchem descriptors"
end
diff --git a/test/model-nanoparticle.rb b/test/model-nanoparticle.rb
index c5f3223..7fb944e 100644
--- a/test/model-nanoparticle.rb
+++ b/test/model-nanoparticle.rb
@@ -108,7 +108,6 @@ class NanoparticleModelTest < MiniTest::Test
},
}
model = Model::Lazar.create training_dataset: @training_dataset, prediction_feature: @prediction_feature, algorithms: algorithms
- p model
refute_empty model.dependent_variables
refute_empty model.descriptor_ids
refute_empty model.independent_variables
diff --git a/test/nanomaterial-prediction-models.rb b/test/nanomaterial-prediction-models.rb
index b0c05f3..f90a822 100644
--- a/test/nanomaterial-prediction-models.rb
+++ b/test/nanomaterial-prediction-models.rb
@@ -13,7 +13,6 @@ class NanomaterialPredictionModelTest < MiniTest::Test
def test_default_nanomaterial_prediction_model
prediction_model = Model::NanoPrediction.create
- p prediction_model
[:endpoint,:species,:source].each do |p|
refute_empty prediction_model[p]
end
diff --git a/test/setup.rb b/test/setup.rb
index 6c97282..63b59fb 100644
--- a/test/setup.rb
+++ b/test/setup.rb
@@ -5,5 +5,9 @@ require_relative '../lib/lazar.rb'
include OpenTox
TEST_DIR ||= File.expand_path(File.dirname(__FILE__))
DATA_DIR ||= File.join(TEST_DIR,"data")
+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")
+end
#$mongo.database.drop
#$gridfs = $mongo.database.fs
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
diff --git a/test/validation-regression.rb b/test/validation-regression.rb
index a0895f9..7630521 100644
--- a/test/validation-regression.rb
+++ b/test/validation-regression.rb
@@ -86,7 +86,6 @@ class ValidationRegressionTest < MiniTest::Test
#assert cv.r_squared > 0.34, "R^2 (#{cv.r_squared}) should be larger than 0.034"
#assert_operator cv.accuracy, :>, 0.7, "model accuracy < 0.7, this may happen by chance due to an unfavorable training/test set split"
end
- p repeated_cv
File.open("tmp.png","w+"){|f| f.puts repeated_cv.correlation_plot}
end