public class ADTree extends Classifier implements OptionHandler, Drawable, AdditionalMeasureProducer, WeightedInstancesHandler, IterativeClassifier, TechnicalInformationHandler
@inproceedings{Freund1999,
address = {Bled, Slovenia},
author = {Freund, Y. and Mason, L.},
booktitle = {Proceeding of the Sixteenth International Conference on Machine Learning},
pages = {124-133},
title = {The alternating decision tree learning algorithm},
year = {1999}
}
Valid options are:
-B <number of boosting iterations> Number of boosting iterations. (Default = 10)
-E <-3|-2|-1|>=0> Expand nodes: -3(all), -2(weight), -1(z_pure), >=0 seed for random walk (Default = -3)
-D Save the instance data with the model
| Modifier and Type | Field and Description |
|---|---|
protected int |
m_boostingIterations
Option - the number of boosting iterations o perform
|
protected int |
m_examplesCounted
Statistics - the number of instances processed during search
|
protected int |
m_lastAddedSplitNum
The number of the last splitter added to the tree
|
protected ReferenceInstances |
m_negTrainInstances
The training instances with negative class - referencing the training dataset
|
protected int |
m_nodesExpanded
Statistics - the number of prediction nodes investigated during search
|
protected int[] |
m_nominalAttIndices
An array containing the inidices to the nominal attributes in the data
|
protected int[] |
m_numericAttIndices
An array containing the inidices to the numeric attributes in the data
|
protected ReferenceInstances |
m_posTrainInstances
The training instances with positive class - referencing the training dataset
|
protected Random |
m_random
The random number generator - used for the random search heuristic
|
protected int |
m_randomSeed
Option - the seed to use for a random search
|
protected PredictionNode |
m_root
The root of the tree
|
protected boolean |
m_saveInstanceData
Option - whether the tree should remember the instance data
|
protected PredictionNode |
m_search_bestInsertionNode
The best node to insert under, as found so far by the latest search
|
protected Instances |
m_search_bestPathNegInstances
The negative instances that apply to the best path found so far
|
protected Instances |
m_search_bestPathPosInstances
The positive instances that apply to the best path found so far
|
protected Splitter |
m_search_bestSplitter
The best splitter to insert, as found so far by the latest search
|
protected double |
m_search_smallestZ
The smallest Z value found so far by the latest search
|
protected int |
m_searchPath
Option - the search mode
|
protected Instances |
m_trainInstances
The instances used to train the tree
|
protected double |
m_trainTotalWeight
The total weight of the instances - used to speed Z calculations
|
static int |
SEARCHPATH_ALL
search mode: Expand all paths
|
static int |
SEARCHPATH_HEAVIEST
search mode: Expand the heaviest path
|
static int |
SEARCHPATH_RANDOM
search mode: Expand a random path
|
static int |
SEARCHPATH_ZPURE
search mode: Expand the best z-pure path
|
static Tag[] |
TAGS_SEARCHPATH
The search modes
|
m_DebugBayesNet, Newick, NOT_DRAWABLE, TREE| Constructor and Description |
|---|
ADTree() |
| Modifier and Type | Method and Description |
|---|---|
void |
boost()
Performs a single boosting iteration, using two-class optimized method.
|
void |
buildClassifier(Instances instances)
Builds a classifier for a set of instances.
|
Object |
clone()
Creates a clone that is identical to the current tree, but is independent.
|
double[] |
distributionForInstance(Instance instance)
Returns the class probability distribution for an instance.
|
void |
done()
Frees memory that is no longer needed for a final model - will no longer be able
to increment the classifier after calling this.
|
Enumeration |
enumerateMeasures()
Returns an enumeration of the additional measure names.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
double |
getMeasure(String additionalMeasureName)
Returns the value of the named measure.
|
int |
getNumOfBoostingIterations()
Gets the number of boosting iterations.
|
String[] |
getOptions()
Gets the current settings of ADTree.
|
protected int |
getRandom(int max)
Gets the next random value.
|
int |
getRandomSeed()
Gets random seed for a random walk.
|
String |
getRevision()
Returns the revision string.
|
boolean |
getSaveInstanceData()
Gets whether the tree is to save instance data.
|
SelectedTag |
getSearchPath()
Gets the method of searching the tree for a new insertion.
|
TechnicalInformation |
getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing
detailed information about the technical background of this class,
e.g., paper reference or book this class is based on.
|
String |
globalInfo()
Returns a string describing classifier
|
String |
graph()
Returns graph describing the tree.
|
protected void |
graphTraverse(PredictionNode currentNode,
StringBuffer text,
int splitOrder,
int predOrder,
Instances instances)
Traverses the tree, graphing each node.
|
int |
graphType()
Returns the type of graph this classifier
represents.
|
void |
initClassifier(Instances instances)
Sets up the tree ready to be trained, using two-class optimized method.
|
String |
legend()
Returns the legend of the tree, describing how results are to be interpreted.
|
Enumeration |
listOptions()
Returns an enumeration describing the available options..
|
static void |
main(String[] argv)
Main method for testing this class.
|
double |
measureExamplesProcessed()
Returns the number of examples "counted".
|
double |
measureNodesExpanded()
Returns the number of nodes expanded.
|
double |
measureNumLeaves()
Calls measure function for leaf size - the number of prediction nodes.
|
double |
measureNumPredictionLeaves()
Calls measure function for prediction leaf size - the number of
prediction nodes without children.
|
double |
measureTreeSize()
Calls measure function for tree size - the total number of nodes.
|
void |
merge(ADTree mergeWith)
Merges two trees together.
|
void |
next(int iteration)
Performs one iteration.
|
int |
nextSplitAddedOrder()
Returns the next number in the order that splitter nodes have been added to
the tree, and records that a new splitter has been added.
|
protected int |
numOfAllNodes(PredictionNode root)
Returns the total number of nodes in a tree.
|
String |
numOfBoostingIterationsTipText() |
protected int |
numOfPredictionLeafNodes(PredictionNode root)
Returns the number of leaf nodes in a tree - prediction nodes without
children.
|
protected int |
numOfPredictionNodes(PredictionNode root)
Returns the number of prediction nodes in a tree.
|
protected double |
predictionValueForInstance(Instance inst,
PredictionNode currentNode,
double currentValue)
Returns the class prediction value (vote) for an instance.
|
String |
randomSeedTipText() |
String |
saveInstanceDataTipText() |
String |
searchPathTipText() |
void |
setNumOfBoostingIterations(int b)
Sets the number of boosting iterations.
|
void |
setOptions(String[] options)
Parses a given list of options.
|
void |
setRandomSeed(int seed)
Sets random seed for a random walk.
|
void |
setSaveInstanceData(boolean v)
Sets whether the tree is to save instance data.
|
void |
setSearchPath(SelectedTag newMethod)
Sets the method of searching the tree for a new insertion.
|
String |
toString()
Returns a description of the classifier.
|
protected String |
toString(PredictionNode currentNode,
int level)
Traverses the tree, forming a string that describes it.
|
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebugpublic static final int SEARCHPATH_ALL
public static final int SEARCHPATH_HEAVIEST
public static final int SEARCHPATH_ZPURE
public static final int SEARCHPATH_RANDOM
public static final Tag[] TAGS_SEARCHPATH
protected Instances m_trainInstances
protected PredictionNode m_root
protected Random m_random
protected int m_lastAddedSplitNum
protected int[] m_numericAttIndices
protected int[] m_nominalAttIndices
protected double m_trainTotalWeight
protected ReferenceInstances m_posTrainInstances
protected ReferenceInstances m_negTrainInstances
protected PredictionNode m_search_bestInsertionNode
protected Splitter m_search_bestSplitter
protected double m_search_smallestZ
protected Instances m_search_bestPathPosInstances
protected Instances m_search_bestPathNegInstances
protected int m_nodesExpanded
protected int m_examplesCounted
protected int m_boostingIterations
protected int m_searchPath
protected int m_randomSeed
protected boolean m_saveInstanceData
public String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation in interface TechnicalInformationHandlerpublic void initClassifier(Instances instances) throws Exception
initClassifier in interface IterativeClassifierinstances - the instances to train the tree withException - if training data is unsuitablepublic void next(int iteration)
throws Exception
next in interface IterativeClassifieriteration - the index of the current iteration (0-based)Exception - if this iteration failspublic void boost()
throws Exception
Exception - if try to boost without setting up tree first or there are no
instances to train withpublic double[] distributionForInstance(Instance instance)
distributionForInstance in class Classifierinstance - the instance to be classifiedprotected double predictionValueForInstance(Instance inst, PredictionNode currentNode, double currentValue)
inst - the instancecurrentNode - the root of the tree to get the values fromcurrentValue - the current value before adding the value contained in the
subtreepublic String toString()
protected String toString(PredictionNode currentNode, int level)
currentNode - the current node under investigationlevel - the current level in the treepublic int graphType()
protected void graphTraverse(PredictionNode currentNode, StringBuffer text, int splitOrder, int predOrder, Instances instances) throws Exception
currentNode - the currentNode under investigationtext - the string built so farsplitOrder - the order the parent splitter was added to the treepredOrder - the order this predictor was added to the splitinstances - the data to work onException - if something goes wrongpublic String legend()
public String numOfBoostingIterationsTipText()
public int getNumOfBoostingIterations()
public void setNumOfBoostingIterations(int b)
b - the number of boosting iterations to usepublic String searchPathTipText()
public SelectedTag getSearchPath()
public void setSearchPath(SelectedTag newMethod)
newMethod - the new tree searching modepublic String randomSeedTipText()
public int getRandomSeed()
public void setRandomSeed(int seed)
seed - the random seedpublic String saveInstanceDataTipText()
public boolean getSaveInstanceData()
public void setSaveInstanceData(boolean v)
v - true then the tree saves instance datapublic Enumeration listOptions()
listOptions in interface OptionHandlerlistOptions in class Classifierpublic void setOptions(String[] options) throws Exception
-B num
Set the number of boosting iterations
(default 10)
-E num
Set the nodes to expand: -3(all), -2(weight), -1(z_pure), >=0 seed for random walk
(default -3)
-D
Save the instance data with the model
setOptions in interface OptionHandlersetOptions in class Classifieroptions - the list of options as an array of stringsException - if an option is not supportedpublic String[] getOptions()
getOptions in interface OptionHandlergetOptions in class Classifierpublic double measureTreeSize()
public double measureNumLeaves()
public double measureNumPredictionLeaves()
public double measureNodesExpanded()
public double measureExamplesProcessed()
public Enumeration enumerateMeasures()
enumerateMeasures in interface AdditionalMeasureProducerpublic double getMeasure(String additionalMeasureName)
getMeasure in interface AdditionalMeasureProduceradditionalMeasureName - the name of the measure to query for its valueIllegalArgumentException - if the named measure is not supportedprotected int numOfAllNodes(PredictionNode root)
root - the root of the tree being measuredprotected int numOfPredictionNodes(PredictionNode root)
root - the root of the tree being measuredprotected int numOfPredictionLeafNodes(PredictionNode root)
root - the root of the tree being measuredprotected int getRandom(int max)
max - the maximum value (+1) to be returnedpublic int nextSplitAddedOrder()
public Capabilities getCapabilities()
getCapabilities in interface CapabilitiesHandlergetCapabilities in class ClassifierCapabilitiespublic void buildClassifier(Instances instances) throws Exception
buildClassifier in class Classifierinstances - the instances to train the classifier withException - if something goes wrongpublic void done()
done in interface IterativeClassifierpublic Object clone()
clone in interface IterativeClassifierclone in class Objectpublic void merge(ADTree mergeWith) throws Exception
mergeWith - the tree to merge withException - if merge could not be performedpublic String getRevision()
getRevision in interface RevisionHandlergetRevision in class Classifierpublic static void main(String[] argv)
argv - the optionsCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.