コード例 #1
0
 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)
コード例 #2
0
ファイル: test_pca.py プロジェクト: 675801717/orange3
 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))
コード例 #3
0
ファイル: test_pca.py プロジェクト: neo-nie/orange3
 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))
コード例 #4
0
 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.)