Exemplo n.º 1
0
 def test_Train(self):
     knn = Knn()
     knnParameter = KnnParameter(1, 3, EuclidianDistance())
     knn.train(self.iris.getInstanceList(), knnParameter)
     self.assertAlmostEqual(4.00, 100 * knn.test(self.iris.getInstanceList()).getErrorRate(), 2)
     knn.train(self.bupa.getInstanceList(), knnParameter)
     self.assertAlmostEqual(19.42, 100 * knn.test(self.bupa.getInstanceList()).getErrorRate(), 2)
     knn.train(self.dermatology.getInstanceList(), knnParameter)
     self.assertAlmostEqual(3.01, 100 * knn.test(self.dermatology.getInstanceList()).getErrorRate(), 2)
     knn.train(self.car.getInstanceList(), knnParameter)
     self.assertAlmostEqual(20.31, 100 * knn.test(self.car.getInstanceList()).getErrorRate(), 2)
     knn.train(self.tictactoe.getInstanceList(), knnParameter)
     self.assertAlmostEqual(32.57, 100 * knn.test(self.tictactoe.getInstanceList()).getErrorRate(), 2)
 def test_Knn(self):
     knn = Knn()
     knnParameter = KnnParameter(1, 3, EuclidianDistance())
     normalize = Normalize(self.iris)
     normalize.convert()
     knn.train(self.iris.getInstanceList(), knnParameter)
     self.assertAlmostEqual(4.67, 100 * knn.test(self.iris.getInstanceList()).getErrorRate(), 2)
     normalize = Normalize(self.bupa)
     normalize.convert()
     knn.train(self.bupa.getInstanceList(), knnParameter)
     self.assertAlmostEqual(16.52, 100 * knn.test(self.bupa.getInstanceList()).getErrorRate(), 2)
     normalize = Normalize(self.dermatology)
     normalize.convert()
     knn.train(self.dermatology.getInstanceList(), knnParameter)
     self.assertAlmostEqual(1.91, 100 * knn.test(self.dermatology.getInstanceList()).getErrorRate(), 2)
Exemplo n.º 3
0
 def test_Knn(self):
     knn = Knn()
     knnParameter = KnnParameter(1, 3, EuclidianDistance())
     pca = Pca(self.iris)
     pca.convert()
     knn.train(self.iris.getInstanceList(), knnParameter)
     self.assertAlmostEqual(3.33, 100 * knn.test(self.iris.getInstanceList()).getErrorRate(), 2)
     pca = Pca(self.bupa)
     pca.convert()
     knn.train(self.bupa.getInstanceList(), knnParameter)
     self.assertAlmostEqual(19.13, 100 * knn.test(self.bupa.getInstanceList()).getErrorRate(), 2)
     pca = Pca(self.dermatology)
     pca.convert()
     knn.train(self.dermatology.getInstanceList(), knnParameter)
     self.assertAlmostEqual(2.73, 100 * knn.test(self.dermatology.getInstanceList()).getErrorRate(), 2)
 def test_Knn(self):
     knn = Knn()
     knnParameter = KnnParameter(1, 3, EuclidianDistance())
     discreteToIndexed = LaryToBinary(self.car)
     discreteToIndexed.convert()
     knn.train(self.car.getInstanceList(), knnParameter)
     self.assertAlmostEqual(20.31, 100 * knn.test(self.car.getInstanceList()).getErrorRate(), 2)
Exemplo n.º 5
0
 def test_Knn(self):
     knn = Knn()
     knnParameter = KnnParameter(1, 3, EuclidianDistance())
     discreteToContinuous = DiscreteToContinuous(self.car)
     discreteToContinuous.convert()
     knn.train(self.car.getInstanceList(), knnParameter)
     self.assertAlmostEqual(
         20.31, 100 * knn.test(self.car.getInstanceList()).getErrorRate(),
         2)