source: orange/Orange/testing/unit/tests/test_earth.py @ 10278:f3b1ffae9c29

Revision 10278:f3b1ffae9c29, 1.6 KB checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Unittest2 for python 2.6.

Line 
1from Orange.misc import testing
2from Orange.misc.testing import datasets_driven, test_on_data, test_on_datasets
3from Orange.regression import earth
4import Orange
5try:
6    import unittest2 as unittest
7except:
8    import unittest
9
10@datasets_driven(datasets=testing.REGRESSION_DATASETS + \
11                 testing.CLASSIFICATION_DATASETS)
12class TestEarthLearner(testing.LearnerTestCase):
13
14    def setUp(self):
15        self.learner = earth.EarthLearner(degree=2, terms=10)
16
17    @test_on_data
18    def test_learner_on(self, dataset):
19        if len(dataset) < 30:
20            raise unittest.SkipTest("Not enough examples.")
21        testing.LearnerTestCase.test_learner_on(self, dataset)
22        str = self.classifier.to_string()
23        evimp = self.classifier.evimp()
24
25    @test_on_data
26    def test_bagged_evimp(self, dataset):
27        from Orange.ensemble.bagging import BaggedLearner
28        bagged = BaggedLearner(earth.EarthLearner(terms=10, degree=2), t=5)(dataset)
29        evimp = earth.bagged_evimp(bagged, used_only=False)
30
31
32@datasets_driven(datasets=testing.REGRESSION_DATASETS + \
33                 testing.CLASSIFICATION_DATASETS)
34class TestScoreEarthImportance(testing.MeasureAttributeTestCase):
35    def setUp(self):
36        from Orange.regression.earth import ScoreEarthImportance
37        self.measure = ScoreEarthImportance(t=5, score_what="rss")
38
39
40#@datasets_driven(datasets=testing.REGRESSION_DATASETS,)
41#class TestScoreRSS(testing.MeasureAttributeTestCase):
42#    def setUp(self):
43#        from Orange.regression.earth import ScoreRSS
44#        self.measure = ScoreRSS()
45
46
47if __name__ == "__main__":
48    unittest.main()
49
Note: See TracBrowser for help on using the repository browser.