Package weka.classifiers.trees.j48
Class ClassifierTree
java.lang.Object
weka.classifiers.trees.j48.ClassifierTree
- All Implemented Interfaces:
Serializable
,CapabilitiesHandler
,Drawable
,RevisionHandler
- Direct Known Subclasses:
C45PruneableClassifierTree
,NBTreeClassifierTree
,PruneableClassifierTree
public class ClassifierTree
extends Object
implements Drawable, Serializable, RevisionHandler, CapabilitiesHandler
Class for handling a tree structure used for classification.
- Version:
- $Revision: 15122 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
- See Also:
-
Field Summary
Fields inherited from interface weka.core.Drawable
BayesNet, Newick, NOT_DRAWABLE, TREE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
assignIDs
(int lastID) Assigns a uniqe id to every node in the tree.void
buildClassifier
(Instances data) Method for building a classifier tree.void
Builds the tree structure.void
Builds the tree structure with hold out setdouble
classifyInstance
(Instance instance) Classifies an instance.final void
Cleanup in order to save memory.double[]
distributionForInstance
(Instance instance, boolean useLaplace) Returns class probabilities for a weighted instance.Returns default capabilities of the classifier tree.double[]
getMembershipValues
(Instance instance) Computes a list that indicates node membershipReturns the revision string.getSons()
graph()
Returns graph describing the tree.int
Returns the type of graph this classifier represents.boolean
isLeaf()
int
Returns number of leaves in tree structure.int
numNodes()
Returns number of nodes in tree structure.prefix()
Returns tree in prefix order.Returns source code for the tree as an if-then statement.toString()
Prints tree structure.
-
Constructor Details
-
ClassifierTree
Constructor.
-
-
Method Details
-
getLocalModel
-
getSons
-
isLeaf
public boolean isLeaf() -
getTrainingData
-
getCapabilities
Returns default capabilities of the classifier tree.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Returns:
- the capabilities of this classifier tree
- See Also:
-
buildClassifier
Method for building a classifier tree.- Parameters:
data
- the data to build the tree from- Throws:
Exception
- if something goes wrong
-
buildTree
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:
Exception
- if something goes wrong
-
buildTree
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 pruningkeepData
- is training Data to be kept?- Throws:
Exception
- if something goes wrong
-
classifyInstance
Classifies an instance.- Parameters:
instance
- the instance to classify- Returns:
- the classification
- Throws:
Exception
- if something goes wrong
-
cleanup
Cleanup in order to save memory.- Parameters:
justHeaderInfo
-
-
distributionForInstance
Returns class probabilities for a weighted instance.- Parameters:
instance
- the instance to get the distribution foruseLaplace
- whether to use laplace or not- Returns:
- the distribution
- Throws:
Exception
- if something goes wrong
-
assignIDs
public int assignIDs(int lastID) Assigns a uniqe id to every node in the tree.- Parameters:
lastID
- the last ID that was assign- Returns:
- the new current ID
-
graphType
public int graphType()Returns the type of graph this classifier represents. -
graph
Returns graph describing the tree. -
prefix
Returns tree in prefix order.- Returns:
- the prefix order
- Throws:
Exception
- if something goes wrong
-
toSource
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:
Exception
- if something goes wrong
-
numLeaves
public int numLeaves()Returns number of leaves in tree structure.- Returns:
- the number of leaves
-
numNodes
public int numNodes()Returns number of nodes in tree structure.- Returns:
- the number of nodes
-
toString
Prints tree structure. -
getMembershipValues
Computes a list that indicates node membership- Throws:
Exception
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-