Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(12)  |  Call(12)  |  Derive(0)  |  Import(0)

src/b/i/biopython-1.63/Tests/test_kNN.py   biopython(Download)
    def test_calculate_model(self):
        k = 3
        model = kNN.train(xs, ys, k)
        self.assertEqual(model.classes, set([0, 1]))
        n = len(xs)
    def test_classify(self):
        k = 3
        model = kNN.train(xs, ys, k)
        result = kNN.classify(model, [6, -173.143442352])
        self.assertEqual(result, 1)
    def test_calculate_probability(self):
        k = 3
        model = kNN.train(xs, ys, k)
        weights = kNN.calculate(model, [6, -173.143442352])
        self.assertAlmostEqual(weights[0], 0.0, places=6)
    def test_model_accuracy(self):
        correct = 0
        k = 3
        model = kNN.train(xs, ys, k)
        predictions = [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
    def test_leave_one_out(self):
        correct = 0
        k = 3
        model = kNN.train(xs, ys, k)
        predictions = [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1]

src/b/i/biopython-HEAD/Tests/test_kNN.py   biopython(Download)
    def test_calculate_model(self):
        k = 3
        model = kNN.train(xs, ys, k)
        self.assertEqual(model.classes, set([0, 1]))
        n = len(xs)
    def test_classify(self):
        k = 3
        model = kNN.train(xs, ys, k)
        result = kNN.classify(model, [6, -173.143442352])
        self.assertEqual(result, 1)
    def test_calculate_probability(self):
        k = 3
        model = kNN.train(xs, ys, k)
        weights = kNN.calculate(model, [6, -173.143442352])
        self.assertAlmostEqual(weights[0], 0.0, places=6)
    def test_model_accuracy(self):
        correct = 0
        k = 3
        model = kNN.train(xs, ys, k)
        predictions = [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
    def test_leave_one_out(self):
        correct = 0
        k = 3
        model = kNN.train(xs, ys, k)
        predictions = [1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1]