source: orange/Orange/testing/unit/tests/test_logreg.py @ 10678:f024c0f62be0

Revision 10678:f024c0f62be0, 1.7 KB checked in by Ales Erjavec <ales.erjavec@…>, 2 years ago (diff)

Added tests for LibLinearLogRegLearner.

Line 
1from Orange.testing import testing
2try:
3    import unittest2 as unittest
4except:
5    import unittest
6
7from orngLR import LogRegLearner, Univariate_LogRegLearner, StepWiseFSS, StepWiseFSS_Filter
8
9from Orange.classification.logreg import LibLinearLogRegLearner
10def datasets_iter():
11    for name, (data,) in testing.datasets_iter(testing.CLASSIFICATION_DATASETS):
12        if len(data.domain.class_var.values) == 2:
13            yield name, (data,)
14
15
16@testing.data_driven(data_iter=datasets_iter())
17class TestLogRegLearner(testing.LearnerTestCase):
18    LEARNER = LogRegLearner
19    @testing.test_on_data
20    def test_learner_on(self, dataset):
21        """ Test LogRegLearner.
22        """
23        if len(dataset) < len(dataset.domain):
24            raise unittest.SkipTest("No enough examples")
25        testing.LearnerTestCase.test_learner_on(self, dataset)
26
27
28@testing.data_driven(data_iter=datasets_iter())
29class TestStepWiseFSS(unittest.TestCase):
30    @testing.test_on_data
31    def test_stepwise_fss_on(self, dataset):
32        """ Test StepWiseFSS.
33        """
34        if len(dataset) < len(dataset.domain):
35            raise unittest.SkipTest("No enough examples")
36
37        attrs = StepWiseFSS(dataset)
38        new_dataset = StepWiseFSS_Filter(dataset)
39        self.assertTrue([a1 == a2 for a1, a2 in zip(attrs, new_dataset.domain.attributes)])
40
41@testing.datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
42class TestLibLinearLogRegLearner(testing.LearnerTestCase):
43    LEARNER = LibLinearLogRegLearner
44    @testing.test_on_data
45    def test_learner_on(self, dataset):
46        """ Test LibLinearLogRegLearner.
47        """
48        testing.LearnerTestCase.test_learner_on(self, dataset)
49
50if __name__ == "__main__":
51    unittest.main()
Note: See TracBrowser for help on using the repository browser.