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

weka.classifiers.mi.miti.NextSplitHeuristic Maven / Gradle / Ivy

Go to download

A collection of multi-instance learning classifiers. Includes the Citation KNN method, several variants of the diverse density method, support vector machines for multi-instance learning, simple wrappers for applying standard propositional learners to multi-instance data, decision tree and rule learners, and some other methods.

The 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 .
 */

/*
 *    NextSplitHeuristic.java
 *    Copyright (C) 2011 University of Waikato, Hamilton, New Zealand
 *
 */
package weka.classifiers.mi.miti;

import java.util.Comparator;
import java.util.HashMap;
import java.util.List;

import weka.core.Instance;

/**
 * Implements the node selection heuristic.
 *
 * @author Luke Bjerring
 * @version $Revision: 8109 $
 */
public class NextSplitHeuristic implements Comparator {	

  /**
   * Method used to sort nodes in the priority queue.
   */
  @Override
    public int compare(TreeNode o1, TreeNode o2) {
    return Double.compare(o1.nodeScore(), o2.nodeScore());
  }
	
  /**
   * Method used to get the BEPP scores based on the given arguments.
   */
  public static double getBepp(List instances, HashMap instanceBags, boolean unbiasedEstimate, int kBEPPConstant, boolean bagCount, double multiplier)
  {
    SufficientStatistics ss;
    if (!bagCount) {
      ss = new SufficientInstanceStatistics(instances, instanceBags);
    } else {
      ss = new SufficientBagStatistics(instances, instanceBags, multiplier);
    }
    return BEPP.GetBEPP(ss.totalCountRight(), ss.positiveCountRight(), kBEPPConstant, unbiasedEstimate);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy