public class RandomTree extends AbstractClassifier implements OptionHandler, WeightedInstancesHandler, Randomizable, Drawable, PartitionGenerator
-K <number of attributes> Number of attributes to randomly investigate. (default 0) (<1 = int(log_2(#predictors)+1)).
-M <minimum number of instances> Set minimum number of instances per leaf. (default 1)
-V <minimum variance for split> Set minimum numeric class variance proportion of train variance for split (default 1e-3).
-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.
-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).
| Modifier and Type | Class and Description |
|---|---|
class |
RandomTree.Tree
The inner class for dealing with the tree.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_AllowUnclassifiedInstances
Whether unclassified instances are allowed
|
protected boolean |
m_BreakTiesRandomly
Whether to break ties randomly.
|
protected boolean |
m_computeImpurityDecreases
Whether to store the impurity decrease/gain sum
|
protected double[][] |
m_impurityDecreasees
Indexed by attribute, each two element array contains impurity decrease/gain sum in first element
and count in the second
|
protected Instances |
m_Info
The header information.
|
protected int |
m_KValue
The number of attributes considered for a split.
|
protected int |
m_MaxDepth
The maximum depth of the tree (0 = unlimited)
|
protected double |
m_MinNum
Minimum number of instances for leaf.
|
protected double |
m_MinVarianceProp
The minimum proportion of the total variance (over all the data) required for split.
|
protected int |
m_NumFolds
Determines how much data is used for backfitting
|
protected int |
m_randomSeed
The random seed to use.
|
protected RandomTree.Tree |
m_Tree
The Tree object
|
protected Classifier |
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_DEFAULTBayesNet, Newick, NOT_DRAWABLE, TREE| Constructor and Description |
|---|
RandomTree() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
allowUnclassifiedInstancesTipText()
Returns the tip text for this property
|
java.lang.String |
breakTiesRandomlyTipText()
Returns the tip text for this property
|
void |
buildClassifier(Instances data)
Builds classifier.
|
double[] |
distributionForInstance(Instance instance)
Computes class distribution of an instance using the tree.
|
void |
generatePartition(Instances data)
Builds the classifier to generate a partition.
|
boolean |
getAllowUnclassifiedInstances()
Gets whether tree is allowed to abstain from making a prediction.
|
boolean |
getBreakTiesRandomly()
Get whether to break ties randomly.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
boolean |
getComputeImpurityDecreases()
Get whether to compute/store impurity decreases for variable importance in RandomForest
|
double[][] |
getImpurityDecreases()
Get the array of impurity decrease/gain sums
|
int |
getKValue()
Get the value of K.
|
RandomTree.Tree |
getM_Tree() |
int |
getMaxDepth()
Get the maximum depth of trh tree, 0 for unlimited.
|
double[] |
getMembershipValues(Instance instance)
Computes array that indicates node membership.
|
double |
getMinNum()
Get the value of MinNum.
|
double |
getMinVarianceProp()
Get the value of MinVarianceProp.
|
int |
getNumFolds()
Get the value of NumFolds.
|
java.lang.String[] |
getOptions()
Gets options from this classifier.
|
int |
getSeed()
Gets the seed for the random number generations
|
java.lang.String |
globalInfo()
Returns a string describing classifier
|
java.lang.String |
graph()
Returns graph describing the tree.
|
int |
graphType()
Returns the type of graph this classifier represents.
|
java.lang.String |
KValueTipText()
Returns the tip text for this property
|
java.util.Enumeration<Option> |
listOptions()
Lists the command-line options for this classifier.
|
static void |
main(java.lang.String[] argv)
Main method for this class.
|
java.lang.String |
maxDepthTipText()
Returns the tip text for this property
|
java.lang.String |
minNumTipText()
Returns the tip text for this property
|
java.lang.String |
minVariancePropTipText()
Returns the tip text for this property
|
int |
numElements()
Returns the number of elements in the partition.
|
java.lang.String |
numFoldsTipText()
Returns the tip text for this property
|
java.lang.String |
seedTipText()
Returns the tip text for this property
|
void |
setAllowUnclassifiedInstances(boolean newAllowUnclassifiedInstances)
Set the value of AllowUnclassifiedInstances.
|
void |
setBreakTiesRandomly(boolean newBreakTiesRandomly)
Set whether to break ties randomly.
|
void |
setComputeImpurityDecreases(boolean computeImpurityDecreases)
Set whether to compute/store impurity decreases for variable importance in RandomForest
|
void |
setKValue(int k)
Set the value of K.
|
void |
setMaxDepth(int value)
Set the maximum depth of the tree, 0 for unlimited.
|
void |
setMinNum(double newMinNum)
Set the value of MinNum.
|
void |
setMinVarianceProp(double newMinVarianceProp)
Set the value of MinVarianceProp.
|
void |
setNumFolds(int newNumFolds)
Set the value of NumFolds.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
setSeed(int seed)
Set the seed for random number generation.
|
protected static double |
singleVariance(double s,
double sS,
double weight)
Computes the variance for a single set
|
java.lang.String |
toString()
Outputs the decision tree.
|
protected static double |
variance(double[] s,
double[] sS,
double[] sumOfWeights)
Computes variance for subsets.
|
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, getRevision, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlacesprotected RandomTree.Tree m_Tree
protected Instances m_Info
protected double m_MinNum
protected int m_KValue
protected int m_randomSeed
protected int m_MaxDepth
protected int m_NumFolds
protected boolean m_AllowUnclassifiedInstances
protected boolean m_BreakTiesRandomly
protected Classifier m_zeroR
protected double m_MinVarianceProp
protected boolean m_computeImpurityDecreases
protected double[][] m_impurityDecreasees
public java.lang.String globalInfo()
public double[][] getImpurityDecreases()
@ProgrammaticProperty public void setComputeImpurityDecreases(boolean computeImpurityDecreases)
computeImpurityDecreases - true to compute and store impurity decrease values for splitting attributespublic boolean getComputeImpurityDecreases()
public java.lang.String minNumTipText()
public double getMinNum()
public void setMinNum(double newMinNum)
newMinNum - Value to assign to MinNum.public java.lang.String minVariancePropTipText()
public double getMinVarianceProp()
public void setMinVarianceProp(double newMinVarianceProp)
newMinVarianceProp - Value to assign to MinVarianceProp.public java.lang.String KValueTipText()
public int getKValue()
public void setKValue(int k)
k - Value to assign to K.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 numFoldsTipText()
public int getNumFolds()
public void setNumFolds(int newNumFolds)
newNumFolds - Value to assign to NumFolds.public java.lang.String allowUnclassifiedInstancesTipText()
public boolean getAllowUnclassifiedInstances()
public void setAllowUnclassifiedInstances(boolean newAllowUnclassifiedInstances)
newAllowUnclassifiedInstances - true if tree is allowed to abstain from making a predictionpublic java.lang.String breakTiesRandomlyTipText()
public boolean getBreakTiesRandomly()
public void setBreakTiesRandomly(boolean newBreakTiesRandomly)
newBreakTiesRandomly - true if ties are to be broken randomlypublic 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
-K <number of attributes> Number of attributes to randomly investigate. (default 0) (<1 = int(log_2(#predictors)+1)).
-M <minimum number of instances> Set minimum number of instances per leaf. (default 1)
-V <minimum variance for split> Set minimum numeric class variance proportion of train variance for split (default 1e-3).
-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.
-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 data to train withjava.lang.Exception - if something goes wrong or the data doesn't fitpublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance in interface ClassifierdistributionForInstance in class AbstractClassifierinstance - the instance to compute the distribution forjava.lang.Exception - if computation failspublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String graph()
throws java.lang.Exception
public int graphType()
public void generatePartition(Instances data) throws java.lang.Exception
generatePartition in interface PartitionGeneratorjava.lang.Exceptionpublic double[] getMembershipValues(Instance instance) throws java.lang.Exception
getMembershipValues in interface PartitionGeneratorjava.lang.Exceptionpublic int numElements()
throws java.lang.Exception
numElements in interface PartitionGeneratorjava.lang.Exceptionprotected static double variance(double[] s,
double[] sS,
double[] sumOfWeights)
s - sS - sumOfWeights - protected static double singleVariance(double s,
double sS,
double weight)
s - sS - weight - the weightpublic static void main(java.lang.String[] argv)
argv - the commandline parameterspublic RandomTree.Tree getM_Tree()