weka.classifiers.trees.j48
Class PruneableClassifierTree

java.lang.Object
  extended byweka.classifiers.trees.j48.ClassifierTree
      extended byweka.classifiers.trees.j48.PruneableClassifierTree
All Implemented Interfaces:
Drawable, java.io.Serializable

public class PruneableClassifierTree
extends ClassifierTree

Class for handling a tree structure that can be pruned using a pruning set.

Version:
$Revision: 1.8 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
private  boolean m_cleanup
          Cleanup after the tree has been built.
private  int m_seed
          The random number seed.
private  int numSets
          How many subsets of equal size?
private  boolean pruneTheTree
          True if the tree is to be pruned.
 
Fields inherited from class weka.classifiers.trees.j48.ClassifierTree
m_id, m_isEmpty, m_isLeaf, m_localModel, m_sons, m_test, m_toSelectModel, m_train
 
Fields inherited from interface weka.core.Drawable
BayesNet, NOT_DRAWABLE, TREE
 
Constructor Summary
PruneableClassifierTree(ModelSelection toSelectLocModel, boolean pruneTree, int num, boolean cleanup, int seed)
          Constructor for pruneable tree structure.
 
Method Summary
 void buildClassifier(Instances data)
          Method for building a pruneable classifier tree.
private  double errorsForLeaf()
          Computes estimated errors for leaf.
private  double errorsForTree()
          Computes estimated errors for tree.
protected  ClassifierTree getNewTree(Instances train, Instances test)
          Returns a newly created tree.
private  ClassifierSplitModel localModel()
          Method just exists to make program easier to read.
 void prune()
          Prunes a tree.
private  PruneableClassifierTree son(int index)
          Method just exists to make program easier to read.
 
Methods inherited from class weka.classifiers.trees.j48.ClassifierTree
assignIDs, buildTree, buildTree, classifyInstance, cleanup, distributionForInstance, getNewTree, graph, graphType, nextID, numLeaves, numNodes, prefix, resetID, toSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pruneTheTree

private boolean pruneTheTree
True if the tree is to be pruned.


numSets

private int numSets
How many subsets of equal size? One used for pruning, the rest for training.


m_cleanup

private boolean m_cleanup
Cleanup after the tree has been built.


m_seed

private int m_seed
The random number seed.

Constructor Detail

PruneableClassifierTree

public PruneableClassifierTree(ModelSelection toSelectLocModel,
                               boolean pruneTree,
                               int num,
                               boolean cleanup,
                               int seed)
                        throws java.lang.Exception
Constructor for pruneable tree structure. Stores reference to associated training data at each node.

Parameters:
toSelectLocModel - selection method for local splitting model
pruneTree - true if the tree is to be pruned
num - number of subsets of equal size
Throws:
java.lang.Exception - if something goes wrong
Method Detail

buildClassifier

public void buildClassifier(Instances data)
                     throws java.lang.Exception
Method for building a pruneable classifier tree.

Overrides:
buildClassifier in class ClassifierTree
Throws:
java.lang.Exception - if tree can't be built successfully

prune

public void prune()
           throws java.lang.Exception
Prunes a tree.

Throws:
java.lang.Exception - if tree can't be pruned successfully

getNewTree

protected ClassifierTree getNewTree(Instances train,
                                    Instances test)
                             throws java.lang.Exception
Returns a newly created tree.

Overrides:
getNewTree in class ClassifierTree
Parameters:
test - the pruning data.
Throws:
java.lang.Exception - if something goes wrong

errorsForTree

private double errorsForTree()
                      throws java.lang.Exception
Computes estimated errors for tree.

Throws:
java.lang.Exception - if error estimate can't be computed

errorsForLeaf

private double errorsForLeaf()
                      throws java.lang.Exception
Computes estimated errors for leaf.

Throws:
java.lang.Exception - if error estimate can't be computed

localModel

private ClassifierSplitModel localModel()
Method just exists to make program easier to read.


son

private PruneableClassifierTree son(int index)
Method just exists to make program easier to read.