weka.attributeSelection.InfoGainAttributeEval Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weka-stable Show documentation
Show all versions of weka-stable Show documentation
The Waikato Environment for Knowledge Analysis (WEKA), a machine
learning workbench. This is the stable version. Apart from bugfixes, this version
does not receive any other updates.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/*
* InfoGainAttributeEval.java
* Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand
*
*/
package weka.attributeSelection;
import java.util.Enumeration;
import java.util.Vector;
import weka.core.Capabilities;
import weka.core.Capabilities.Capability;
import weka.core.ContingencyTables;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.RevisionUtils;
import weka.core.Utils;
import weka.filters.Filter;
import weka.filters.supervised.attribute.Discretize;
import weka.filters.unsupervised.attribute.NumericToBinary;
/**
* InfoGainAttributeEval :
*
* Evaluates the worth of an attribute by measuring the information gain with
* respect to the class.
*
* InfoGain(Class,Attribute) = H(Class) - H(Class | Attribute).
*
*
*
* Valid options are:
*
*
*
* -M
* treat missing values as a seperate value.
*
*
*
* -B
* just binarize numeric attributes instead
* of properly discretizing them.
*
*
*
*
* @author Mark Hall ([email protected])
* @version $Revision: 10172 $
* @see Discretize
* @see NumericToBinary
*/
public class InfoGainAttributeEval extends ASEvaluation implements
AttributeEvaluator, OptionHandler {
/** for serialization */
static final long serialVersionUID = -1949849512589218930L;
/** Treat missing values as a seperate value */
private boolean m_missing_merge;
/** Just binarize numeric attributes */
private boolean m_Binarize;
/** The info gain for each attribute */
private double[] m_InfoGains;
/**
* Returns a string describing this attribute evaluator
*
* @return a description of the evaluator suitable for displaying in the
* explorer/experimenter gui
*/
public String globalInfo() {
return "InfoGainAttributeEval :\n\nEvaluates the worth of an attribute "
+ "by measuring the information gain with respect to the class.\n\n"
+ "InfoGain(Class,Attribute) = H(Class) - H(Class | Attribute).\n";
}
/**
* Constructor
*/
public InfoGainAttributeEval() {
resetOptions();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
**/
@Override
public Enumeration