From b536a45cf18b070cec3f9cb8a44fdac0bfa3c58e Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 27 Jun 2019 14:08:57 +0000 Subject: fixed confidence value for cv stats; added tests --- lib/validation-statistics.rb | 2 +- test/classification-validation.rb | 28 ++++++++++++++++++++++++++++ test/regression-validation.rb | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/lib/validation-statistics.rb b/lib/validation-statistics.rb index d603294..2dd9c7a 100644 --- a/lib/validation-statistics.rb +++ b/lib/validation-statistics.rb @@ -129,7 +129,7 @@ module OpenTox predictions.each do |cid,pred| !if pred[:value] and pred[:measurements] and !pred[:measurements].empty? insert_prediction pred, :all - if pred[:confidence].match(/High/i) + if pred[:confidence].match(/Similar/i) insert_prediction pred, :confidence_high elsif pred[:confidence].match(/Low/i) insert_prediction pred, :confidence_low diff --git a/test/classification-validation.rb b/test/classification-validation.rb index 33f0353..5995c88 100644 --- a/test/classification-validation.rb +++ b/test/classification-validation.rb @@ -36,6 +36,34 @@ class ClassificationValidationTest < MiniTest::Test refute_nil validation.model.training_dataset_id refute_equal model.training_dataset_id, validation.model.training_dataset_id assert_equal params, validation_params + keys = cv.accuracy.keys + av = cv.accept_values + types = ["nr_predictions", \ + "predictivity", \ + "true_rate", \ + "confusion_matrix" + ] + types.each do |type| + keys.each do |key| + case type + when "confusion_matrix" + cv[type][key].each do |arr| + arr.each do |a| + refute_nil a + assert a > 0 + end + end + when "predictivity", "true_rate" + av.each do |v| + refute_nil cv[type][key][v] + assert cv[type][key][v] > 0 + end + else + refute_nil cv[type][key] + assert cv[type][key] > 0 + end + end + end end end diff --git a/test/regression-validation.rb b/test/regression-validation.rb index 65bec63..94ef7b5 100644 --- a/test/regression-validation.rb +++ b/test/regression-validation.rb @@ -86,6 +86,20 @@ class RegressionValidationTest < MiniTest::Test repeated_cv.crossvalidations.each do |cv| assert cv.r_squared[:all] > 0.34, "R^2 (#{cv.r_squared[:all]}) should be larger than 0.34" assert cv.rmse[:all] < 1.5, "RMSE (#{cv.rmse[:all]}) should be smaller than 0.5" + keys = cv.rmse.keys + types = ["rmse", \ + "r_squared", \ + "mae", \ + "nr_predictions", \ + "within_prediction_interval", \ + "out_of_prediction_interval" + ] + types.each do |type| + keys.each do |key| + refute_nil cv[type][key] + assert cv[type][key] > 0 + end + end end end -- cgit v1.2.3