def testCar(setFunc = setEntropy, infoFunc = infoGain): """Correct classification averate rate is about 0.89""" examples,attrValues,labelName,labelValues = getCarDataset() print 'Testing Car dataset. Number of examples %d.'%len(examples) tree = makeTree(examples, attrValues, labelName, setFunc, infoFunc) f = open('car.out','w') f.write(str(tree)) f.close() print 'Tree size: %d.\n'%tree.count() print 'Entire tree written out to car.out in local directory\n' dataset = getCarDataset() evaluation = getAverageClassificaionRate((examples,attrValues,labelName,labelValues)) printDemarcation() return (tree,evaluation)
def testCar(setFunc = setEntropy, infoFunc = infoGain): """Correct classification averate rate is about 0.95""" examples,attrValues,labelName,labelValues = getCarDataset() print 'Testing Car dataset. Number of examples %d.'%len(examples) tree = makeTree(examples, attrValues, labelName, setFunc, infoFunc) f = open('car.out','w') f.write(str(tree)) f.close() print 'Tree size: %d.\n'%tree.count() print 'Entire tree written out to car.out in local directory\n' dataset = getCarDataset() evaluation = getAverageClassificaionRate((examples,attrValues,labelName,labelValues)) print 'Results for training set:\n%s\n'%str(evaluation) printDemarcation() return (tree,evaluation)