DecisionTreesMatlab

CodeExplanation
dt_demo.mAn example using the decision tree code, using the example data from this lecture.
build_tree.mCode to grow a decision tree based on information gain.
ent.mCalculates the entropy of a list of values
cond_ent.mCalculates the conditional entropy of a list of values given another list of values.
data.txtThe car data used in dt_demo.m. Note that the non-numeric entries "mpg" and "maker" have been converted to integer values.

To use the code, download the code and data above into some directory, making sure that you've changed directories from within Matlab to that directory. To run the example code, run dt_demo.m, which should create and display a decision tree.

Play with both the data and the code until you understand it. You can find more data to work with here.

Back to Lectures