All Packages Class Hierarchy This Package Previous Next Index WEKA's home
Class weka.classifiers.j48.ClassifierTree
java.lang.Object
|
+----weka.classifiers.j48.ClassifierTree
- public class ClassifierTree
- extends java.lang.Object
- implements Drawable, java.io.Serializable
Class for handling a tree structure used for
classification.
- Version:
- $Revision: 1.12 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
ClassifierTree(ModelSelection)
- Constructor.
assignIDs(int)
- Assigns a uniqe id to every node in the tree.
buildClassifier(Instances)
- Method for building a classifier tree.
buildTree(Instances, boolean)
- Builds the tree structure.
buildTree(Instances, Instances, boolean)
- Builds the tree structure with hold out set
classifyInstance(Instance)
- Classifies an instance.
cleanup(Instances)
- Cleanup in order to save memory.
distributionForInstance(Instance, boolean)
- Returns class probabilities for a weighted instance.
graph()
- Returns graph describing the tree.
numLeaves()
- Returns number of leaves in tree structure.
numNodes()
- Returns number of nodes in tree structure.
prefix()
- Returns tree in prefix order.
toSource(String)
- Returns source code for the tree as an if-then statement.
toString()
- Prints tree structure.
ClassifierTree
public ClassifierTree(ModelSelection toSelectLocModel)
Constructor.
buildClassifier
public void buildClassifier(Instances data) throws java.lang.Exception
Method for building a classifier tree.
- Throws:
- java.lang.Exception - if something goes wrong
buildTree
public void buildTree(Instances data,
boolean keepData) throws java.lang.Exception
Builds the tree structure.
- Parameters:
data
- the data for which the tree structure is to be
generated.
keepData
- is training data to be kept?
- Throws:
- java.lang.Exception - if something goes wrong
buildTree
public void buildTree(Instances train,
Instances test,
boolean keepData) throws java.lang.Exception
Builds the tree structure with hold out set
- Parameters:
train
- the data for which the tree structure is to be
generated.
test
- the test data for potential pruning
keepData
- is training Data to be kept?
- Throws:
- java.lang.Exception - if something goes wrong
classifyInstance
public double classifyInstance(Instance instance) throws java.lang.Exception
Classifies an instance.
- Throws:
- java.lang.Exception - if something goes wrong
cleanup
public final void cleanup(Instances justHeaderInfo)
Cleanup in order to save memory.
distributionForInstance
public final double[] distributionForInstance(Instance instance,
boolean useLaplace) throws java.lang.Exception
Returns class probabilities for a weighted instance.
- Throws:
- java.lang.Exception - if something goes wrong
assignIDs
public int assignIDs(int lastID)
Assigns a uniqe id to every node in the tree.
graph
public java.lang.String graph() throws java.lang.Exception
Returns graph describing the tree.
- Throws:
- java.lang.Exception - if something goes wrong
prefix
public java.lang.String prefix() throws java.lang.Exception
Returns tree in prefix order.
- Throws:
- java.lang.Exception - if something goes wrong
toSource
public java.lang.StringBuffer[] toSource(java.lang.String className) throws java.lang.Exception
Returns source code for the tree as an if-then statement. The
class is assigned to variable "p", and assumes the tested
instance is named "i". The results are returned as two stringbuffers:
a section of code for assignment of the class, and a section of
code containing support code (eg: other support methods).
- Parameters:
className
- the classname that this static classifier has
- Returns:
- an array containing two stringbuffers, the first string containing
assignment code, and the second containing source for support code.
- Throws:
- java.lang.Exception - if something goes wrong
numLeaves
public int numLeaves()
Returns number of leaves in tree structure.
numNodes
public int numNodes()
Returns number of nodes in tree structure.
toString
public java.lang.String toString()
Prints tree structure.
- Overrides:
- toString in class java.lang.Object
All Packages Class Hierarchy This Package Previous Next Index WEKA's home