Exemple #1
0
    def test_missing(self):
        iris = data.Table('iris')
        learn = majority_.MajorityLearner()
        for e in iris[:len(iris) // 2:2]:
            e.set_class("?")
        clf = learn(iris)
        y = clf(iris)
        self.assertTrue((y == 2).all())

        iris = data.Table('iris')
        learn = majority_.MajorityLearner()
        for e in iris:
            e.set_class("?")
        clf = learn(iris)
        y = clf(iris)
        self.assertTrue((y == 0).all())
Exemple #2
0
    def test_majority(self):
        nrows = 1000
        ncols = 10
        x = np.random.random_integers(1, 3, (nrows, ncols))
        y = np.random.random_integers(1, 3, (nrows, 1)) // 2
        y[0] = 4
        t = data.Table(x, y)
        learn = majority_.MajorityLearner()
        clf = learn(t)

        x2 = np.random.random_integers(1, 3, (nrows, ncols))
        y2 = clf(x2)
        self.assertTrue((y2 == 1).all())
Exemple #3
0
    def test_weights(self):
        nrows = 100
        ncols = 10
        x = np.random.random_integers(1, 3, (nrows, ncols))
        y = np.random.random_integers(1, 5, (nrows, 1))
        heavy = 3
        w = (y == heavy) * 123 + 1
        t = data.Table(x, y, W=w)
        learn = majority_.MajorityLearner()
        clf = learn(t)

        x2 = np.random.random_integers(1, 3, (nrows, ncols))
        y2 = clf(x2)
        self.assertTrue((y2 == heavy).all())
Exemple #4
0
 def test_continuous(self):
     autompg = data.Table('auto-mpg')
     learn = majority_.MajorityLearner()
     self.assertRaises(ValueError, learn, autompg)
Exemple #5
0
 def test_empty(self):
     iris = data.Table('iris')
     learn = majority_.MajorityLearner()
     clf = learn(iris[:0])
     y = clf(iris[0], clf.Probs)
     self.assertTrue(np.allclose(y, y.sum() / y.size))
Exemple #6
0
class TestMajorityLearnerWithLoessEstimator(testing.LearnerTestCase):
    LEARNER = majority.MajorityLearner(estimator_constructor=\
                    Orange.core.ProbabilityEstimatorConstructor_loess())
Exemple #7
0
class TestMajorityLearner(testing.LearnerTestCase):
    LEARNER = majority.MajorityLearner()