We implement an ID3 algorithm that constructs a decision tree for the data given in a CSV file. All sources are in the chapter directory. The most important parts of the source code are given here:
# source_code/3/construct_decision_tree.py# Constructs a decision tree from data specified in a CSV file. # Format of a CSV file: # Each data item is written on one line, with its variables separated # by a comma. The last variable is used as a decision variable to # branch a node and construct the decision tree. import math # anytree module is used to visualize the decision tree constructed by# this ID3 algorithm. from anytree import Node, RenderTree import sys sys.path.append('../common') import common import decision_tree # Program ...