def test_classless(self): classless = Table(Domain(self.zoo.domain.attributes), self.zoo[:, 0:-1]) scorers = [scoring.Gini(), scoring.InfoGain(), scoring.GainRatio()] for scorer in scorers: with self.assertRaises(ValueError): scorer(0, classless)
def test_wrong_class_type(self): scorers = [scoring.Gini(), scoring.InfoGain(), scoring.GainRatio()] for scorer in scorers: with self.assertRaises(ValueError): scorer(0, self.housing)
class TestMeasureAttr_InfoGain(testing.MeasureAttributeTestCase): MEASURE = scoring.InfoGain()
def test_info_gain(self): scorer = scoring.InfoGain() correct = [0.79067, 0.71795, 0.83014, 0.97432, 0.46970] np.testing.assert_almost_equal([scorer(a, self.zoo) for a in range(5)], correct, decimal=5)
# initialize Qt application # NOTE: Needed by the save_treegraph_image() function. import sys from OWWidget import QApplication a = QApplication(sys.argv) # find out the current file's location so it can be used to compute the # location of other files/directories cur_dir = os.path.dirname(os.path.abspath(__file__)) path_prefix = os.path.abspath(os.path.join(cur_dir, "../../")) base_learners = OrderedDict() import Orange.classification.tree as octree import Orange.feature.scoring as fscoring split_const = octree.SplitConstructor_ExhaustiveBinary( measure=fscoring.InfoGain()) base_learners["orange_tree"] = octree.TreeLearner(split=split_const, store_instances=True) base_learners["orange_tree_pruned"] = octree.TreeLearner( split=split_const, min_instances=10, same_majority_pruning=True, store_instances=True) measures = [] measures.append("CA") measures.append("AUC") learners = OrderedDict() learners["Tree"] = bin_exp.TreeMarkedAndMergedLearner() learners["ForcedTree"] = bin_exp.ForcedFirstSplitMTLLearner(