Package weka.classifiers.trees
Class RandomTree
java.lang.Object
weka.classifiers.Classifier
weka.classifiers.trees.RandomTree
- All Implemented Interfaces:
Serializable,Cloneable,CapabilitiesHandler,Drawable,OptionHandler,Randomizable,RevisionHandler,WeightedInstancesHandler
public class RandomTree
extends Classifier
implements OptionHandler, WeightedInstancesHandler, Randomizable, Drawable
Class for constructing a tree that considers K
randomly chosen attributes at each node. Performs no pruning. Also has an
option to allow estimation of class probabilities based on a hold-out set
(backfitting).
Valid options are:
-K <number of attributes> Number of attributes to randomly investigate. (default 0) (<0 = int(log_2(#predictors)+1)).
-M <minimum number of instances> Set minimum number of instances per leaf.
-S <num> Seed for random number generator. (default 1)
-depth <num> The maximum depth of the tree, 0 for unlimited. (default 0)
-N <num> Number of folds for backfitting (default 0, no backfitting).
-U Allow unclassified instances.
-D If set, classifier is run in debug mode and may output additional info to the console
- Version:
- $Revision: 10993 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz), Richard Kirkby (rkirkby@cs.waikato.ac.nz)
- See Also:
-
Field Summary
Fields inherited from interface weka.core.Drawable
BayesNet, Newick, NOT_DRAWABLE, TREE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the tip text for this propertyvoidbuildClassifier(Instances data) Builds classifier.double[]distributionForInstance(Instance instance) Computes class distribution of an instance using the tree.voidgeneratePartition(Instances data) Builds the classifier to generate a partition.booleanGet the value of NumFolds.Returns default capabilities of the classifier.intGet the value of K.intGet the maximum depth of trh tree, 0 for unlimited.double[]getMembershipValues(Instance instance) Computes array that indicates node membership.doubleGet the value of MinNum.intGet the value of NumFolds.String[]Gets options from this classifier.intgetSeed()Gets the seed for the random number generationsReturns a string describing classifiergraph()Returns graph describing the tree.intReturns the type of graph this classifier represents.Returns the tip text for this propertyLists the command-line options for this classifier.static voidMain method for this class.Returns the tip text for this propertyReturns the tip text for this propertyintReturns the number of elements in the partition.Returns the tip text for this propertyReturns the tip text for this propertyvoidsetAllowUnclassifiedInstances(boolean newAllowUnclassifiedInstances) Set the value of AllowUnclassifiedInstances.voidsetKValue(int k) Set the value of K.voidsetMaxDepth(int value) Set the maximum depth of the tree, 0 for unlimited.voidsetMinNum(double newMinNum) Set the value of MinNum.voidsetNumFolds(int newNumFolds) Set the value of NumFolds.voidsetOptions(String[] options) Parses a given list of options.voidsetSeed(int seed) Set the seed for random number generation.toString()Outputs the decision tree.Methods inherited from class weka.classifiers.Classifier
classifyInstance, debugTipText, forName, getDebug, getRevision, makeCopies, makeCopy, setDebug
-
Constructor Details
-
RandomTree
public RandomTree()
-
-
Method Details
-
globalInfo
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
minNumTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getMinNum
public double getMinNum()Get the value of MinNum.- Returns:
- Value of MinNum.
-
setMinNum
public void setMinNum(double newMinNum) Set the value of MinNum.- Parameters:
newMinNum- Value to assign to MinNum.
-
KValueTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getKValue
public int getKValue()Get the value of K.- Returns:
- Value of K.
-
setKValue
public void setKValue(int k) Set the value of K.- Parameters:
k- Value to assign to K.
-
seedTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setSeed
public void setSeed(int seed) Set the seed for random number generation.- Specified by:
setSeedin interfaceRandomizable- Parameters:
seed- the seed
-
getSeed
public int getSeed()Gets the seed for the random number generations- Specified by:
getSeedin interfaceRandomizable- Returns:
- the seed for the random number generation
-
maxDepthTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getMaxDepth
public int getMaxDepth()Get the maximum depth of trh tree, 0 for unlimited.- Returns:
- the maximum depth.
-
numFoldsTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNumFolds
public int getNumFolds()Get the value of NumFolds.- Returns:
- Value of NumFolds.
-
setNumFolds
public void setNumFolds(int newNumFolds) Set the value of NumFolds.- Parameters:
newNumFolds- Value to assign to NumFolds.
-
allowUnclassifiedInstancesTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getAllowUnclassifiedInstances
public boolean getAllowUnclassifiedInstances()Get the value of NumFolds.- Returns:
- Value of NumFolds.
-
setAllowUnclassifiedInstances
public void setAllowUnclassifiedInstances(boolean newAllowUnclassifiedInstances) Set the value of AllowUnclassifiedInstances.- Parameters:
newAllowUnclassifiedInstances- Value to assign to AllowUnclassifiedInstances.
-
setMaxDepth
public void setMaxDepth(int value) Set the maximum depth of the tree, 0 for unlimited.- Parameters:
value- the maximum depth.
-
listOptions
Lists the command-line options for this classifier.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classClassifier- Returns:
- an enumeration over all possible options
-
getOptions
Gets options from this classifier.- Specified by:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classClassifier- Returns:
- the options for the current setup
-
setOptions
Parses a given list of options. Valid options are:-K <number of attributes> Number of attributes to randomly investigate (<0 = int(log_2(#attributes)+1)).
-M <minimum number of instances> Set minimum number of instances per leaf.
-S <num> Seed for random number generator. (default 1)
-depth <num> The maximum depth of the tree, 0 for unlimited. (default 0)
-N <num> Number of folds for backfitting (default 0, no backfitting).
-U Allow unclassified instances.
-D If set, classifier is run in debug mode and may output additional info to the console
- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classClassifier- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
getCapabilities
Returns default capabilities of the classifier.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Overrides:
getCapabilitiesin classClassifier- Returns:
- the capabilities of this classifier
- See Also:
-
buildClassifier
Builds classifier.- Specified by:
buildClassifierin classClassifier- Parameters:
data- the data to train with- Throws:
Exception- if something goes wrong or the data doesn't fit
-
distributionForInstance
Computes class distribution of an instance using the tree.- Overrides:
distributionForInstancein classClassifier- Parameters:
instance- the instance to compute the distribution for- Returns:
- the computed class probabilities
- Throws:
Exception- if computation fails
-
toString
Outputs the decision tree. -
graph
Returns graph describing the tree. -
graphType
public int graphType()Returns the type of graph this classifier represents. -
generatePartition
Builds the classifier to generate a partition.- Throws:
Exception
-
getMembershipValues
Computes array that indicates node membership. Array locations are allocated based on breadth-first exploration of the tree.- Throws:
Exception
-
numElements
Returns the number of elements in the partition.- Throws:
Exception
-
main
Main method for this class.- Parameters:
argv- the commandline parameters
-