All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.m5.Node

java.lang.Object
    |
    +----weka.classifiers.m5.Node

public final class Node
extends java.lang.Object
implements java.io.Serializable
Class for handing a node in the tree or the subtree under this node

Version:
$Revision: 1.5 $
Author:
Yong Wang (yongwang@cs.waikato.ac.nz)

Constructor Index

 o Node(Instances, Node)
Constructs a new node
 o Node(Instances, Node, Options)
Constructs the root of a tree

Method Index

 o copy(Node)
Makes a copy of the tree under this node
 o errors(Instances, boolean)
Evaluates a tree
 o factor(int, int, double)
Calculates a multiplication factor used at this node
 o formulaeToString(boolean)
Converts all the linear models at the leaves under the node to a string
 o function()
Finds the appropriate order of the unsmoothed linear model at this node
 o leafNode()
Sets the node to a leaf
 o leafNum(Instance)
Detects which leaf a instance falls into
 o measures(Instances, boolean)
Computes performance measures of a tree
 o measuresToString(Measures[], Instances, int, int, String)
Converts the performance measures into a string
 o numberOfLinearModels()
Counts the number of linear models in the tree.
 o numLeaves(int)
Sets the leaves' numbers
 o predict(Instance, boolean)
Predicts the class value of an instance by the tree
 o predictionsToString(Instances, int, boolean)
Converts the predictions by the tree under this node to a string
 o prune()
Prunes the model tree
 o regression(Function)
Computes the coefficients of a linear model using the instances at this node
 o singleNodeToString()
Converts the information stored at this node to a string
 o smoothen()
Smoothens all unsmoothed formulae at the tree leaves under this node.
 o smoothenFormula(Node)
Recursively smoothens the unsmoothed linear model at this node with the unsmoothed linear models at the nodes above this
 o split(Instances)
Splits the node recursively, unless there are few instances or instances have similar values of the class attribute
 o treeToString(int, double)
Converts the tree under this node to a string
 o validation(Instances)
Computes performance measures for both unsmoothed and smoothed models
 o valueNode()
Takes a constant value as the function at the node

Constructor Detail

 o Node
public Node(Instances inst,
            Node up)
          Constructs a new node
Parameters:
inst - instances
up - the parent node
 o Node
public Node(Instances inst,
            Node up,
            Options options)
          Constructs the root of a tree
Parameters:
inst - instances
up - the parent node
options - the options

Method Detail

 o singleNodeToString
public final java.lang.String singleNodeToString() throws java.lang.Exception
          Converts the information stored at this node to a string
Returns:
the converted string
Throws:
java.lang.Exception - if something goes wrong
 o treeToString
public final java.lang.String treeToString(int treeLevel,
                                 double deviation)
          Converts the tree under this node to a string
Parameters:
treeLevel - the depth of this node; the root of a tree should have treeLevel = 0
deviation - the global deviation of the class column, used for evaluating relative errors
Returns:
the converted string
 o numberOfLinearModels
public final int numberOfLinearModels()
          Counts the number of linear models in the tree.
 o formulaeToString
public final java.lang.String formulaeToString(boolean smooth) throws java.lang.Exception
          Converts all the linear models at the leaves under the node to a string
Parameters:
smooth - either the smoothed models if true, otherwise the unsmoothed are converted
Returns:
the converted string
Throws:
java.lang.Exception - if something goes wrong
 o numLeaves
public final int numLeaves(int leafCounter)
          Sets the leaves' numbers
Parameters:
leafCounter - the number of leaves counted
Returns:
the number of the total leaves under the node
 o split
public final void split(Instances inst) throws java.lang.Exception
          Splits the node recursively, unless there are few instances or instances have similar values of the class attribute
Parameters:
inst - instances
Throws:
java.lang.Exception - if something goes wrong
 o leafNode
public final void leafNode() throws java.lang.Exception
          Sets the node to a leaf
