source: orange/Orange/testing/unit/tests/test_linear.py @ 9679:3879dea56188

Revision 9679:3879dea56188, 2.0 KB checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Moved and renamed testing.

Line 
1import Orange
2from Orange.misc import testing
3from Orange.misc.testing import datasets_driven
4from Orange.classification.svm import LinearLearner
5import unittest
6
7
8@testing.test_on_data
9def test_learner_on(self, dataset):
10    testing.LearnerTestCase.test_learner_on(self, dataset)
11    n_vals = len(dataset.domain.class_var.values)
12    if n_vals > 2:
13        self.assertEquals(len(self.classifier.weights), n_vals)
14    else:
15        self.assertEquals(len(self.classifier.weights), 1)
16       
17    n_features = len(dataset.domain.attributes)
18    self.assert_(all(len(w) == n_features for w in self.classifier.weights))
19       
20@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
21class TestLinearLearnerL2R_L2LOSS_DUAL(testing.LearnerTestCase):
22    LEARNER = LinearLearner(sover_type=LinearLearner.L2R_L2LOSS_DUAL)
23   
24    test_learner_on=test_learner_on
25   
26@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
27class TestLinearLearnerL2R_L2LOSS(testing.LearnerTestCase):
28    LEARNER = LinearLearner(sover_type=LinearLearner.L2R_L2LOSS)
29    test_learner_on=test_learner_on
30   
31@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
32class TestLinearLearnerL2R_L1LOSS_DUAL(testing.LearnerTestCase):
33    LEARNER = LinearLearner(sover_type=LinearLearner.L2R_L1LOSS_DUAL)
34    test_learner_on=test_learner_on
35   
36@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
37class TestLinearLearnerL2R_L1LOSS(testing.LearnerTestCase):
38    LEARNER = LinearLearner(sover_type=LinearLearner.L2R_L2LOSS)
39    test_learner_on=test_learner_on
40   
41@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
42class TestLinearLearnerL1R_L2LOSS(testing.LearnerTestCase):
43    LEARNER = LinearLearner(sover_type=LinearLearner.L1R_L2LOSS)
44    test_learner_on=test_learner_on
45   
46@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
47class TestLinearLearnerL1R_L2LOSS(testing.LearnerTestCase):
48    LEARNER = LinearLearner(sover_type=LinearLearner.MCSVM_CS)
49    test_learner_on=test_learner_on
50
51if __name__ == "__main__":
52    unittest.main()
Note: See TracBrowser for help on using the repository browser.