summaryrefslogtreecommitdiff
path: root/test/regression.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/regression.rb')
-rw-r--r--test/regression.rb25
1 files changed, 19 insertions, 6 deletions
diff --git a/test/regression.rb b/test/regression.rb
index dff0518..4c21450 100644
--- a/test/regression.rb
+++ b/test/regression.rb
@@ -4,7 +4,15 @@ class LazarRegressionTest < MiniTest::Test
def test_weighted_average
training_dataset = Dataset.from_csv_file "#{DATA_DIR}/EPAFHM.medi_log10.csv"
- model = Model::LazarRegression.create training_dataset.features.first, training_dataset, {:neighbor_algorithm_parameters => {:min_sim => 0}, :prediction_algorithm => "OpenTox::Algorithm::Regression.local_weighted_average"}
+ algorithms = {
+ :similarity => {
+ :min => 0
+ },
+ :prediction => {
+ :method => "Algorithm::Regression.weighted_average",
+ },
+ }
+ model = Model::Lazar.create training_dataset: training_dataset, algorithms: algorithms
compound = Compound.from_smiles "CC(C)(C)CN"
prediction = model.predict compound
assert_equal -0.86, prediction[:value].round(2)
@@ -13,17 +21,22 @@ class LazarRegressionTest < MiniTest::Test
def test_mpd_fingerprints
training_dataset = Dataset.from_csv_file "#{DATA_DIR}/EPAFHM.medi_log10.csv"
- model = Model::LazarRegression.create training_dataset.features.first, training_dataset
- model.neighbor_algorithm_parameters[:type] = "MP2D"
+ algorithms = {
+ :descriptors => {
+ :method => "fingerprint",
+ :type => "MP2D"
+ }
+ }
+ model = Model::Lazar.create training_dataset: training_dataset, algorithms: algorithms
compound = Compound.from_smiles "CCCSCCSCC"
prediction = model.predict compound
- assert_equal 1.37, prediction[:value].round(2)
assert_equal 3, prediction[:neighbors].size
+ assert_equal 1.37, prediction[:value].round(2)
end
def test_local_fingerprint_regression
training_dataset = Dataset.from_csv_file "#{DATA_DIR}/EPAFHM.medi_log10.csv"
- model = Model::LazarRegression.create(training_dataset.features.first, training_dataset, :prediction_algorithm => "OpenTox::Algorithm::Regression.local_fingerprint_regression")
+ model = Model::Lazar.create training_dataset: training_dataset
compound = Compound.from_smiles "NC(=O)OCCC"
prediction = model.predict compound
refute_nil prediction[:value]
@@ -34,7 +47,7 @@ class LazarRegressionTest < MiniTest::Test
def test_local_physchem_regression
skip # TODO: fix
training_dataset = Dataset.from_csv_file "#{DATA_DIR}/EPAFHM.medi_log10.csv"
- model = Model::LazarRegression.create(training_dataset.features.first, training_dataset, :prediction_algorithm => "OpenTox::Algorithm::Regression.local_physchem_regression")
+ model = Model::Lazar.create(training_dataset.features.first, training_dataset, :prediction_algorithm => "OpenTox::Algorithm::Regression.local_physchem_regression")
compound = Compound.from_smiles "NC(=O)OCCC"
prediction = model.predict compound
refute_nil prediction[:value]