weka.classifiers.trees.j48
Class C45PruneableClassifierTree

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

public class C45PruneableClassifierTree
extends ClassifierTree

Class for handling a tree structure that can be pruned using C4.5 procedures.

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

Field Summary
(package private)  float m_CF
          The confidence factor for pruning.
(package private)  boolean m_cleanup
          Cleanup after the tree has been built.
(package private)  boolean m_pruneTheTree
          True if the tree is to be pruned.
(package private)  boolean m_subtreeRaising
          Is subtree raising to be performed?
 
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
C45PruneableClassifierTree(ModelSelection toSelectLocModel, boolean pruneTree, float cf, boolean raiseTree, boolean cleanup)
          Constructor for pruneable tree structure.
 
Method Summary
 void buildClassifier(Instances data)
          Method for building a pruneable classifier tree.
 void collapse()
          Collapses a tree to a node if training error doesn't increase.
private  double getEstimatedErrors()
          Computes estimated errors for tree.
private  double getEstimatedErrorsForBranch(Instances data)
          Computes estimated errors for one branch.
private  double getEstimatedErrorsForDistribution(Distribution theDistribution)
          Computes estimated errors for leaf.
protected  ClassifierTree getNewTree(Instances data)
          Returns a newly created tree.
private  double getTrainingErrors()
          Computes errors of tree on training data.
private  ClassifierSplitModel localModel()
          Method just exists to make program easier to read.
private  void newDistribution(Instances data)
          Computes new distributions of instances for nodes in tree.
 void prune()
          Prunes a tree using C4.5's pruning procedure.
private  C45PruneableClassifierTree 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

m_pruneTheTree

boolean m_pruneTheTree
True if the tree is to be pruned.


m_CF

float m_CF
The confidence factor for pruning.


m_subtreeRaising

boolean m_subtreeRaising
Is subtree raising to be performed?


m_cleanup

boolean m_cleanup
Cleanup after the tree has been built.

Constructor Detail

C45PruneableClassifierTree

public C45PruneableClassifierTree(ModelSelection toSelectLocModel,
                                  boolean pruneTree,
                                  float cf,
                                  boolean raiseTree,
                                  boolean cleanup)
                           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
cf - the confidence factor for pruning
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 something goes wrong

collapse

public final void collapse()
Collapses a tree to a node if training error doesn't increase.


prune

public void prune()
           throws java.lang.Exception
Prunes a tree using C4.5's pruning procedure.

Throws:
java.lang.Exception - if something goes wrong

getNewTree

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

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

getEstimatedErrors

private double getEstimatedErrors()
Computes estimated errors for tree.


getEstimatedErrorsForBranch

private double getEstimatedErrorsForBranch(Instances data)
                                    throws java.lang.Exception
Computes estimated errors for one branch.

Throws:
java.lang.Exception - if something goes wrong

getEstimatedErrorsForDistribution

private double getEstimatedErrorsForDistribution(Distribution theDistribution)
Computes estimated errors for leaf.


getTrainingErrors

private double getTrainingErrors()
Computes errors of tree on training data.


localModel

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


newDistribution

private void newDistribution(Instances data)
                      throws java.lang.Exception
Computes new distributions of instances for nodes in tree.

Throws:
java.lang.Exception - if something goes wrong

son

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