source: orange/Orange/testing/unit/tests/test_logreg.py @ 10655:a228b55811a4

Revision 10655:a228b55811a4, 1.7 KB checked in by markotoplak, 2 years ago (diff)

Moved testing from utils into testing.

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
9def datasets_iter():
10    for name, (data,) in testing.datasets_iter(testing.CLASSIFICATION_DATASETS):
11        if len(data.domain.class_var.values) == 2:
12            yield name, (data,)
13
14
15@testing.data_driven(data_iter=datasets_iter())
16class TestLogRegLearner(testing.LearnerTestCase):
17    LEARNER = LogRegLearner
18    @testing.test_on_data
19    def test_learner_on(self, dataset):
20        """ Test LogRegLearner.
21        """
22        if len(dataset) < len(dataset.domain):
23            raise unittest.SkipTest("No enough examples")
24        testing.LearnerTestCase.test_learner_on(self, dataset)
25
26
27#@testing.data_driven(data_iter=datasets_iter())
28#class TestUniLogRegLearner(testing.LearnerTestCase):
29#    LEARNER = Univariate_LogRegLearner
30#    @testing.test_on_data
31#    def test_learner_on(self, dataset):
32#        """ Test LogRegLearner.
33#        """
34#        if len(dataset) < len(dataset.domain.attributes):
35#            raise unittest.SkipTest("No enough examples")
36#        testing.LearnerTestCase.test_learner_on(self, dataset)
37
38@testing.data_driven(data_iter=datasets_iter())
39class TestStepWiseFSS(unittest.TestCase):
40    @testing.test_on_data
41    def test_stepwise_fss_on(self, dataset):
42        """ Test StepWiseFSS.
43        """
44        if len(dataset) < len(dataset.domain):
45            raise unittest.SkipTest("No enough examples")
46
47        attrs = StepWiseFSS(dataset)
48        new_dataset = StepWiseFSS_Filter(dataset)
49        self.assertTrue([a1 == a2 for a1, a2 in zip(attrs, new_dataset.domain.attributes)])
50
51if __name__ == "__main__":
52    unittest.main()
Note: See TracBrowser for help on using the repository browser.