All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.trees.RandomForest

java.lang.Object
    |
    +----weka.classifiers.Classifier
            |
            +----weka.classifiers.DistributionClassifier
                    |
                    +----weka.classifiers.trees.RandomForest

public class RandomForest
extends DistributionClassifier
implements OptionHandler, Randomizable, WeightedInstancesHandler, AdditionalMeasureProducer
Class for constructing random forests. For more information see:

Leo Breiman. Random Forests. Machine Learning 45 (1):5-32, October 2001.

Valid options are:

-I num
Set the number of trees in the forest (default 10)

-K num
Set the number of features to consider. If < 1 (the default) will use logM+1, where M is the number of inputs.

-S seed
Random number seed (default 1).

Version:
$Revision: 1.3 $
Author:
Richard Kirkby (rkirkby@cs.waikato.ac.nz)

Constructor Index

 o RandomForest()
 

Method Index

 o buildClassifier(Instances)
Builds a classifier for a set of instances.
 o distributionForInstance(Instance)
Returns the class probability distribution for an instance.
 o enumerateMeasures()
Returns an enumeration of the additional measure names.
 o getMeasure(String)
Returns the value of the named measure.
 o getNumFeatures()
Get the number of features used in random selection.
 o getNumTrees()
Get the value of numTrees.
 o getOptions()
Gets the current settings of the forest.
 o getSeed()
Gets the seed for the random number generations
 o listOptions()
Returns an enumeration describing the available options.
 o main(String[])
Main method for this class.
 o measureOutOfBagError()
Gets the out of bag error that was calculated as the classifier was built.
 o setNumFeatures(int)
Set the number of features to use in random selection.
 o setNumTrees(int)
Set the value of numTrees.
 o setOptions(String[])
Parses a given list of options.
 o setSeed(int)
Set the seed for random number generation.
 o toString()
Outputs a description of this classifier.

Constructor Detail

 o RandomForest
public RandomForest()

Method Detail

 o getNumTrees
public int getNumTrees()
          Get the value of numTrees.
Returns:
Value of numTrees.
 o setNumTrees
public void setNumTrees(int newNumTrees)
          Set the value of numTrees.
Parameters:
newNumTrees - Value to assign to numTrees.
 o getNumFeatures
public int getNumFeatures()
          Get the number of features used in random selection.
Returns:
Value of numFeatures.
 o setNumFeatures
public void setNumFeatures(int newNumFeatures)
          Set the number of features to use in random selection.
Parameters:
newNumFeatures - Value to assign to numFeatures.
 o setSeed
public void setSeed(int seed)
          Set the seed for random number generation.
Parameters:
seed - the seed
 o getSeed
public int getSeed()
          Gets the seed for the random number generations
Returns:
the seed for the random number generation
 o measureOutOfBagError
public double measureOutOfBagError()
          Gets the out of bag error that was calculated as the classifier was built.
Returns:
the out of bag error
 o enumerateMeasures
public java.util.Enumeration enumerateMeasures()
          Returns an enumeration of the additional measure names.
Returns:
an enumeration of the measure names
 o getMeasure
public double getMeasure(java.lang.String additionalMeasureName)
          Returns the value of the named measure.
Parameters:
measureName - the name of the measure to query for its value
Returns:
the value of the named measure
Throws:
java.lang.IllegalArgumentException - if the named measure is not supported
 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
Returns:
an enumeration of all the available options
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of the forest.
Returns:
an array of strings suitable for passing to setOptions()
 o setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
          Parses a given list of options.
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported
 o buildClassifier
public void buildClassifier(Instances data) throws java.lang.Exception
          Builds a classifier for a set of instances.
Parameters:
instances - the instances to train the classifier with
Throws:
java.lang.Exception - if something goes wrong
Overrides:
buildClassifier in class Classifier
 o distributionForInstance
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
          Returns the class probability distribution for an instance.
Parameters:
instance - the instance to be classified
Returns:
the distribution the forest generates for the instance
Overrides:
distributionForInstance in class DistributionClassifier
 o toString
public java.lang.String toString()
          Outputs a description of this classifier.
Returns:
a string containing a description of the classifier
Overrides:
toString in class java.lang.Object
 o main
public static void main(java.lang.String argv[])
          Main method for this class.
Parameters:
argv - the options

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home