summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lazar-physchem-short.rb1
-rw-r--r--test/lazar-regression.rb27
-rw-r--r--test/validation.rb5
3 files changed, 31 insertions, 2 deletions
diff --git a/test/lazar-physchem-short.rb b/test/lazar-physchem-short.rb
index ecf8aff..e74a4b9 100644
--- a/test/lazar-physchem-short.rb
+++ b/test/lazar-physchem-short.rb
@@ -2,6 +2,7 @@ require_relative "setup.rb"
class LazarPhyschemDescriptorTest < MiniTest::Test
def test_epafhm
+ skip "Physchem Regression not yet implemented."
# check available descriptors
@descriptors = OpenTox::Algorithm::Descriptor::DESCRIPTORS.keys
assert_equal 111,@descriptors.size,"wrong number of physchem descriptors"
diff --git a/test/lazar-regression.rb b/test/lazar-regression.rb
new file mode 100644
index 0000000..c36f521
--- /dev/null
+++ b/test/lazar-regression.rb
@@ -0,0 +1,27 @@
+require_relative "setup.rb"
+
+class LazarRegressionTest < MiniTest::Test
+
+ def test_weighted_average
+ training_dataset = Dataset.from_csv_file "#{DATA_DIR}/EPAFHM.medi.csv"
+ model = Model::LazarRegression.create training_dataset
+ compound = Compound.from_smiles "CC(C)(C)CN"
+ prediction = model.predict compound
+ assert_equal 13.6, prediction[:value].round(1)
+ assert_equal 0.83, prediction[:confidence].round(2)
+ assert_equal 1, prediction[:neighbors].size
+ end
+
+ def test_weighted_average_with_relevant_fingerprints
+ training_dataset = Dataset.from_csv_file "#{DATA_DIR}/EPAFHM.medi.csv"
+ model = Model::LazarRegression.create training_dataset
+ model.update(:prediction_algorithm => "OpenTox::Algorithm::Regression.weighted_average_with_relevant_fingerprints")
+ compound = Compound.from_smiles "CC(C)(C)CN"
+ prediction = model.predict compound
+ p prediction
+ #assert_equal 13.6, prediction[:value].round(1)
+ #assert_equal 0.83, prediction[:confidence].round(2)
+ #assert_equal 1, prediction[:neighbors].size
+ end
+
+end
diff --git a/test/validation.rb b/test/validation.rb
index d98feb5..485769c 100644
--- a/test/validation.rb
+++ b/test/validation.rb
@@ -4,10 +4,11 @@ class ValidationTest < MiniTest::Test
def test_fminer_crossvalidation
dataset = Dataset.from_csv_file "#{DATA_DIR}/hamster_carcinogenicity.csv"
- model = Model::LazarFminerClassification.create dataset#, features
+ model = Model::LazarFminerClassification.create dataset
cv = ClassificationCrossValidation.create model
p cv.accuracy
p cv.weighted_accuracy
+ refute_empty cv.validation_ids
assert cv.accuracy > 0.8
assert cv.weighted_accuracy > cv.accuracy, "Weighted accuracy (#{cv.weighted_accuracy}) larger than unweighted accuracy(#{cv.accuracy}) "
end
@@ -31,7 +32,7 @@ class ValidationTest < MiniTest::Test
p cv.weighted_rmse
p cv.mae
p cv.weighted_mae
- `inkview #{cv.plot}`
+ #`inkview #{cv.plot}`
assert cv.rmse < 30, "RMSE > 30"
assert cv.weighted_rmse < cv.rmse, "Weighted RMSE (#{cv.weighted_rmse}) larger than unweighted RMSE(#{cv.rmse}) "
assert cv.mae < 12