source: orange/Orange/testing/unit/tests/test_knn.py @ 10651:4f6fcf57db06

Revision 10651:4f6fcf57db06, 816 bytes checked in by markotoplak, 2 years ago (diff)

Moved caching, collections, debugging, fileutil, r, testing from misc to utils.

Line 
1try:
2    import unittest2 as unittest
3except:
4    import unittest
5import Orange
6from Orange.utils import testing
7from Orange.utils.testing import datasets_driven, test_on_data
8from Orange.classification import knn
9from Orange.distance import Euclidean
10
11
12@testing.datasets_driven(datasets=testing.CLASSIFICATION_DATASETS + \
13                         testing.REGRESSION_DATASETS)
14class TestKNNLearner(testing.LearnerTestCase):
15    def setUp(self):
16        self.learner = knn.kNNLearner(distance_constructor=Euclidean())
17
18    @testing.test_on_data
19    def test_learner_on(self, dataset):
20        testing.LearnerTestCase.test_learner_on(self, dataset)
21        instance = dataset.random_instance()
22        self.assertEqual(len(self.classifier.find_nearest(3, instance)), 3)
23
24if __name__ == "__main__":
25    unittest.main()
Note: See TracBrowser for help on using the repository browser.