public class RandomTree
extends java.lang.Object
-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
Modifier and Type | Field and Description |
---|---|
protected boolean |
m_AllowUnclassifiedInstances
Whether unclassified instances are allowed
|
protected int |
m_Attribute
The attribute to split on.
|
protected double[] |
m_ClassDistribution
Class probabilities from the training data.
|
protected boolean |
m_Debug
Debug flag.
|
protected PrototypeSet |
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 int |
m_NumFolds
Determines how much data is used for backfitting
|
protected double[] |
m_Prop
The proportions of training instances going down each branch.
|
protected int |
m_randomSeed
The random seed to use.
|
protected double |
m_SplitPoint
The split point.
|
protected RandomTree[] |
m_Successors
The subtrees appended to this tree.
|
protected int |
nClasses
Number of classes of the problem.
|
Constructor and Description |
---|
RandomTree() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
allowUnclassifiedInstancesTipText()
Returns the tip text for this property
|
void |
backfitData(PrototypeSet data)
Backfits the given data into the tree.
|
protected void |
backfitData(PrototypeSet data,
double[] classProbs)
Recursively backfits data into the tree.
|
void |
buildClassifier(PrototypeSet data)
Builds classifier.
|
protected void |
buildTree(PrototypeSet data,
double[] classProbs,
PrototypeSet header,
double minNum,
boolean debug,
int[] attIndicesWindow,
int depth,
boolean allow)
Recursively generates a tree.
|
protected double |
distribution(double[][] props,
double[][][] dists,
int att,
PrototypeSet data)
Computes class distribution for an attribute.
|
double[] |
distributionForInstance(Prototype instance)
Computes class distribution of an instance using the decision tree.
|
protected double |
gain(double[][] dist,
double priorVal)
Computes value of splitting criterion after split.
|
boolean |
getAllowUnclassifiedInstances()
Get the value of NumFolds.
|
int |
getKValue()
Get the value of K.
|
int |
getMaxDepth()
Get the maximum depth of trh tree, 0 for unlimited.
|
double |
getMinNum()
Get the value of MinNum.
|
int |
getNumFolds()
Get the value of NumFolds.
|
int |
getSeed()
Gets the seed for the random number generations
|
java.lang.String |
globalInfo()
Returns a string describing classifier
|
java.lang.String |
KValueTipText()
Returns the tip text for this property
|
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 |
numFoldsTipText()
Returns the tip text for this property
|
int |
numNodes()
Computes size of the tree.
|
protected double |
priorVal(double[][] dist)
Computes value of splitting criterion before split.
|
java.lang.String |
seedTipText()
Returns the tip text for this property
|
void |
setAllowUnclassifiedInstances(boolean newAllowUnclassifiedInstances)
Set the value of AllowUnclassifiedInstances.
|
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 |
setNumFolds(int newNumFolds)
Set the value of NumFolds.
|
void |
setSeed(int seed)
Set the seed for random number generation.
|
protected PrototypeSet[] |
splitData(PrototypeSet data)
Splits instances into subsets based on the given split.
|
protected RandomTree[] m_Successors
protected int m_Attribute
protected double m_SplitPoint
protected PrototypeSet m_Info
protected double[] m_Prop
protected double[] m_ClassDistribution
protected double m_MinNum
protected int m_KValue
protected int m_randomSeed
protected int m_MaxDepth
protected int m_NumFolds
protected boolean m_Debug
protected int nClasses
protected boolean m_AllowUnclassifiedInstances
public java.lang.String globalInfo()
public java.lang.String minNumTipText()
public double getMinNum()
public void setMinNum(double newMinNum)
newMinNum
- Value to assign to MinNum.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)
seed
- the seedpublic int getSeed()
public java.lang.String maxDepthTipText()
public int getMaxDepth()
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
- Value to assign to AllowUnclassifiedInstances.public void setMaxDepth(int value)
value
- the maximum depth.public void buildClassifier(PrototypeSet data) throws java.lang.Exception
data
- the data to train withjava.lang.Exception
- if something goes wrong or the data doesn't fitpublic void backfitData(PrototypeSet data) throws java.lang.Exception
data
- data used to backfit it into the tree.java.lang.Exception
- if the backfitting can not be done.public double[] distributionForInstance(Prototype instance) throws java.lang.Exception
instance
- the instance to compute the distribution forjava.lang.Exception
- if computation failsprotected void backfitData(PrototypeSet data, double[] classProbs) throws java.lang.Exception
data
- the data to work withclassProbs
- the class distributionjava.lang.Exception
- if generation failsprotected void buildTree(PrototypeSet data, double[] classProbs, PrototypeSet header, double minNum, boolean debug, int[] attIndicesWindow, int depth, boolean allow) throws java.lang.Exception
data
- the data to work withclassProbs
- the class distributionheader
- the header of the dataminNum
- the minimum number of instances per leafdebug
- whether debugging is onattIndicesWindow
- the attribute window to choose attributes fromdepth
- the current depthallow
- flag to allow unclassified instances or not.java.lang.Exception
- if generation failspublic int numNodes()
protected PrototypeSet[] splitData(PrototypeSet data) throws java.lang.Exception
data
- the data to work withjava.lang.Exception
- if something goes wrongprotected double distribution(double[][] props, double[][][] dists, int att, PrototypeSet data) throws java.lang.Exception
props
- dists
- att
- the attribute indexdata
- the data to work withjava.lang.Exception
- if something goes wrongprotected double priorVal(double[][] dist)
dist
- the distributionsprotected double gain(double[][] dist, double priorVal)
dist
- the distributionspriorVal
- the splitting criterionpublic static void main(java.lang.String[] argv)
argv
- the commandline parameters