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

weka.classifiers.trees.ExtraTree Maven / Gradle / Ivy

Go to download

Package for generating a single Extra-Tree. Use with the RandomCommittee meta classifier to generate an Extra-Trees forest for classification or regression. This classifier requires all predictors to be numeric. Missing values are not allowed. Instance weights are taken into account. For more information, see Pierre Geurts, Damien Ernst, Louis Wehenkel (2006). Extremely randomized trees. Machine Learning. 63(1):3-42.

There is a newer version: 1.0.2
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 .
 */

/*
 *    ExtraTree.java
 *    Copyright (C) 2012 University of Waikato, Hamilton, New Zealand
 *
 */
package weka.classifiers.trees;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import java.util.Vector;

import weka.classifiers.RandomizableClassifier;
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.PartitionGenerator;
import weka.core.RevisionUtils;
import weka.core.TechnicalInformation;
import weka.core.TechnicalInformation.Field;
import weka.core.TechnicalInformation.Type;
import weka.core.TechnicalInformationHandler;
import weka.core.Utils;
import weka.core.WeightedInstancesHandler;

/**
 *  Class for generating a single Extra-Tree. Use with
 * the RandomCommittee meta classifier to generate an Extra-Trees forest for
 * classification or regression. This classifier requires all predictors to be
 * numeric. Missing values are not allowed. Instance weights are taken into
 * account. For more information, see
*
* Pierre Geurts, Damien Ernst, Louis Wehenkel (2006). Extremely randomized * trees. Machine Learning. 63(1):3-42. *

* * * BibTeX: * *

 * @article{Geurts2006,
 *    author = {Pierre Geurts and Damien Ernst and Louis Wehenkel},
 *    journal = {Machine Learning},
 *    number = {1},
 *    pages = {3-42},
 *    title = {Extremely randomized trees},
 *    volume = {63},
 *    year = {2006}
 * }
 * 
*

* * * Valid options are: *

* *

 * -K <number of attributes>
 *  Number of attributes to randomly choose at a node. If values is -1, (m - 1) will be used for regression problems, and Math.rint(sqrt(m - 1)) for classification problems, where m is the number of predictors, as specified in Geurts et al. (default -1).
 * 
* *
 * -N <minimum number of instances>
 *  The minimum number of instances required at a node for splitting to be considered. If value is -1, 5 will be used for regression problems and 2 for classification problems, as specified in Geurts et al. (default -1).
 * 
* *
 * -S <num>
 *  Random number seed.
 *  (default 1)
 * 
* *
 * -D
 *  If set, classifier is run in debug mode and
 *  may output additional info to the console
 * 
* * * * @author Eibe Frank ([email protected]) * @version $Revision: 10343 $ */ public class ExtraTree extends RandomizableClassifier implements Serializable, OptionHandler, TechnicalInformationHandler, WeightedInstancesHandler, PartitionGenerator { // We want this to make the classifier uniquely identifiable static final long serialVersionUID = 7354290459723928536L; // The actual trees protected Tree m_tree = null; // The minimum number of instances per leaf protected int m_n_min = -1; // The number of attributes to consider protected int m_K = -1; /** * Returns a string describing classifier * * @return a description suitable for displaying in the explorer/experimenter * gui */ public String globalInfo() { return "Class for generating a single Extra-Tree. Use with the RandomCommittee meta " + "classifier to generate an Extra-Trees forest for classification or regression. This " + "classifier requires all predictors to be numeric. Missing values are not " + "allowed. Instance weights are taken into account. For more information, see\n\n" + getTechnicalInformation().toString(); } /** * Returns an instance of a TechnicalInformation object, containing detailed * information about the technical background of this class, e.g., paper * reference or book this class is based on. * * @return the technical information about this class */ @Override public TechnicalInformation getTechnicalInformation() { TechnicalInformation result; result = new TechnicalInformation(Type.ARTICLE); result.setValue(Field.AUTHOR, "Pierre Geurts and Damien Ernst and Louis Wehenkel"); result.setValue(Field.TITLE, "Extremely randomized trees"); result.setValue(Field.JOURNAL, "Machine Learning"); result.setValue(Field.YEAR, "2006"); result.setValue(Field.VOLUME, "63"); result.setValue(Field.PAGES, "3-42"); result.setValue(Field.NUMBER, "1"); return result; } /** * Returns the tip text for this property * * @return tip text for this property suitable for displaying in the * explorer/experimenter gui */ public String kTipText() { return "Number of attributes to randomly choose at a node. If values is -1, " + "(m - 1) will be used for regression problems, and Math.rint(sqrt(m - 1)) " + "for classification problems, where m is the number of predictors, as " + "specified in Geurts et al."; } /** * Get the value of K. * * @return Value of K. */ public int getK() { return m_K; } /** * Set the value of K. * * @param k value to assign to K. */ public void setK(int k) { m_K = k; } /** * Returns the tip text for this property * * @return tip text for this property suitable for displaying in the * explorer/experimenter gui */ public String nminTipText() { return "The minimum number of instances required at a node for splitting " + "to be considered. If value is -1, 5 will be used for regression problems " + "and 2 for classification problems, as specified in Geurts et al."; } /** * Get the value of n_min. * * @return Value of n_min. */ public int getNmin() { return m_n_min; } /** * Set the value of n_min. * * @param k value to assign to n_min. */ public void setNmin(int n) { m_n_min = n; } /** * Lists the command-line options for this classifier. * * @return an enumeration over all possible options */ @Override public Enumeration




© 2015 - 2025 Weber Informatics LLC | Privacy Policy