source: orange/testing/unittests/tests/test_knn.py @ 8136:718bda796fa3

Revision 8136:718bda796fa3, 774 bytes checked in by ales_erjavec <ales.erjavec@…>, 3 years ago (diff)

Added tests for distance measures, io, knn, rules, table and variable.
Fixed some other tests.

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