weka.classifiers.trees.ht.SplitMetric 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 .
*/
/*
* SplitMetric.java
* Copyright (C) 2013 University of Waikato, Hamilton, New Zealand
*
*/
package weka.classifiers.trees.ht;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* Base class for split metrics
*
* @author Richard Kirkby ([email protected])
* @author Mark Hall (mhall{[at]}pentaho{[dot]}com)
* @version $Revision: 9720 $
*/
public abstract class SplitMetric implements Serializable {
/**
* For serialization
*/
private static final long serialVersionUID = 2891555018707080818L;
/**
* Utility method to return the sum of instance weight in a distribution
*
* @param dist the distribution
* @return the sum of the weights contained in a distribution
*/
public static double sum(Map dist) {
double sum = 0;
for (Map.Entry e : dist.entrySet()) {
sum += e.getValue().m_weight;
}
return sum;
}
/**
* Evaluate the merit of a split
*
* @param preDist the class distribution before the split
* @param postDist the class distributions after the split
* @return the merit of the split
*/
public abstract double evaluateSplit(Map preDist,
List