def test_NaiveBayes(self): table = SqlTable( connection_params(), "iris", type_hints=Domain( [], DiscreteVariable("iris", values=[ "Iris-setosa", "Iris-virginica", "Iris-versicolor" ]), ), ) table = preprocess.Discretize(table) bayes = nb.NaiveBayesLearner() clf = bayes(table) # Single instance prediction self.assertEqual(clf(table[0]), table[0].get_class()) # Table prediction pred = clf(table) actual = array([ins.get_class() for ins in table]) ca = pred == actual ca = ca.sum() / len(ca) self.assertGreater(ca, 0.95) self.assertLess(ca, 1.0)
def test_PCA(self): table = SqlTable(connection_params(), 'iris', type_hints=Domain([], DiscreteVariable("iris", values=['Iris-setosa', 'Iris-virginica', 'Iris-versicolor']))) for batch_size in (50, 500): rpca = RemotePCA(table, batch_size, 20) self.assertEqual(rpca.components_.shape, (4, 4))
def test_PCA(self): table = SqlTable(connection_params(), 'iris', type_hints=Domain([], DiscreteVariable( "iris", values=[ 'Iris-setosa', 'Iris-virginica', 'Iris-versicolor' ]))) for batch_size in (50, 500): rpca = RemotePCA(table, batch_size, 10) self.assertEqual(rpca.components_.shape, (4, 4))
def test_NaiveBayes(self): table = SqlTable(connection_params(), 'iris', type_hints=Domain([], DiscreteVariable("iris", values=['Iris-setosa', 'Iris-virginica', 'Iris-versicolor']))) table = preprocess.Discretize(table) bayes = nb.NaiveBayesLearner() clf = bayes(table) # Single instance prediction self.assertEqual(clf(table[0]), table[0].get_class()) # Table prediction pred = clf(table) actual = array([ins.get_class() for ins in table]) ca = pred == actual ca = ca.sum() / len(ca) self.assertGreater(ca, 0.95) self.assertLess(ca, 1.)