Throws:
java.lang.Exception - if something goes wrong
 o valueNode
public final void valueNode() throws java.lang.Exception
          Takes a constant value as the function at the node
Throws:
java.lang.Exception - if something goes wrong
 o prune
public final void prune() throws java.lang.Exception
          Prunes the model tree
Parameters:
modelType - determines what kind a model is constructed, a model tree, a regression tree or a simple linear regression
pruningFactor - the pruning factor influences the size of the pruned tree
Throws:
java.lang.Exception - if something goes wrong
 o regression
public final void regression(Function function)
          Computes the coefficients of a linear model using the instances at this node
Parameters:
function - the linear model containing the index of the attributes; coefficients are to be computed
 o function
public final void function() throws java.lang.Exception
          Finds the appropriate order of the unsmoothed linear model at this node
Throws:
java.lang.Exception - if something goes wrong
 o factor
public final double factor(int n,
                           int v,
                           double pruningFactor)
          Calculates a multiplication factor used at this node
Parameters:
n - the number of instances
v - the number of the coefficients
Returns:
multiplication factor
 o smoothen
public final void smoothen()
          Smoothens all unsmoothed formulae at the tree leaves under this node.
 o smoothenFormula
public final void smoothenFormula(Node current)
          Recursively smoothens the unsmoothed linear model at this node with the unsmoothed linear models at the nodes above this
Parameters:
current - the unsmoothed linear model at the up node of the 'current' will be used for smoothening
 o predictionsToString
public final java.lang.String predictionsToString(Instances inst,
                                        int lmNo,
                                        boolean smooth) throws java.lang.Exception
          Converts the predictions by the tree under this node to a string
Parameters:
insta - instances
smooth - =ture using the smoothed models; otherwise, the unsmoothed
Returns:
the converted string
Throws:
java.lang.Exception - if something goes wrong
 o leafNum
public final int leafNum(Instance instance)
          Detects which leaf a instance falls into
Parameters:
i - instance i
inst - instances
Returns:
the leaf no.
 o predict
public final double predict(Instance instance,
                            boolean smooth)
          Predicts the class value of an instance by the tree
Parameters:
i - instance i
Returns:
the predicted value
 o errors
public final Errors errors(Instances inst,
                           boolean smooth) throws java.lang.Exception
          Evaluates a tree
Parameters:
inst - instances
Returns:
the evaluation results
Throws:
java.lang.Exception - if something goes wrong
 o measures
public final Measures measures(Instances inst,
                               boolean smooth) throws java.lang.Exception
          Computes performance measures of a tree
Parameters:
inst - instances
smooth - =true uses the smoothed models; otherwise uses the unsmoothed models
Returns:
the performance measures
Throws:
java.lang.Exception - if something goes wrong
 o validation
public final Measures[] validation(Instances inst) throws java.lang.Exception
          Computes performance measures for both unsmoothed and smoothed models
Parameters:
inst - instances
Throws:
java.lang.Exception - if something goes wrong
 o copy
public final Node copy(Node up) throws java.lang.Exception
          Makes a copy of the tree under this node
Parameters:
up - the parant node of the new node
Returns:
a copy of the tree under this node
Throws:
java.lang.Exception - if something goes wrong
 o measuresToString
public final java.lang.String measuresToString(Measures measures[],
                                     Instances inst,
                                     int lmNo,
                                     int verbosity,
                                     java.lang.String str) throws java.lang.Exception
          Converts the performance measures into a string
Parameters:
measures[] - contains both the unsmoothed and smoothed measures
inst - the instances
lmNo - also converts the predictions by all linear models if lmNo=0, or one linear model spedified by lmNo.
verbosity - the verbosity level
str - the type of evaluation, one of "t" for training, "T" for testing, "f" for fold training, "F" for fold testing, "x" for cross-validation
Returns:
the converted string
Throws:
java.lang.Exception - if something goes wrong

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home