def test_regression(self):
     nrows, ncols = 500, 5
     X = np.random.rand(nrows, ncols)
     y = (-3 * X[:, 1] + X[:, 3]) / 2
     data = Table(X, y)
     scorer = score.UnivariateLinearRegression()
     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)