def test_classless(self): classless = Table(Domain(self.zoo.domain.attributes), self.zoo[:, 0:-1]) scorers = [Gini(), InfoGain(), GainRatio()] for scorer in scorers: with self.assertRaises(ValueError): scorer(classless, 0)
def test_wrong_class_type(self): scorers = [Gini(), InfoGain(), GainRatio()] for scorer in scorers: with self.assertRaises(ValueError): scorer(self.housing, 0) with self.assertRaises(ValueError): Chi2()(self.housing, 0) with self.assertRaises(ValueError): ANOVA()(self.housing, 2) UnivariateLinearRegression()(self.housing, 2)
def test_info_gain(self): scorer = InfoGain() correct = [0.79067, 0.71795, 0.83014, 0.97432, 0.46970] np.testing.assert_almost_equal([scorer(self.zoo, a) for a in range(5)], correct, decimal=5)