public class RandomForest extends AbstractClassifier implements OptionHandler, Randomizable, WeightedInstancesHandler, AdditionalMeasureProducer, TechnicalInformationHandler
@article{Breiman2001, author = {Leo Breiman}, journal = {Machine Learning}, number = {1}, pages = {5-32}, title = {Random Forests}, volume = {45}, year = {2001} }Valid options are:
-I <number of trees> Number of trees to build.
-K <number of features> Number of features to consider (<1=int(logM+1)).
-S Seed for random number generator. (default 1)
-depth <num> The maximum depth of the trees, 0 for unlimited. (default 0)
-print Print the individual trees in the output
-num-slots <num> Number of execution slots. (default 1 - i.e. no parallelism)
-D If set, classifier is run in debug mode and may output additional info to the console
Constructor and Description |
---|
RandomForest() |
Modifier and Type | Method and Description |
---|---|
void |
buildClassifier(Instances data)
Builds a classifier for a set of instances.
|
double[] |
distributionForInstance(Instance instance)
Returns the class probability distribution for an instance.
|
Enumeration |
enumerateMeasures()
Returns an enumeration of the additional measure names.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
int |
getMaxDepth()
Get the maximum depth of trh tree, 0 for unlimited.
|
double |
getMeasure(String additionalMeasureName)
Returns the value of the named measure.
|
int |
getNumExecutionSlots()
Get the number of execution slots (threads) to use for building
the members of the ensemble.
|
int |
getNumFeatures()
Get the number of features used in random selection.
|
int |
getNumTrees()
Get the value of numTrees.
|
String[] |
getOptions()
Gets the current settings of the forest.
|
boolean |
getPrintTrees()
Get whether to print the individual ensemble trees in the output
|
String |
getRevision()
Returns the revision string.
|
int |
getSeed()
Gets the seed for the random number generations
|
TechnicalInformation |
getTechnicalInformation()
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.
|
String |
globalInfo()
Returns a string describing classifier
|
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(String[] argv)
Main method for this class.
|
String |
maxDepthTipText()
Returns the tip text for this property
|
double |
measureOutOfBagError()
Gets the out of bag error that was calculated as the classifier was built.
|
String |
numExecutionSlotsTipText()
Returns the tip text for this property
|
String |
numFeaturesTipText()
Returns the tip text for this property
|
String |
numTreesTipText()
Returns the tip text for this property
|
String |
printTreesTipText()
Returns the tip text for this property
|
String |
seedTipText()
Returns the tip text for this property
|
void |
setMaxDepth(int value)
Set the maximum depth of the tree, 0 for unlimited.
|
void |
setNumExecutionSlots(int numSlots)
Set the number of execution slots (threads) to use for building the
members of the ensemble.
|
void |
setNumFeatures(int newNumFeatures)
Set the number of features to use in random selection.
|
void |
setNumTrees(int newNumTrees)
Set the value of numTrees.
|
void |
setOptions(String[] options)
Parses a given list of options.
|
void |
setPrintTrees(boolean print)
Set whether to print the individual ensemble trees in the output
|
void |
setSeed(int seed)
Set the seed for random number generation.
|
String |
toString()
Outputs a description of this classifier.
|
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug
public String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public String numTreesTipText()
public int getNumTrees()
public void setNumTrees(int newNumTrees)
newNumTrees
- Value to assign to numTrees.public String numFeaturesTipText()
public int getNumFeatures()
public void setNumFeatures(int newNumFeatures)
newNumFeatures
- Value to assign to numFeatures.public String seedTipText()
public void setSeed(int seed)
setSeed
in interface Randomizable
seed
- the seedpublic int getSeed()
getSeed
in interface Randomizable
public String maxDepthTipText()
public int getMaxDepth()
public void setMaxDepth(int value)
value
- the maximum depth.public String printTreesTipText()
public void setPrintTrees(boolean print)
print
- true if the individual trees are to be printedpublic boolean getPrintTrees()
public double measureOutOfBagError()
public void setNumExecutionSlots(int numSlots)
numSlots
- the number of slots to use.public int getNumExecutionSlots()
public String numExecutionSlotsTipText()
public Enumeration enumerateMeasures()
enumerateMeasures
in interface AdditionalMeasureProducer
public double getMeasure(String additionalMeasureName)
getMeasure
in interface AdditionalMeasureProducer
additionalMeasureName
- the name of the measure to query for its valueIllegalArgumentException
- if the named measure is not supportedpublic Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class AbstractClassifier
public String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class AbstractClassifier
public void setOptions(String[] options) throws Exception
-I <number of trees> Number of trees to build.
-K <number of features> Number of features to consider (<1=int(logM+1)).
-S Seed for random number generator. (default 1)
-depth <num> The maximum depth of the trees, 0 for unlimited. (default 0)
-print Print the individual trees in the output
-num-slots <num> Number of execution slots. (default 1 - i.e. no parallelism)
-D If set, classifier is run in debug mode and may output additional info to the console
setOptions
in interface OptionHandler
setOptions
in class AbstractClassifier
options
- the list of options as an array of stringsException
- if an option is not supportedpublic Capabilities getCapabilities()
getCapabilities
in interface Classifier
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class AbstractClassifier
Capabilities
public void buildClassifier(Instances data) throws Exception
buildClassifier
in interface Classifier
data
- the instances to train the classifier withException
- if something goes wrongpublic double[] distributionForInstance(Instance instance) throws Exception
distributionForInstance
in interface Classifier
distributionForInstance
in class AbstractClassifier
instance
- the instance to be classifiedException
- if computation failspublic String toString()
public String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClassifier
public static void main(String[] argv)
argv
- the optionsCopyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.