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

weka.classifiers.trees.j48.Distribution Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 3.8.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 2 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, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 *    Distribution.java
 *    Copyright (C) 1999 University of Waikato, Hamilton, New Zealand
 *
 */

package weka.classifiers.trees.j48;

import weka.core.Instance;
import weka.core.Instances;
import weka.core.RevisionHandler;
import weka.core.RevisionUtils;
import weka.core.Utils;

import java.io.Serializable;
import java.util.Enumeration;

/**
 * Class for handling a distribution of class values.
 *
 * @author Eibe Frank ([email protected])
 * @version $Revision: 1.12 $
 */
public class Distribution
  implements Cloneable, Serializable, RevisionHandler {

  /** for serialization */
  private static final long serialVersionUID = 8526859638230806576L;

  /** Weight of instances per class per bag. */
  private double m_perClassPerBag[][]; 

  /** Weight of instances per bag. */
  private double m_perBag[];           

  /** Weight of instances per class. */
  private double m_perClass[];         

  /** Total weight of instances. */
  private double totaL;            

  /**
   * Creates and initializes a new distribution.
   */
  public Distribution(int numBags,int numClasses) {

    int i;

    m_perClassPerBag = new double [numBags][0];
    m_perBag = new double [numBags];
    m_perClass = new double [numClasses];
    for (i=0;i 1)
      return true;
    else
      return false;
  }

  /**
   * Clones distribution (Deep copy of distribution).
   */
  public final Object clone() {

    int i,j;

    Distribution newDistribution = new Distribution (m_perBag.length,
						     m_perClass.length);
    for (i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy