public class RandomTree.Tree
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
protected int |
m_Attribute
The attribute to split on.
|
protected double[] |
m_ClassDistribution
Class probabilities from the training data in the nominal case.
|
protected double[] |
m_Distribution
Holds the sum of squared errors and the weight in the numeric case.
|
protected double[] |
m_Prop
The proportions of training instances going down each branch.
|
protected double |
m_SplitPoint
The split point.
|
protected RandomTree.Tree[] |
m_Successors
The subtrees appended to this tree.
|
| Constructor and Description |
|---|
Tree() |
| Modifier and Type | Method and Description |
|---|---|
void |
backfitData(Instances data)
Backfits the given data into the tree.
|
protected void |
backfitData(Instances data,
double[] classProbs,
double totalWeight)
Recursively backfits data into the tree.
|
protected void |
buildTree(Instances data,
double[] classProbs,
int[] attIndicesWindow,
double totalWeight,
java.util.Random random,
int depth,
double minVariance)
Recursively generates a tree.
|
protected double |
distribution(double[][] props,
double[][][] dists,
int att,
Instances data)
Computes class distribution for an attribute.
|
double[] |
distributionForInstance(Instance 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.
|
int |
getM_Attribute()
Get the attribute this tree splits by.
|
double[] |
getM_Classdistribution()
Gets the class distribution for the last Instances object
|
double |
getM_SplitPoint()
Get the split point for the attribute (relevant only if it is numeric).
|
RandomTree.Tree[] |
getM_Successors()
Get the successor subtrees of this tree.
|
java.lang.String |
getRevision()
Returns the revision string.
|
protected java.lang.String |
leafString()
Outputs a leaf.
|
protected double |
numericDistribution(double[][] props,
double[][][] dists,
int att,
double[][] subsetWeights,
Instances data,
double[] vals)
Computes numeric class distribution for an attribute
|
int |
numNodes()
Computes size of the tree.
|
protected double |
priorVal(double[][] dist)
Computes value of splitting criterion before split.
|
protected Instances[] |
splitData(Instances data)
Splits instances into subsets based on the given split.
|
int |
toGraph(java.lang.StringBuffer text,
int num)
Outputs one node for graph.
|
protected int |
toGraph(java.lang.StringBuffer text,
int num,
RandomTree.Tree parent)
Outputs one node for graph.
|
protected java.lang.String |
toString(int level)
Recursively outputs the tree.
|
protected RandomTree.Tree[] m_Successors
protected int m_Attribute
protected double m_SplitPoint
protected double[] m_Prop
protected double[] m_ClassDistribution
protected double[] m_Distribution
public void backfitData(Instances data) throws java.lang.Exception
java.lang.Exceptionpublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
instance - the instance to compute the distribution forjava.lang.Exception - if computation failspublic int toGraph(java.lang.StringBuffer text,
int num)
throws java.lang.Exception
text - the buffer to append the output tonum - unique node idjava.lang.Exception - if generation failsprotected java.lang.String leafString()
throws java.lang.Exception
java.lang.Exception - if generation failsprotected java.lang.String toString(int level)
level - the current level of the treeprotected void backfitData(Instances data, double[] classProbs, double totalWeight) throws java.lang.Exception
data - the data to work withclassProbs - the class distributionjava.lang.Exception - if generation failsprotected void buildTree(Instances data, double[] classProbs, int[] attIndicesWindow, double totalWeight, java.util.Random random, int depth, double minVariance) throws java.lang.Exception
data - the data to work withclassProbs - the class distributionattIndicesWindow - the attribute window to choose attributes fromrandom - random number generator for choosing random attributesdepth - the current depthjava.lang.Exception - if generation failspublic int numNodes()
protected Instances[] splitData(Instances data) throws java.lang.Exception
data - the data to work withjava.lang.Exception - if something goes wrongprotected double numericDistribution(double[][] props,
double[][][] dists,
int att,
double[][] subsetWeights,
Instances data,
double[] vals)
throws java.lang.Exception
props - dists - att - subsetWeights - data - vals - java.lang.Exception - if a problem occursprotected double distribution(double[][] props,
double[][][] dists,
int att,
Instances 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)
throws java.lang.InterruptedException
dist - the distributionsjava.lang.InterruptedExceptionprotected double gain(double[][] dist,
double priorVal)
dist - the distributionspriorVal - the splitting criterionpublic java.lang.String getRevision()
protected int toGraph(java.lang.StringBuffer text,
int num,
RandomTree.Tree parent)
throws java.lang.Exception
text - the buffer to append the output tonum - the current node idparent - the parent of the nodesjava.lang.Exception - if something goes wrongpublic RandomTree.Tree[] getM_Successors()
public int getM_Attribute()
public double getM_SplitPoint()
public double[] getM_Classdistribution()