|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.trees.j48.ClassifierTree
Class for handling a tree structure used for classification.
Field Summary | |
protected int |
m_id
The id for the node. |
protected boolean |
m_isEmpty
True if node is empty. |
protected boolean |
m_isLeaf
True if node is leaf. |
protected ClassifierSplitModel |
m_localModel
Local model at node. |
protected ClassifierTree[] |
m_sons
References to sons. |
protected Distribution |
m_test
The pruning instances. |
protected ModelSelection |
m_toSelectModel
The model selection method. |
protected Instances |
m_train
The training instances. |
private static long |
PRINTED_NODES
For getting a unique ID when outputting the tree (hashcode isn't guaranteed unique) |
Fields inherited from interface weka.core.Drawable |
BayesNet, NOT_DRAWABLE, TREE |
Constructor Summary | |
ClassifierTree(ModelSelection toSelectLocModel)
Constructor. |
Method Summary | |
int |
assignIDs(int lastID)
Assigns a uniqe id to every node in the tree. |
void |
buildClassifier(Instances data)
Method for building a classifier tree. |
void |
buildTree(Instances data,
boolean keepData)
Builds the tree structure. |
void |
buildTree(Instances train,
Instances test,
boolean keepData)
Builds the tree structure with hold out set |
double |
classifyInstance(Instance instance)
Classifies an instance. |
void |
cleanup(Instances justHeaderInfo)
Cleanup in order to save memory. |
double[] |
distributionForInstance(Instance instance,
boolean useLaplace)
Returns class probabilities for a weighted instance. |
private void |
dumpTree(int depth,
java.lang.StringBuffer text)
Help method for printing tree structure. |
protected ClassifierTree |
getNewTree(Instances data)
Returns a newly created tree. |
protected ClassifierTree |
getNewTree(Instances train,
Instances test)
Returns a newly created tree. |
private double |
getProbs(int classIndex,
Instance instance,
double weight)
Help method for computing class probabilities of a given instance. |
private double |
getProbsLaplace(int classIndex,
Instance instance,
double weight)
Help method for computing class probabilities of a given instance. |
java.lang.String |
graph()
Returns graph describing the tree. |
private void |
graphTree(java.lang.StringBuffer text)
Help method for printing tree structure as a graph. |
int |
graphType()
Returns the type of graph this classifier represents. |
private ClassifierSplitModel |
localModel()
Method just exists to make program easier to read. |
protected static long |
nextID()
Gets the next unique node ID. |
int |
numLeaves()
Returns number of leaves in tree structure. |
int |
numNodes()
Returns number of nodes in tree structure. |
java.lang.String |
prefix()
Returns tree in prefix order. |
private void |
prefixTree(java.lang.StringBuffer text)
Prints the tree in prefix form |
protected static void |
resetID()
Resets the unique node ID counter (e.g. |
private ClassifierTree |
son(int index)
Method just exists to make program easier to read. |
java.lang.StringBuffer[] |
toSource(java.lang.String className)
Returns source code for the tree as an if-then statement. |
java.lang.String |
toString()
Prints tree structure. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected ModelSelection m_toSelectModel
protected ClassifierSplitModel m_localModel
protected ClassifierTree[] m_sons
protected boolean m_isLeaf
protected boolean m_isEmpty
protected Instances m_train
protected Distribution m_test
protected int m_id
private static long PRINTED_NODES
Constructor Detail |
public ClassifierTree(ModelSelection toSelectLocModel)
Method Detail |
protected static long nextID()
protected static void resetID()
public void buildClassifier(Instances data) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic void buildTree(Instances data, boolean keepData) throws java.lang.Exception
data
- the data for which the tree structure is to be
generated.keepData
- is training data to be kept?
java.lang.Exception
- if something goes wrongpublic void buildTree(Instances train, Instances test, boolean keepData) throws java.lang.Exception
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?
java.lang.Exception
- if something goes wrongpublic double classifyInstance(Instance instance) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final void cleanup(Instances justHeaderInfo)
public final double[] distributionForInstance(Instance instance, boolean useLaplace) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic int assignIDs(int lastID)
public int graphType()
graphType
in interface Drawable
public java.lang.String graph() throws java.lang.Exception
graph
in interface Drawable
java.lang.Exception
- if something goes wrongpublic java.lang.String prefix() throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic java.lang.StringBuffer[] toSource(java.lang.String className) throws java.lang.Exception
className
- the classname that this static classifier has
java.lang.Exception
- if something goes wrongpublic int numLeaves()
public int numNodes()
public java.lang.String toString()
protected ClassifierTree getNewTree(Instances data) throws java.lang.Exception
data
- the training data
java.lang.Exception
- if something goes wrongprotected ClassifierTree getNewTree(Instances train, Instances test) throws java.lang.Exception
test
- the pruning data.
java.lang.Exception
- if something goes wrongprivate void dumpTree(int depth, java.lang.StringBuffer text) throws java.lang.Exception
java.lang.Exception
- if something goes wrongprivate void graphTree(java.lang.StringBuffer text) throws java.lang.Exception
java.lang.Exception
- if something goes wrongprivate void prefixTree(java.lang.StringBuffer text) throws java.lang.Exception
java.lang.Exception
private double getProbsLaplace(int classIndex, Instance instance, double weight) throws java.lang.Exception
java.lang.Exception
- if something goes wrongprivate double getProbs(int classIndex, Instance instance, double weight) throws java.lang.Exception
java.lang.Exception
- if something goes wrongprivate ClassifierSplitModel localModel()
private ClassifierTree son(int index)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |