public class FastRandomForest extends AbstractClassifier implements OptionHandler, Randomizable, WeightedInstancesHandler, AdditionalMeasureProducer, TechnicalInformationHandler
Class for constructing a forest of random trees.
For more information see:
Leo Breiman (2001). Random Forests. Machine Learning. 45(1):5-32.
BibTeX:
@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)
-D If set, classifier is run in debug mode and may output additional info to the console
Modifier and Type | Field and Description |
---|---|
protected hr.irb.fastRandomForest.FastRfBagging |
m_bagger
The bagger.
|
protected Instances |
m_Info
The header information.
|
protected int |
m_KValue
Final number of features that were considered in last build.
|
protected int |
m_MaxDepth
The maximum depth of the trees (0 = unlimited)
|
protected int |
m_numFeatures
Number of features to consider in random feature selection.
|
protected int |
m_NumThreads
Number of simultaneous threads to use in computation (0 = autodetect).
|
protected int |
m_numTrees
Number of trees in forest.
|
protected int |
m_randomSeed
The random seed.
|
protected AbstractClassifier |
m_ZeroR
a ZeroR model in case no model can be built from the data
|
BATCH_SIZE_DEFAULT, m_BatchSize, m_Debug, m_DoNotCheckCapabilities, m_numDecimalPlaces, NUM_DECIMAL_PLACES_DEFAULT
Constructor and Description |
---|
FastRandomForest() |
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.
|
boolean |
getComputeImportances() |
double[] |
getFeatureImportances() |
int |
getMaxDepth()
Get the maximum depth of trh tree, 0 for unlimited.
|
double |
getMeasure(String additionalMeasureName)
Returns the value of the named measure.
|
int |
getNumFeatures()
Get the number of features used in random selection.
|
int |
getNumThreads()
Get the number of simultaneous threads used in training, 0 for autodetect.
|
int |
getNumTrees()
Get the value of numTrees.
|
String[] |
getOptions()
Gets the current settings of the forest.
|
String |
getRevision() |
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 |
numFeaturesTipText()
Returns the tip text for this property
|
String |
numThreadsTipText()
Returns the tip text for this property
|
String |
numTreesTipText()
Returns the tip text for this property
|
String |
seedTipText()
Returns the tip text for this property
|
void |
setComputeImportances(boolean computeImportances) |
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 |
setNumThreads(int value)
Set the number of simultaneous threads used in training, 0 for autodetect.
|
void |
setNumTrees(int newNumTrees)
Set the value of numTrees.
|
void |
setOptions(String[] options)
Parses a given list of options.
|
void |
setSeed(int seed)
Set the seed for random number generation.
|
String |
toString()
Outputs a description of this classifier.
|
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
makeCopy
protected int m_numTrees
protected int m_numFeatures
protected int m_randomSeed
protected int m_KValue
protected int m_NumThreads
protected hr.irb.fastRandomForest.FastRfBagging m_bagger
protected int m_MaxDepth
protected Instances m_Info
protected AbstractClassifier m_ZeroR
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 numThreadsTipText()
public int getNumThreads()
public void setNumThreads(int value)
value
- the maximum depth.public boolean getComputeImportances()
public void setComputeImportances(boolean computeImportances)
computeImportances
- compute feature importances?public double measureOutOfBagError()
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
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)
-threads Number of simultaneous threads to use. (default 0 = autodetect number of available cores)
-import Compute and output RF feature importances (slow).
-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
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 static void main(String[] argv)
argv
- the optionspublic String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClassifier
public double[] getFeatureImportances()
null
if the importances haven't been computedCopyright © 2015–2021 Fiji. All rights reserved.