decision tree learning to run the decision tree learning demoin folder "aipython"load "learndt py"using ipython - learndt pyand it prints some test results to try more examplescopy and paste the commentedout commands at the bottom of that file this requires python with matplotlib the decision tree algorithm does binary splitsand assumes that all input features are binary functions of the examples it stops splitting if there are no input featuresthe number of examples is less than specified number of examples or all of the examples agree on the target feature learndt py -learning binary decision tree from learnproblem import learnerevaluate from learnnoinputs import predict import math class dt_learner(learner)def __init__(selfdatasetsplit_to_optimize=evaluate log_lossto minimize for at each split leaf_prediction=predict empiricalwhat to use for value at leaves train=noneused for cross validation max_num_cuts= maximum number of conditions to split numerical feature into gamma= - minimum improvement needed to expand node min_child_weight= )self dataset dataset self target dataset target self split_to_optimize split_to_optimize self leaf_prediction leaf_prediction self max_num_cuts max_num_cuts self gamma gamma self min_child_weight min_child_weight if train is noneself train self dataset train elseself train train def learn(selfmax_num_cuts= )"""learn decision tree""return self learn_tree(self dataset conditions(self max_num_cuts)self trainthe main recursive algorithmtakes in set of input features and set of training data it first decides whether to split if it doesn' splitit makes point predictionignoring the input features version june