public final class M5TreeNode
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
M5TreeNode(M5Instances inst,
M5TreeNode up)
Constructs a new node
|
M5TreeNode(M5Instances inst,
M5TreeNode up,
InformationHandler options)
Constructs the root of a tree
|
Modifier and Type | Method and Description |
---|---|
M5TreeNode |
copy(M5TreeNode up)
Makes a copy of the tree under this node
|
Results |
errors(M5Instances inst,
boolean smooth)
Evaluates a tree
|
double |
factor(int n,
int v,
double pruningFactor)
Calculates a multiplication factor used at this node
|
java.lang.String |
formulaeToString(boolean smooth)
Converts all the linear models at the leaves under the node to a string
|
void |
function()
Finds the appropriate order of the unsmoothed linear model at this node
|
void |
leafNode()
Sets the node to a leaf
|
int |
leafNum(M5Instance instance)
Detects which leaf a instance falls into
|
Measures |
measures(M5Instances inst,
boolean smooth)
Computes performance measures of a tree
|
java.lang.String |
measuresToString(Measures[] measures,
M5Instances inst,
int lmNo,
int verbosity,
java.lang.String str)
Converts the performance measures into a string
|
int |
numberOfLinearModels()
Counts the number of linear models in the tree.
|
int |
numLeaves(int leafCounter)
Sets the leaves' numbers
|
double |
predict(M5Instance instance,
boolean smooth)
Predicts the class value of an instance by the tree
|
java.lang.String |
predictionsToString(M5Instances inst,
int lmNo,
boolean smooth)
Converts the predictions by the tree under this node to a string
|
void |
prune()
Prunes the model tree
|
void |
regression(Function function)
Computes the coefficients of a linear model using the instances at this
node
|
java.lang.String |
singleNodeToString()
Converts the information stored at this node to a string
|
void |
smoothen()
Smoothens all unsmoothed formulae at the tree leaves under this node.
|
void |
smoothenFormula(M5TreeNode current)
Recursively smoothens the unsmoothed linear model at this node with the
unsmoothed linear models at the nodes above this
|
void |
split(M5Instances inst)
Splits the node recursively, unless there are few instances or
instances have similar values of the class attribute
|
java.lang.String |
treeToString(int treeLevel,
double deviation)
Converts the tree under this node to a string
|
Measures[] |
validation(M5Instances inst)
Computes performance measures for both unsmoothed and smoothed models
|
void |
valueNode()
Takes a constant value as the function at the node
|
public M5TreeNode(M5Instances inst, M5TreeNode up)
inst
- instancesup
- the parent nodepublic M5TreeNode(M5Instances inst, M5TreeNode up, InformationHandler options)
inst
- instancesup
- the parent nodeoptions
- the optionspublic final java.lang.String singleNodeToString() throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final java.lang.String treeToString(int treeLevel, double deviation)
treeLevel
- the depth of this node;
the root of a tree should have treeLevel = 0deviation
- the global deviation of the class column,
used for evaluating relative errorspublic final int numberOfLinearModels()
public final java.lang.String formulaeToString(boolean smooth) throws java.lang.Exception
smooth
- either the smoothed models if true, otherwise
the unsmoothed are convertedjava.lang.Exception
- if something goes wrongpublic final int numLeaves(int leafCounter)
leafCounter
- the number of leaves countedpublic final void split(M5Instances inst) throws java.lang.Exception
inst
- instancesjava.lang.Exception
- if something goes wrongpublic final void leafNode() throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final void valueNode() throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final void prune() throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final void regression(Function function)
function
- the linear model containing the index of the attributes;
coefficients are to be computedpublic final void function() throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final double factor(int n, int v, double pruningFactor)
n
- the number of instancesv
- the number of the coefficientspruningFactor
- the pruning factorpublic final void smoothen()
public final void smoothenFormula(M5TreeNode current)
current
- the unsmoothed linear model at the up node of the
'current' will be used for smootheningpublic final java.lang.String predictionsToString(M5Instances inst, int lmNo, boolean smooth) throws java.lang.Exception
inst
- instanceslmNo
- lm Nosmooth
- =ture using the smoothed models; otherwise, the unsmoothedjava.lang.Exception
- if something goes wrongpublic final int leafNum(M5Instance instance)
instance
- instancespublic final double predict(M5Instance instance, boolean smooth)
instance
- instance ismooth
- =true, uses the smoothed model; otherwise uses the unsmoothedpublic final Results errors(M5Instances inst, boolean smooth) throws java.lang.Exception
inst
- instancessmooth
- =true, evaluates the smoothed models;
=false, evaluats the unsmoothed modelsjava.lang.Exception
- if something goes wrongpublic final Measures measures(M5Instances inst, boolean smooth) throws java.lang.Exception
inst
- instancessmooth
- =true uses the smoothed models;
otherwise uses the unsmoothed modelsjava.lang.Exception
- if something goes wrongpublic final Measures[] validation(M5Instances inst) throws java.lang.Exception
inst
- instancesjava.lang.Exception
- if something goes wrongpublic final M5TreeNode copy(M5TreeNode up) throws java.lang.Exception
up
- the parant node of the new nodejava.lang.Exception
- if something goes wrongpublic final java.lang.String measuresToString(Measures[] measures, M5Instances inst, int lmNo, int verbosity, java.lang.String str) throws java.lang.Exception
measures
- contains both the unsmoothed and smoothed measuresinst
- the instanceslmNo
- also converts the predictions by all linear models if lmNo=0,
or one linear model spedified by lmNo.verbosity
- the verbosity levelstr
- the type of evaluation, one of
"t" for training, "T" for testing,
"f" for fold training, "F" for fold testing,
"x" for cross-validationjava.lang.Exception
- if something goes wrong