public class RandomForest extends AbstractClassifier implements OptionHandler, Randomizable, WeightedInstancesHandler, AdditionalMeasureProducer, TechnicalInformationHandler, PartitionGenerator, Aggregateable<RandomForest>
@article{Breiman2001,
author = {Leo Breiman},
journal = {Machine Learning},
number = {1},
pages = {5-32},
title = {Random Forests},
volume = {45},
year = {2001}
}
-I <number of trees> Number of trees to build. (default 100)
-K <number of features> Number of features to consider (<1=int(log_2(#predictors)+1)). (default 0)
-S Seed for random number generator. (default 1)
-depth <num> The maximum depth of the trees, 0 for unlimited. (default 0)
-O Don't calculate the out of bag error.
-print Print the individual trees in the output
-num-slots <num> Number of execution slots. (default 1 - i.e. no parallelism)
-B Break ties randomly when several attributes look equally good.
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
NUM_DECIMAL_PLACES_DEFAULT| Constructor and Description |
|---|
RandomForest() |
| Modifier and Type | Method and Description |
|---|---|
RandomForest |
aggregate(RandomForest toAggregate)
Aggregate an object with this one
|
java.lang.String |
breakTiesRandomlyTipText()
Returns the tip text for this property
|
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.lang.String |
dontCalculateOutOfBagErrorTipText()
Returns the tip text for this property
|
java.util.Enumeration<java.lang.String> |
enumerateMeasures()
Returns an enumeration of the additional measure names.
|
void |
finalizeAggregation()
Call to complete the aggregation process.
|
void |
generatePartition(Instances data)
Builds the classifier to generate a partition.
|
boolean |
getBreakTiesRandomly()
Get whether to break ties randomly.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
boolean |
getDontCalculateOutOfBagError()
Get whether to turn off the calculation of out of bag error
|
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.
|
double[] |
getMembershipValues(Instance inst)
Computes an array that indicates leaf membership
|
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.
|
java.lang.String[] |
getOptions()
Gets the current settings of the forest.
|
boolean |
getPrintTrees()
Get whether to print the individual ensemble trees in the output
|
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<Option> |
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.
|
int |
numElements()
Returns the number of elements in the partition.
|
java.lang.String |
numExecutionSlotsTipText()
Returns the tip text for this property
|
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 |
printTreesTipText()
Returns the tip text for this property
|
java.lang.String |
seedTipText()
Returns the tip text for this property
|
void |
setBreakTiesRandomly(boolean newBreakTiesRandomly)
Set whether to break ties randomly.
|
void |
setDontCalculateOutOfBagError(boolean b)
Set whether to turn off the calculation of out of bag error
|
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(java.lang.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.
|
java.lang.String |
toString()
Outputs a description of this classifier.
|
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlacespublic java.lang.String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation in interface TechnicalInformationHandlerpublic 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 Randomizableseed - the seedpublic int getSeed()
getSeed in interface Randomizablepublic java.lang.String maxDepthTipText()
public int getMaxDepth()
public void setMaxDepth(int value)
value - the maximum depth.public java.lang.String printTreesTipText()
public void setPrintTrees(boolean print)
print - true if the individual trees are to be printedpublic boolean getPrintTrees()
public java.lang.String dontCalculateOutOfBagErrorTipText()
public void setDontCalculateOutOfBagError(boolean b)
b - true to turn off the calculation of out of bag errorpublic boolean getDontCalculateOutOfBagError()
public double measureOutOfBagError()
public void setNumExecutionSlots(int numSlots)
numSlots - the number of slots to use.public int getNumExecutionSlots()
public java.lang.String numExecutionSlotsTipText()
public java.lang.String breakTiesRandomlyTipText()
public boolean getBreakTiesRandomly()
public void setBreakTiesRandomly(boolean newBreakTiesRandomly)
newBreakTiesRandomly - true if ties are to be broken randomlypublic java.util.Enumeration<java.lang.String> enumerateMeasures()
enumerateMeasures in interface AdditionalMeasureProducerpublic double getMeasure(java.lang.String additionalMeasureName)
getMeasure in interface AdditionalMeasureProduceradditionalMeasureName - the name of the measure to query for its valuejava.lang.IllegalArgumentException - if the named measure is not supportedpublic java.util.Enumeration<Option> listOptions()
listOptions in interface OptionHandlerlistOptions in class AbstractClassifierpublic java.lang.String[] getOptions()
getOptions in interface OptionHandlergetOptions in class AbstractClassifierpublic void setOptions(java.lang.String[] options)
throws java.lang.Exception
-I <number of trees> Number of trees to build. (default 100)
-K <number of features> Number of features to consider (<1=int(log_2(#predictors)+1)). (default 0)
-S Seed for random number generator. (default 1)
-depth <num> The maximum depth of the trees, 0 for unlimited. (default 0)
-O Don't calculate the out of bag error.
-print Print the individual trees in the output
-num-slots <num> Number of execution slots. (default 1 - i.e. no parallelism)
-B Break ties randomly when several attributes look equally good.
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
-num-decimal-places The number of decimal places for the output of numbers in the model (default 2).
setOptions in interface OptionHandlersetOptions in class AbstractClassifieroptions - the list of options as an array of stringsjava.lang.Exception - if an option is not supportedpublic Capabilities getCapabilities()
getCapabilities in interface ClassifiergetCapabilities in interface CapabilitiesHandlergetCapabilities in class AbstractClassifierCapabilitiespublic void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier in interface Classifierdata - the instances to train the classifier withjava.lang.Exception - if something goes wrongpublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance in interface ClassifierdistributionForInstance in class AbstractClassifierinstance - the instance to be classifiedjava.lang.Exception - if computation failspublic java.lang.String toString()
toString in class java.lang.Objectpublic void generatePartition(Instances data) throws java.lang.Exception
generatePartition in interface PartitionGeneratorjava.lang.Exceptionpublic double[] getMembershipValues(Instance inst) throws java.lang.Exception
getMembershipValues in interface PartitionGeneratorjava.lang.Exceptionpublic int numElements()
throws java.lang.Exception
numElements in interface PartitionGeneratorjava.lang.Exceptionpublic java.lang.String getRevision()
getRevision in interface RevisionHandlergetRevision in class AbstractClassifierpublic static void main(java.lang.String[] argv)
argv - the optionspublic RandomForest aggregate(RandomForest toAggregate) throws java.lang.Exception
Aggregateableaggregate in interface Aggregateable<RandomForest>toAggregate - the object to aggregatejava.lang.Exception - if the supplied object can't be aggregated for some
reasonpublic void finalizeAggregation()
throws java.lang.Exception
AggregateablefinalizeAggregation in interface Aggregateable<RandomForest>java.lang.Exception - if the aggregation can't be finalized for some reason