All Downloads are FREE. Search and download functionalities are using the official Maven repository.

weka.classifiers.trees.ht.SplitMetric Maven / Gradle / Ivy

Go to download

The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This version represents the developer version, the "bleeding edge" of development, you could say. New functionality gets added to this version.

There is a newer version: 3.9.6
Show newest version
/*
 *   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> postDist);

  /**
   * Get the range of the splitting metric
   * 
   * @param preDist the pre-split class distribution
   * @return the range of the splitting metric
   */
  public abstract double getMetricRange(Map preDist);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy