All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.adtree.ADTree

java.lang.Object
    |
    +----weka.classifiers.Classifier
            |
            +----weka.classifiers.DistributionClassifier
                    |
                    +----weka.classifiers.adtree.ADTree

public class ADTree
extends DistributionClassifier
implements OptionHandler, Drawable, AdditionalMeasureProducer, WeightedInstancesHandler, IterativeClassifier
Class for generating an alternating decision tree. The basic algorithm is based on:

Freund, Y., Mason, L.: The alternating decision tree learning algorithm. Proceeding of the Sixteenth International Conference on Machine Learning, Bled, Slovenia, (1999) 124-133.

This version currently only supports two-class problems. The number of boosting iterations needs to be manually tuned to suit the dataset and the desired complexity/accuracy tradeoff. Induction of the trees has been optimized, and heuristic search methods have been introduced to speed learning.

Valid options are:

-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

Version:
$Revision: 1.1.2.2 $
Author:
Richard Kirkby (rkirkby@cs.waikato.ac.nz)
Author:
Bernhard Pfahringer (bernhard@cs.waikato.ac.nz)

Variable Index

 o SEARCHPATH_ALL
The search modes
 o SEARCHPATH_HEAVIEST
 
 o SEARCHPATH_RANDOM
 
 o SEARCHPATH_ZPURE
 
 o TAGS_SEARCHPATH
 

Constructor Index

 o ADTree()
 

Method Index

 o boost()
Performs a single boosting iteration, using two-class optimized method.
 o buildClassifier(Instances)
Builds a classifier for a set of instances.
 o clone()
Creates a clone that is identical to the current tree, but is independent.
 o distributionForInstance(Instance)
Returns the class probability distribution for an instance.
 o done()
Frees memory that is no longer needed for a final model - will no longer be able to increment the classifier after calling this.
 o enumerateMeasures()
Returns an enumeration of the additional measure names.
 o getMeasure(String)
Returns the value of the named measure.
 o getNumOfBoostingIterations()
Gets the number of boosting iterations.
 o getOptions()
Gets the current settings of ADTree.
 o getRandomSeed()
Gets random seed for a random walk.
 o getSaveInstanceData()
Gets whether the tree is to save instance data.
 o getSearchPath()
Gets the method of searching the tree for a new insertion.
 o globalInfo()
 
 o graph()
Returns graph describing the tree.
 o initClassifier(Instances)
Sets up the tree ready to be trained, using two-class optimized method.
 o legend()
Returns the legend of the tree, describing how results are to be interpreted.
 o listOptions()
Returns an enumeration describing the available options.
 o main(String[])
Main method for testing this class.
 o measureExamplesProcessed()
Returns the number of examples "counted".
 o measureNodesExpanded()
Returns the number of nodes expanded.
 o measureNumLeaves()
Calls measure function for leaf size - the number of prediction nodes.
 o measureNumPredictionLeaves()
Calls measure function for prediction leaf size - the number of prediction nodes without children.
 o measureTreeSize()
Calls measure function for tree size - the total number of nodes.
 o merge(ADTree)
Merges two trees together.
 o next(int)
Performs one iteration.
 o 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.
 o numOfBoostingIterationsTipText()
 
 o randomSeedTipText()
 
 o saveInstanceDataTipText()
 
 o searchPathTipText()
 
 o setNumOfBoostingIterations(int)
Sets the number of boosting iterations.
 o setOptions(String[])
Parses a given list of options.
 o setRandomSeed(int)
Sets random seed for a random walk.
 o setSaveInstanceData(boolean)
Sets whether the tree is to save instance data.
 o setSearchPath(SelectedTag)
Sets the method of searching the tree for a new insertion.
 o toString()
Returns a description of the classifier.

Field Detail

 o SEARCHPATH_ALL
public static final int SEARCHPATH_ALL
          The search modes
 o SEARCHPATH_HEAVIEST
public static final int SEARCHPATH_HEAVIEST
 o SEARCHPATH_ZPURE
public static final int SEARCHPATH_ZPURE
 o SEARCHPATH_RANDOM
public static final int SEARCHPATH_RANDOM
 o TAGS_SEARCHPATH
public static final Tag[] TAGS_SEARCHPATH

Constructor Detail

 o ADTree
public ADTree()

Method Detail

 o initClassifier
public void initClassifier(Instances instances) throws java.lang.Exception
          Sets up the tree ready to be trained, using two-class optimized method.
Parameters:
instances - the instances to train the tree with
Throws:
java.lang.Exception - if training data is unsuitable
 o next
public void next(int iteration) throws java.lang.Exception
          Performs one iteration.
Parameters:
iteration - the index of the current iteration (0-based)
Throws:
java.lang.Exception - if this iteration fails
 o boost
public void boost() throws java.lang.Exception
          Performs a single boosting iteration, using two-class optimized method. Will add a new splitter node and two prediction nodes to the tree (unless merging takes place).
Throws:
java.lang.Exception - if try to boost without setting up tree first or there are no instances to train with
 o distributionForInstance
public double[] distributionForInstance(Instance instance)
          Returns the class probability distribution for an instance.
Parameters:
instance - the instance to be classified
Returns:
the distribution the tree generates for the instance
Overrides:
distributionForInstance in class DistributionClassifier
 o toString
public java.lang.String toString()
          Returns a description of the classifier.
Returns:
a string containing a description of the classifier
Overrides:
toString in class java.lang.Object
 o graph
public java.lang.String graph() throws java.lang.Exception
          Returns graph describing the tree.
Returns:
the graph of the tree in dotty format
Throws:
java.lang.Exception - if something goes wrong
 o legend
public java.lang.String legend()
          Returns the legend of the tree, describing how results are to be interpreted.
Returns:
a string containing the legend of the classifier
 o globalInfo
public java.lang.String globalInfo()
Returns:
a description of the classifier suitable for displaying in the explorer/experimenter gui
 o numOfBoostingIterationsTipText
public java.lang.String numOfBoostingIterationsTipText()
Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui
 o getNumOfBoostingIterations
public int getNumOfBoostingIterations()
          Gets the number of boosting iterations.
Returns:
the number of boosting iterations
 o setNumOfBoostingIterations
public void setNumOfBoostingIterations(int b)
          Sets the number of boosting iterations.
Parameters:
b - the number of boosting iterations to use
 o searchPathTipText
public java.lang.String searchPathTipText()
Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui
 o getSearchPath
public SelectedTag getSearchPath()
          Gets the method of searching the tree for a new insertion. Will be one of SEARCHPATH_ALL, SEARCHPATH_HEAVIEST, SEARCHPATH_ZPURE, SEARCHPATH_RANDOM.
Returns:
the tree searching mode
 o setSearchPath
public void setSearchPath(SelectedTag newMethod)
          Sets the method of searching the tree for a new insertion. Will be one of SEARCHPATH_ALL, SEARCHPATH_HEAVIEST, SEARCHPATH_ZPURE, SEARCHPATH_RANDOM.
Parameters:
newMethod - the new tree searching mode
 o randomSeedTipText
public java.lang.String randomSeedTipText()
Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui
 o getRandomSeed
public int getRandomSeed()
          Gets random seed for a random walk.
Returns:
the random seed
 o setRandomSeed
public void setRandomSeed(int seed)
          Sets random seed for a random walk.
Parameters:
s - the random seed
 o saveInstanceDataTipText
public java.lang.String saveInstanceDataTipText()
Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui
 o getSaveInstanceData
public boolean getSaveInstanceData()
          Gets whether the tree is to save instance data.
Returns:
the random seed
 o setSaveInstanceData
public void setSaveInstanceData(boolean v)
          Sets whether the tree is to save instance data.
Parameters:
s - the random seed
 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
Returns:
an enumeration of all the available options
 o setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
          Parses a given list of options. Valid options are:

-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

Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of ADTree.
Returns:
an array of strings suitable for passing to setOptions()
 o measureTreeSize
public double measureTreeSize()
          Calls measure function for tree size - the total number of nodes.
Returns:
the tree size
 o measureNumLeaves
public double measureNumLeaves()
          Calls measure function for leaf size - the number of prediction nodes.
Returns:
the leaf size
 o measureNumPredictionLeaves
public double measureNumPredictionLeaves()
          Calls measure function for prediction leaf size - the number of prediction nodes without children.
Returns:
the leaf size
 o measureNodesExpanded
public double measureNodesExpanded()
          Returns the number of nodes expanded.
Returns:
the number of nodes expanded during search
 o measureExamplesProcessed
public double measureExamplesProcessed()
          Returns the number of examples "counted".
Returns:
the number of nodes processed during search
 o enumerateMeasures
public java.util.Enumeration enumerateMeasures()
          Returns an enumeration of the additional measure names.
Returns:
an enumeration of the measure names
 o getMeasure
public double getMeasure(java.lang.String additionalMeasureName)
          Returns the value of the named measure.
Parameters:
measureName - the name of the measure to query for its value
Returns:
the value of the named measure
Throws:
java.lang.IllegalArgumentException - if the named measure is not supported
 o nextSplitAddedOrder
public 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.
Returns:
the next number in the order
 o buildClassifier
public void buildClassifier(Instances instances) throws java.lang.Exception
          Builds a classifier for a set of instances.
Parameters:
instances - the instances to train the classifier with
Throws:
java.lang.Exception - if something goes wrong
Overrides:
buildClassifier in class Classifier
 o done
public 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.
 o clone
public java.lang.Object clone()
          Creates a clone that is identical to the current tree, but is independent. Deep copies the essential elements such as the tree nodes, and the instances (because the weights change.) Reference copies several elements such as the potential splitter sets, assuming that such elements should never differ between clones.
Returns:
the clone
 o merge
public void merge(ADTree mergeWith) throws java.lang.Exception
          Merges two trees together. Modifies the tree being acted on, leaving tree passed as a parameter untouched (cloned). Does not check to see whether training instances are compatible - strange things could occur if they are not.
Parameters:
mergeWith - the tree to merge with
Throws:
java.lang.Exception - if merge could not be performed
 o main
public static void main(java.lang.String argv[])
          Main method for testing this class.
Parameters:
argv - the options

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home