fixed confidence value for cv stats; added tests
authorgebele <gebele@in-silico.ch>
Thu, 27 Jun 2019 14:08:57 +0000 (14:08 +0000)
committergebele <gebele@in-silico.ch>
Thu, 27 Jun 2019 14:08:57 +0000 (14:08 +0000)
lib/validation-statistics.rb
test/classification-validation.rb
test/regression-validation.rb

index d603294..2dd9c7a 100644 (file)
@@ -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
index 33f0353..5995c88 100644 (file)
@@ -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
   
index 65bec63..94ef7b5 100644 (file)
@@ -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