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

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

Moved testing from utils into testing.

Line 
1try:
2    import unittest2 as unittest
3except:
4    import unittest
5
6from Orange.data.preprocess import (AddCensorWeight as Preprocessor_addCensorWeight,
7         AddClassNoise as  Preprocessor_addClassNoise,
8         AddClassWeight as Preprocessor_addClassWeight,
9         AddGaussianClassNoise as  Preprocessor_addGaussianClassNoise,
10         AddGaussianNoise as Preprocessor_addGaussianNoise,
11         AddMissing as Preprocessor_addMissing,
12         AddMissingClasses as Preprocessor_addMissingClasses,
13         AddNoise as Preprocessor_addNoise,
14         Discretize as Preprocessor_discretize,
15         Drop as Preprocessor_drop,
16         DropMissing as Preprocessor_dropMissing,
17         DropMissingClasses as Preprocessor_dropMissingClasses,
18         Filter as Preprocessor_filter,
19         Ignore as Preprocessor_ignore,
20         ImputeByLearner as Preprocessor_imputeByLearner,
21         RemoveDuplicates as Preprocessor_removeDuplicates,
22         Select as Preprocessor_select,
23         Shuffle as Preprocessor_shuffle,
24         Take as Preprocessor_take,
25         TakeMissing as Preprocessor_takeMissing,
26         TakeMissingClasses as Preprocessor_takeMissingClasses,
27         DiscretizeEntropy as Preprocessor_discretizeEntropy,
28         RemoveContinuous as Preprocessor_removeContinuous,
29         RemoveDiscrete as Preprocessor_removeDiscrete,
30         Continuize as Preprocessor_continuize,
31         Impute as Preprocessor_impute,
32         FeatureSelection as Preprocessor_featureSelection,
33         RFE as Preprocessor_RFE,
34         Sample as Preprocessor_sample,
35         PreprocessorList as Preprocessor_preprocessorList,
36         )
37
38import orange
39
40import Orange.testing.testing as testing
41
42@testing.datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
43class TestAddClassNoise(testing.PreprocessorTestCase):
44    """ Test Preprocessor_addClassNoise
45    """
46    PREPROCESSOR = Preprocessor_addClassNoise
47
48
49@testing.datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
50class TestAddClassWeight(testing.PreprocessorTestCase):
51    PREPROCESSOR = Preprocessor_addClassWeight
52
53
54@testing.datasets_driven(datasets=testing.REGRESSION_DATASETS)
55class TestAddGaussianClassNoise(testing.PreprocessorTestCase):
56    """ Test Preprocessor_addGaussianClassNoise
57    """
58    PREPROCESSOR = Preprocessor_addGaussianClassNoise
59
60
61@testing.datasets_driven
62class TestAddGaussianNoise(testing.PreprocessorTestCase):
63    """ Test Preprocessor_addGaussianNoise
64    """
65    PREPROCESSOR = Preprocessor_addGaussianNoise
66
67
68@testing.datasets_driven
69class TestAddMissing(testing.PreprocessorTestCase):
70    PREPROCESSOR = Preprocessor_addMissing
71
72
73@testing.datasets_driven(datasets=testing.CLASSIFICATION_DATASETS + \
74                         testing.REGRESSION_DATASETS)
75class TestAddMissingClasses(testing.PreprocessorTestCase):
76    PREPROCESSOR = Preprocessor_addMissingClasses
77
78
79@testing.datasets_driven
80class TestAddMissing(testing.PreprocessorTestCase):
81    PREPROCESSOR = Preprocessor_addMissing
82
83
84@testing.datasets_driven
85class TestAddNoise(testing.PreprocessorTestCase):
86    PREPROCESSOR = Preprocessor_addNoise
87
88
89@testing.datasets_driven
90class TestDiscretizeEquiN(testing.PreprocessorTestCase):
91    PREPROCESSOR = Preprocessor_discretize(method=orange.EquiNDiscretization())
92
93
94@testing.datasets_driven
95class TestDiscretizeEquiDist(testing.PreprocessorTestCase):
96    PREPROCESSOR = Preprocessor_discretize(method=orange.EquiDistDiscretization())
97
98
99@testing.datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
100class TestDiscretizeEntropy(testing.PreprocessorTestCase):
101    PREPROCESSOR = Preprocessor_discretize(method=orange.EntropyDiscretization())
102
103##########
104# This crashes with std::bad_cast
105##########
106#@testing.datasets_driven
107#class TestDiscretizeBiModal(testing.PreprocessorTestCase):
108#    PREPROCESSOR = Preprocessor_discretize(method=orange.BiModalDiscretization())
109
110#####
111# Pickling throws a segfault
112#####
113#@testing.datasets_driven
114#class TestFilter(testing.PreprocessorTestCase):
115#    PREPROCESSOR = Preprocessor_filter(filter=orange.Filter_random(prob = 0.7, randomGenerator = 24))
116
117@testing.datasets_driven
118class TestDropMissingClasses(testing.PreprocessorTestCase):
119    PREPROCESSOR = Preprocessor_dropMissingClasses
120
121@testing.datasets_driven
122class TestIgnore(testing.PreprocessorTestCase):
123    PREPROCESSOR = Preprocessor_ignore
124
125@testing.datasets_driven
126class TestImputeByLearner(testing.PreprocessorTestCase):
127    PREPROCESSOR = Preprocessor_imputeByLearner(learner=orange.MajorityLearner())
128
129@testing.datasets_driven(datasets=testing.ALL_DATASETS + ["lenses"])
130class TestRemoveDuplicates(testing.PreprocessorTestCase):
131    PREPROCESSOR = Preprocessor_removeDuplicates
132
133@testing.datasets_driven
134class TestSelect(testing.PreprocessorTestCase):
135    PREPROCESSOR = Preprocessor_select
136
137@testing.datasets_driven
138class TestShuffle(testing.PreprocessorTestCase):
139    PREPROCESSOR = Preprocessor_shuffle
140
141@testing.datasets_driven
142class TestTake(testing.PreprocessorTestCase):
143    PREPROCESSOR = Preprocessor_take
144
145@testing.datasets_driven
146class TestTakeMissing(testing.PreprocessorTestCase):
147    PREPROCESSOR = Preprocessor_takeMissing
148
149@testing.datasets_driven
150class TestTakeMissingClasses(testing.PreprocessorTestCase):
151    PREPROCESSOR = Preprocessor_takeMissingClasses
152
153@testing.datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
154class TestDiscretizeEntropy(testing.PreprocessorTestCase):
155    PREPROCESSOR = Preprocessor_discretizeEntropy
156
157@testing.datasets_driven
158class TestRemoveContinuous(testing.PreprocessorTestCase):
159    PREPROCESSOR = Preprocessor_removeContinuous
160
161@testing.datasets_driven
162class TestRemoveDiscrete(testing.PreprocessorTestCase):
163    PREPROCESSOR = Preprocessor_removeDiscrete
164
165@testing.datasets_driven
166class TestContinuize(testing.PreprocessorTestCase):
167    PREPROCESSOR = Preprocessor_continuize
168
169@testing.datasets_driven
170class TestImpute(testing.PreprocessorTestCase):
171    PREPROCESSOR = Preprocessor_impute
172
173@testing.datasets_driven(datasets=testing.CLASSIFICATION_DATASETS + \
174                         testing.REGRESSION_DATASETS)
175class TestFeatureSelection(testing.PreprocessorTestCase):
176    PREPROCESSOR = Preprocessor_featureSelection
177
178@testing.datasets_driven(datasets=testing.CLASSIFICATION_DATASETS)
179class TestRFE(testing.PreprocessorTestCase):
180    PREPROCESSOR = Preprocessor_RFE
181
182@testing.datasets_driven
183class TestSample(testing.PreprocessorTestCase):
184    PREPROCESSOR = Preprocessor_sample
185
186@testing.datasets_driven
187class TestSelect(testing.PreprocessorTestCase):
188    PREPROCESSOR = Preprocessor_preprocessorList(preprocessors=[Preprocessor_sample, Preprocessor_takeMissing])
189
190if __name__ == "__main__":
191    unittest.main()
192
193
Note: See TracBrowser for help on using the repository browser.