def test_anova(self): nrows, ncols = 500, 5 X = np.random.rand(nrows, ncols) y = 4 + (-3 * X[:, 1] + X[:, 3]) // 2 data = Table(X, y) scorer = score.ANOVA() sc = [scorer(a, data) for a in range(ncols)] self.assertTrue(np.argmax(sc) == 1)
def test_wrong_class_type(self): scorers = [score.Gini(), score.InfoGain(), score.GainRatio()] for scorer in scorers: with self.assertRaises(ValueError): scorer(0, self.housing) with self.assertRaises(ValueError): score.Chi2(2, self.housing) with self.assertRaises(ValueError): score.ANOVA(2, self.housing) score.UnivariateLinearRegression(2, self.housing)
def test_anova(self): nrows, ncols = 500, 5 X = np.random.rand(nrows, ncols) y = 4 + (-3 * X[:, 1] + X[:, 3]) // 2 domain = Domain.from_numpy(X, y) domain = Domain(domain.attributes, DiscreteVariable('c', values=np.unique(y))) data = Table(domain, X, y) scorer = score.ANOVA() sc = [scorer(data, a) for a in range(ncols)] self.assertTrue(np.argmax(sc) == 1)