@@ -0,0 +1,2566 @@
+import unittest%0Aimport numpy%0A%0Aimport Orange.data%0Aimport Orange.evaluation%0Aimport Orange.classification%0A%0Afrom Orange.widgets.evaluate import owrocanalysis%0A%0A%0Aclass TestROC(unittest.TestCase):%0A    def test_ROCData_from_results(self):%0A        data = Orange.data.Table(%22iris%22)%0A        learners = %5B%0A            Orange.classification.MajorityLearner(),%0A            Orange.classification.LogisticRegressionLearner(),%0A            Orange.classification.TreeLearner()%0A        %5D%0A        res = Orange.evaluation.CrossValidation(data, learners, k=10)%0A%0A        for i, _ in enumerate(learners):%0A            for c in range(len(data.domain.class_var.values)):%0A                rocdata = owrocanalysis.ROCData_from_results(res, i, target=c)%0A                self.assertTrue(rocdata.merged.is_valid)%0A                self.assertEqual(len(rocdata.folds), 10)%0A                self.assertTrue(all(c.is_valid for c in rocdata.folds))%0A                self.assertTrue(rocdata.avg_vertical.is_valid)%0A                self.assertTrue(rocdata.avg_threshold.is_valid)%0A%0A        data = data%5Bnumpy.random.choice(len(data), size=20)%5D%0A        res = Orange.evaluation.LeaveOneOut(data, learners)%0A%0A        for i, _ in enumerate(learners):%0A            for c in range(len(data.domain.class_var.values)):%0A                rocdata = owrocanalysis.ROCData_from_results(res, i, target=c)%0A                self.assertTrue(rocdata.merged.is_valid)%0A                self.assertEqual(len(rocdata.folds), 20)%0A                # all individual fold curves and averaged curve data%0A                # should be invalid%0A                self.assertTrue(all(not c.is_valid for c in rocdata.folds))%0A                self.assertFalse(rocdata.avg_vertical.is_valid)%0A                self.assertFalse(rocdata.avg_threshold.is_valid)%0A%0A        # equivalent test to the LeaveOneOut but from a slightly different%0A        # constructed Orange.evaluation.Results%0A        res = Orange.evaluation.CrossValidation(data, learners, k=20)%0A%0A        for i, _ in enumerate(learners):%0A            for c in range(len(data.domain.class_var.values)):%0A                rocdata = owrocanalysis.ROCData_from_results(res, i, target=c)%0A                self.assertTrue(rocdata.merged.is_valid)%0A                self.assertEqual(len(rocdata.folds), 20)%0A                # all individual fold curves and averaged curve data%0A                # should be invalid%0A                self.assertTrue(all(not c.is_valid for c in rocdata.folds))%0A                self.assertFalse(rocdata.avg_vertical.is_valid)%0A                self.assertFalse(rocdata.avg_threshold.is_valid)%0A

Add basic tests for roc analysis utilities