Learning algorithms

We have loaded our data and selected the best features, and we are ready to learn some classification models. Let's begin with basic decision trees.

In Weka, a decision tree is implemented within the J48 class, which is a reimplementation of Quinlan's famous C4.5 decision tree learner (Quinlan, 1993).

We will make a decision tree by using the following steps:

  1. We initialize a new J48 decision tree learner. We can pass additional parameters with a string table—for instance, the tree pruning that controls the model complexity (refer to Chapter 1, Applied Machine Learning Quick Start). In our case, we will build an un-pruned tree; hence, we will pass a single -U parameter, as follows:
J48 tree = new J48(); String[] options ...

Get Machine Learning in Java - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.