source: orange/Orange/testing/unit/tests/test_linear.py @ 10687:d9b8746f2f43

Revision 10687:d9b8746f2f43, 2.0 KB checked in by Ales Erjavec <ales.erjavec@…>, 2 years ago (diff)

Changed tests for LinearSVMLearner.

Line 
1import Orange
2from Orange.testing import testing
3from Orange.testing.testing import datasets_driven
4from Orange.classification.svm import LinearSVMLearner
5try:
6    import unittest2 as unittest
7except:
8    import unittest
9
10
11@testing.test_on_data
12def test_learner_on(self, dataset):
13    testing.LearnerTestCase.test_learner_on(self, dataset)
14    n_vals = len(dataset.domain.class_var.values)
15    if n_vals > 2:
16        self.assertEquals(len(self.classifier.weights), n_vals)
17    else:
18        self.assertEquals(len(self.classifier.weights), 1)
19
20@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
21class TestLinearSVMLearnerL2R_L2LOSS_DUAL(testing.LearnerTestCase):
22    LEARNER = LinearSVMLearner(sover_type=LinearSVMLearner.L2R_L2LOSS_DUAL)
23
24    test_learner_on = test_learner_on
25
26@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
27class TestLinearSVMLearnerL2R_L2LOSS(testing.LearnerTestCase):
28    LEARNER = LinearSVMLearner(sover_type=LinearSVMLearner.L2R_L2LOSS)
29    test_learner_on = test_learner_on
30
31@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
32class TestLinearSVMLearnerL2R_L1LOSS_DUAL(testing.LearnerTestCase):
33    LEARNER = LinearSVMLearner(sover_type=LinearSVMLearner.L2R_L1LOSS_DUAL)
34    test_learner_on = test_learner_on
35
36@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
37class TestLinearSVMLearnerL2R_L1LOSS(testing.LearnerTestCase):
38    LEARNER = LinearSVMLearner(sover_type=LinearSVMLearner.L2R_L2LOSS)
39    test_learner_on = test_learner_on
40
41@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
42class TestLinearSVMLearnerL1R_L2LOSS(testing.LearnerTestCase):
43    LEARNER = LinearSVMLearner(sover_type=LinearSVMLearner.L1R_L2LOSS)
44    test_learner_on = test_learner_on
45
46@datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
47class TestLinearSVMLearnerL1R_L2LOSS(testing.LearnerTestCase):
48    LEARNER = LinearSVMLearner(sover_type=LinearSVMLearner.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.