Decision Tree Classification Using Weka

I don’t use the Weka machine learning tool very often. Most of the ML work I do involves deep neural networks and Weka is weak in that area. But for some ML problems Weka is excellent.

Weka has been around for a long time. It’s very user friendly. A few days ago, I was looking at decision tree classification (a technique I don’t use very often). My normal approach is to write a Python language program using the scikit-learn library. But weirdly, scikit-learn decision tree classification cannot handle categorical predictor variables of three or more values. Binary predictors are OK.

So, I did a quick decision tree example using Weka, and I was very impressed. I used the J48 algorithm which is a variation of the well-known C 4.5 algorithm. I created a dummy set of data with just 12 items. The goal is to predict a person’s political party affiliation from age, sex, annual income, and occupation.

The result tree is very easy to interpret. Notice that the tree doesn’t use the age predictor because income, occupation, and sex are enough to correctly classify 11 of the 12 data items. By fiddling with the J48 parameters I could have gotten 100% prediction accuracy.

I don’t think there’s a moral to this story. But I did notice that I had become a bit of a deep neural network snob — DNNs are state of the art but sometimes traditional ML techniques can be very effective.



Left: selecting goat instead of dog for pet – bad decision. Center: taking a selfie with camel – bad decision. Right: overconfident cat – bad decision.

This entry was posted in Machine Learning. Bookmark the permalink.