public class RandomForest extends Classifier 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 (<0 = int(log_2(#predictors)+1)).
-S Seed for random number generator. (default 1)
-depth <num> The maximum depth of the trees, 0 for unlimited. (default 0)
-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.
|
java.util.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(java.lang.String additionalMeasureName)
Returns the value of the named measure.
|
int |
getNumFeatures()
Get the number of features used in random selection.
|
int |
getNumTrees()
Get the value of numTrees.
|
java.lang.String[] |
getOptions()
Gets the current settings of the forest.
|
java.lang.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.
|
java.lang.String |
globalInfo()
Returns a string describing classifier
|
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(java.lang.String[] argv)
Main method for this class.
|
java.lang.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.
|
java.lang.String |
numFeaturesTipText()
Returns the tip text for this property
|
java.lang.String |
numTreesTipText()
Returns the tip text for this property
|
java.lang.String |
seedTipText()
Returns the tip text for this property
|
void |
setMaxDepth(int value)
Set the maximum depth of the tree, 0 for unlimited.
|
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(java.lang.String[] options)
Parses a given list of options.
|
void |
setSeed(int seed)
Set the seed for random number generation.
|
java.lang.String |
toString()
Outputs a description of this classifier.
|
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, setDebug
public java.lang.String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public java.lang.String numTreesTipText()
public int getNumTrees()
public void setNumTrees(int newNumTrees)
newNumTrees
- Value to assign to numTrees.public java.lang.String numFeaturesTipText()
public int getNumFeatures()
public void setNumFeatures(int newNumFeatures)
newNumFeatures
- Value to assign to numFeatures.public java.lang.String seedTipText()
public void setSeed(int seed)
setSeed
in interface Randomizable
seed
- the seedpublic int getSeed()
getSeed
in interface Randomizable
public java.lang.String maxDepthTipText()
public int getMaxDepth()
public void setMaxDepth(int value)
value
- the maximum depth.public double measureOutOfBagError()
public java.util.Enumeration enumerateMeasures()
enumerateMeasures
in interface AdditionalMeasureProducer
public double getMeasure(java.lang.String additionalMeasureName)
getMeasure
in interface AdditionalMeasureProducer
additionalMeasureName
- the name of the measure to query for its valuejava.lang.IllegalArgumentException
- if the named measure is not supportedpublic java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Classifier
public java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class Classifier
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-I <number of trees> Number of trees to build.
-K <number of features> Number of features to consider (<0 = int(log_2(#predictors)+1)).
-S Seed for random number generator. (default 1)
-depth <num> The maximum depth of the trees, 0 for unlimited. (default 0)
-D If set, classifier is run in debug mode and may output additional info to the console
setOptions
in interface OptionHandler
setOptions
in class Classifier
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class Classifier
Capabilities
public void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier
in class Classifier
data
- the instances to train the classifier withjava.lang.Exception
- if something goes wrongpublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class Classifier
instance
- the instance to be classifiedjava.lang.Exception
- if computation failspublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class Classifier
public static void main(java.lang.String[] argv)
argv
- the options