Package weka.classifiers.trees
Class REPTree
java.lang.Object
weka.classifiers.AbstractClassifier
weka.classifiers.trees.REPTree
- All Implemented Interfaces:
Serializable,Cloneable,Classifier,Sourcable,AdditionalMeasureProducer,BatchPredictor,CapabilitiesHandler,CapabilitiesIgnorer,CommandlineRunnable,Drawable,OptionHandler,PartitionGenerator,Randomizable,RevisionHandler,WeightedInstancesHandler
public class REPTree
extends AbstractClassifier
implements OptionHandler, WeightedInstancesHandler, Drawable, AdditionalMeasureProducer, Sourcable, PartitionGenerator, Randomizable
Fast decision tree learner. Builds a
decision/regression tree using information gain/variance and prunes it using
reduced-error pruning (with backfitting). Only sorts values for numeric
attributes once. Missing values are dealt with by splitting the corresponding
instances into pieces (i.e. as in C4.5).
Valid options are:
-M <minimum number of instances> Set minimum number of instances per leaf (default 2).
-V <minimum variance for split> Set minimum numeric class variance proportion of train variance for split (default 1e-3).
-N <number of folds> Number of folds for reduced error pruning (default 3).
-S <seed> Seed for random data shuffling (default 1).
-P No pruning.
-L Maximum tree depth (default -1, no maximum)
- Version:
- $Revision: 15520 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
- See Also:
-
Field Summary
Fields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULTFields inherited from interface weka.core.Drawable
BayesNet, Newick, NOT_DRAWABLE, TREE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildClassifier(Instances data) Builds classifier.double[]distributionForInstance(Instance instance) Computes class distribution of an instance using the tree.Returns an enumeration of the additional measure names.voidgeneratePartition(Instances data) Builds the classifier to generate a partition.Returns default capabilities of the classifier.doubleGet the value of InitialCount.intGet the value of MaxDepth.doublegetMeasure(String additionalMeasureName) Returns the value of the named measure.double[]getMembershipValues(Instance instance) Computes array that indicates node membership.doubleGet the value of MinNum.doubleGet the value of MinVarianceProp.booleanGet the value of NoPruning.intGet the value of NumFolds.String[]Gets options from this classifier.Returns the revision string.intgetSeed()Get the value of Seed.booleanGet the value of SpreadInitialCount.Returns a string describing classifiergraph()Outputs the decision tree as a graphintReturns the type of graph this classifier represents.Returns the tip text for this propertyLists the command-line options for this classifier.static voidMain method for this class.Returns the tip text for this propertyReturns the tip text for this propertyReturns the tip text for this propertyReturns the tip text for this propertyintReturns the number of elements in the partition.Returns the tip text for this propertyintnumNodes()Computes size of the tree.Returns the tip text for this propertyvoidsetInitialCount(double newInitialCount) Set the value of InitialCount.voidsetMaxDepth(int newMaxDepth) Set the value of MaxDepth.voidsetMinNum(double newMinNum) Set the value of MinNum.voidsetMinVarianceProp(double newMinVarianceProp) Set the value of MinVarianceProp.voidsetNoPruning(boolean newNoPruning) Set the value of NoPruning.voidsetNumFolds(int newNumFolds) Set the value of NumFolds.voidsetOptions(String[] options) Parses a given list of options.voidsetSeed(int newSeed) Set the value of Seed.voidsetSpreadInitialCount(boolean newSpreadInitialCount) Set the value of SpreadInitialCount.Returns the tip text for this propertyReturns the tree as if-then statements.toString()Outputs the decision tree.Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
Constructor Details
-
REPTree
public REPTree()
-
-
Method Details
-
globalInfo
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
noPruningTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNoPruning
public boolean getNoPruning()Get the value of NoPruning.- Returns:
- Value of NoPruning.
-
setNoPruning
public void setNoPruning(boolean newNoPruning) Set the value of NoPruning.- Parameters:
newNoPruning- Value to assign to NoPruning.
-
minNumTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getMinNum
public double getMinNum()Get the value of MinNum.- Returns:
- Value of MinNum.
-
setMinNum
public void setMinNum(double newMinNum) Set the value of MinNum.- Parameters:
newMinNum- Value to assign to MinNum.
-
minVariancePropTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getMinVarianceProp
public double getMinVarianceProp()Get the value of MinVarianceProp.- Returns:
- Value of MinVarianceProp.
-
setMinVarianceProp
public void setMinVarianceProp(double newMinVarianceProp) Set the value of MinVarianceProp.- Parameters:
newMinVarianceProp- Value to assign to MinVarianceProp.
-
seedTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getSeed
public int getSeed()Get the value of Seed.- Specified by:
getSeedin interfaceRandomizable- Returns:
- Value of Seed.
-
setSeed
public void setSeed(int newSeed) Set the value of Seed.- Specified by:
setSeedin interfaceRandomizable- Parameters:
newSeed- Value to assign to Seed.
-
numFoldsTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNumFolds
public int getNumFolds()Get the value of NumFolds.- Returns:
- Value of NumFolds.
-
setNumFolds
public void setNumFolds(int newNumFolds) Set the value of NumFolds.- Parameters:
newNumFolds- Value to assign to NumFolds.
-
maxDepthTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getMaxDepth
public int getMaxDepth()Get the value of MaxDepth.- Returns:
- Value of MaxDepth.
-
setMaxDepth
public void setMaxDepth(int newMaxDepth) Set the value of MaxDepth.- Parameters:
newMaxDepth- Value to assign to MaxDepth.
-
initialCountTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getInitialCount
public double getInitialCount()Get the value of InitialCount.- Returns:
- Value of InitialCount.
-
setInitialCount
public void setInitialCount(double newInitialCount) Set the value of InitialCount.- Parameters:
newInitialCount- Value to assign to InitialCount.
-
spreadInitialCountTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getSpreadInitialCount
public boolean getSpreadInitialCount()Get the value of SpreadInitialCount.- Returns:
- Value of SpreadInitialCount.
-
setSpreadInitialCount
public void setSpreadInitialCount(boolean newSpreadInitialCount) Set the value of SpreadInitialCount.- Parameters:
newSpreadInitialCount- Value to assign to SpreadInitialCount.
-
listOptions
Lists the command-line options for this classifier.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classAbstractClassifier- Returns:
- an enumeration over all commandline options
-
getOptions
Gets options from this classifier.- Specified by:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classAbstractClassifier- Returns:
- the options for the current setup
-
setOptions
Parses a given list of options. Valid options are:-M <minimum number of instances> Set minimum number of instances per leaf (default 2).
-V <minimum variance for split> Set minimum numeric class variance proportion of train variance for split (default 1e-3).
-N <number of folds> Number of folds for reduced error pruning (default 3).
-S <seed> Seed for random data shuffling (default 1).
-P No pruning.
-L Maximum tree depth (default -1, no maximum)
- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classAbstractClassifier- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
numNodes
public int numNodes()Computes size of the tree.- Returns:
- the number of nodes
-
enumerateMeasures
Returns an enumeration of the additional measure names.- Specified by:
enumerateMeasuresin interfaceAdditionalMeasureProducer- Returns:
- an enumeration of the measure names
-
getMeasure
Returns the value of the named measure.- Specified by:
getMeasurein interfaceAdditionalMeasureProducer- Parameters:
additionalMeasureName- the name of the measure to query for its value- Returns:
- the value of the named measure
- Throws:
IllegalArgumentException- if the named measure is not supported
-
getCapabilities
Returns default capabilities of the classifier.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Specified by:
getCapabilitiesin interfaceClassifier- Overrides:
getCapabilitiesin classAbstractClassifier- Returns:
- the capabilities of this classifier
- See Also:
-
buildClassifier
Builds classifier.- Specified by:
buildClassifierin interfaceClassifier- Parameters:
data- the data to train with- Throws:
Exception- if building fails
-
distributionForInstance
Computes class distribution of an instance using the tree.- Specified by:
distributionForInstancein interfaceClassifier- Overrides:
distributionForInstancein classAbstractClassifier- Parameters:
instance- the instance to compute the distribution for- Returns:
- the computed class probabilities
- Throws:
Exception- if computation fails
-
toSource
Returns the tree as if-then statements. -
graphType
public int graphType()Returns the type of graph this classifier represents. -
graph
Outputs the decision tree as a graph -
toString
Outputs the decision tree. -
generatePartition
Builds the classifier to generate a partition.- Specified by:
generatePartitionin interfacePartitionGenerator- Throws:
Exception
-
getMembershipValues
Computes array that indicates node membership. Array locations are allocated based on breadth-first exploration of the tree.- Specified by:
getMembershipValuesin interfacePartitionGenerator- Throws:
Exception
-
numElements
Returns the number of elements in the partition.- Specified by:
numElementsin interfacePartitionGenerator- Throws:
Exception
-
getRevision
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classAbstractClassifier- Returns:
- the revision
-
main
Main method for this class.- Parameters:
argv- the commandline options
-