source: orange/testing/unittests/tests/test_logreg.py @ 8763:215fb7c76033

Revision 8763:215fb7c76033, 1.9 KB checked in by ales_erjavec <ales.erjavec@…>, 3 years ago (diff)

Added more tests.

Line 
1from Orange.misc import testing
2import unittest
3
4from orngLR import LogRegLearner, Univariate_LogRegLearner, StepWiseFSS, StepWiseFSS_Filter
5
6def datasets_iter():
7    for name, (data,) in testing.datasets_iter(testing.CLASSIFICATION_DATASETS):
8        if len(data.domain.class_var.values) == 2:
9            yield name, (data,)
10           
11   
12@testing.data_driven(data_iter=datasets_iter())
13class TestLogRegLearner(testing.LearnerTestCase):
14    LEARNER = LogRegLearner
15    @testing.test_on_data
16    def test_learner_on(self, dataset):
17        """ Test LogRegLearner.
18        """
19        if len(dataset) < len(dataset.domain):
20            raise unittest.SkipTest("No enough examples")
21        testing.LearnerTestCase.test_learner_on(self, dataset)
22
23
24#@testing.data_driven(data_iter=datasets_iter())
25#class TestUniLogRegLearner(testing.LearnerTestCase):
26#    LEARNER = Univariate_LogRegLearner
27#    @testing.test_on_data
28#    def test_learner_on(self, dataset):
29#        """ Test LogRegLearner.
30#        """
31#        if len(dataset) < len(dataset.domain.attributes):
32#            raise unittest.SkipTest("No enough examples")
33#        testing.LearnerTestCase.test_learner_on(self, dataset)
34
35@testing.data_driven(data_iter=datasets_iter())
36class TestStepWiseFSS(unittest.TestCase):
37    @testing.test_on_data
38    def test_stepwise_fss_on(self, dataset):
39        """ Test StepWiseFSS.
40        """
41        if len(dataset) < len(dataset.domain):
42            raise unittest.SkipTest("No enough examples")
43
44        attrs = StepWiseFSS(dataset)
45        new_dataset = StepWiseFSS_Filter(dataset)
46        self.assertTrue([a1 == a2 for a1, a2 in zip(attrs, new_dataset.domain.attributes)])
47       
48if __name__ == "__main__":
49    import Orange, os
50    import Orange.misc.environ
51    data = Orange.data.Table(os.path.expanduser("~/Development/orange/doc/datasets/titanic.tab"))
52    c = LogRegLearner(data)
53    import pickle
54    var = c.continuized_domain[0]
55    pickle.dumps(var)
56#    unittest.main()
57   
Note: See TracBrowser for help on using the repository browser.