Attribute selection

In the next step, we will select only informative attributes, that is, attributes that are more likely to help with prediction. A standard approach to this problem is to check the information gain carried by each attribute. We will use the weka.attributeSelection.AttributeSelection filter, which requires two additional methods: an evaluator (how attribute usefulness is calculated) and search algorithms (how to select a subset of attributes).

In our case, first, we initialize weka.attributeSelection.InfoGainAttributeEval, which implements the calculation of information gain:

InfoGainAttributeEval eval = new InfoGainAttributeEval(); 
Ranker search = new Ranker(); 

To only select the top attributes above a threshold, we initialize ...

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.