public class J48 extends AbstractClassifier implements OptionHandler, Drawable, Matchable, Sourcable, WeightedInstancesHandler, Summarizable, AdditionalMeasureProducer, TechnicalInformationHandler, PartitionGenerator
@book{Quinlan1993, address = {San Mateo, CA}, author = {Ross Quinlan}, publisher = {Morgan Kaufmann Publishers}, title = {C4.5: Programs for Machine Learning}, year = {1993} }Valid options are:
-U Use unpruned tree.
-O Do not collapse tree.
-C <pruning confidence> Set confidence threshold for pruning. (default 0.25)
-M <minimum number of instances> Set minimum number of instances per leaf. (default 2)
-R Use reduced error pruning.
-N <number of folds> Set number of folds for reduced error pruning. One fold is used as pruning set. (default 3)
-B Use binary splits only.
-S Don't perform subtree raising.
-L Do not clean up after the tree has been built.
-A Laplace smoothing for predicted probabilities.
-J Do not use MDL correction for info gain on numeric attributes.
-Q <seed> Seed for random data shuffling (default 1).
-doNotMakeSplitPointActualValue Do not make split point actual value.
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
BayesNet, Newick, NOT_DRAWABLE, TREE
Constructor and Description |
---|
J48() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
binarySplitsTipText()
Returns the tip text for this property
|
void |
buildClassifier(Instances instances)
Generates the classifier.
|
double |
classifyInstance(Instance instance)
Classifies an instance.
|
java.lang.String |
collapseTreeTipText()
Returns the tip text for this property
|
java.lang.String |
confidenceFactorTipText()
Returns the tip text for this property
|
double[] |
distributionForInstance(Instance instance)
Returns class probabilities for an instance.
|
java.lang.String |
doNotMakeSplitPointActualValueTipText()
Returns the tip text for this property
|
java.util.Enumeration<java.lang.String> |
enumerateMeasures()
Returns an enumeration of the additional measure names
|
void |
generatePartition(Instances data)
Builds the classifier to generate a partition.
|
boolean |
getBinarySplits()
Get the value of binarySplits.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
boolean |
getCollapseTree()
Get the value of collapseTree.
|
float |
getConfidenceFactor()
Get the value of CF.
|
boolean |
getDoNotMakeSplitPointActualValue()
Gets the value of doNotMakeSplitPointActualValue.
|
double |
getMeasure(java.lang.String additionalMeasureName)
Returns the value of the named measure
|
double[] |
getMembershipValues(Instance inst)
Computes an array that indicates node membership.
|
int |
getMinNumObj()
Get the value of minNumObj.
|
int |
getNumFolds()
Get the value of numFolds.
|
java.lang.String[] |
getOptions()
Gets the current settings of the Classifier.
|
boolean |
getReducedErrorPruning()
Get the value of reducedErrorPruning.
|
java.lang.String |
getRevision()
Returns the revision string.
|
boolean |
getSaveInstanceData()
Check whether instance data is to be saved.
|
int |
getSeed()
Get the value of Seed.
|
boolean |
getSubtreeRaising()
Get the value of subtreeRaising.
|
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.
|
boolean |
getUnpruned()
Get the value of unpruned.
|
boolean |
getUseLaplace()
Get the value of useLaplace.
|
boolean |
getUseMDLcorrection()
Get the value of useMDLcorrection.
|
java.lang.String |
globalInfo()
Returns a string describing classifier
|
java.lang.String |
graph()
Returns graph describing the tree.
|
int |
graphType()
Returns the type of graph this classifier represents.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(java.lang.String[] argv)
Main method for testing this class
|
double |
measureNumLeaves()
Returns the number of leaves
|
double |
measureNumRules()
Returns the number of rules (same as number of leaves)
|
double |
measureTreeSize()
Returns the size of the tree
|
java.lang.String |
minNumObjTipText()
Returns the tip text for this property
|
int |
numElements()
Returns the number of elements in the partition.
|
java.lang.String |
numFoldsTipText()
Returns the tip text for this property
|
java.lang.String |
prefix()
Returns tree in prefix order.
|
java.lang.String |
reducedErrorPruningTipText()
Returns the tip text for this property
|
java.lang.String |
saveInstanceDataTipText()
Returns the tip text for this property
|
java.lang.String |
seedTipText()
Returns the tip text for this property
|
void |
setBinarySplits(boolean v)
Set the value of binarySplits.
|
void |
setCollapseTree(boolean v)
Set the value of collapseTree.
|
void |
setConfidenceFactor(float v)
Set the value of CF.
|
void |
setDoNotMakeSplitPointActualValue(boolean m_doNotMakeSplitPointActualValue)
Sets the value of doNotMakeSplitPointActualValue.
|
void |
setMinNumObj(int v)
Set the value of minNumObj.
|
void |
setNumFolds(int v)
Set the value of numFolds.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
setReducedErrorPruning(boolean v)
Set the value of reducedErrorPruning.
|
void |
setSaveInstanceData(boolean v)
Set whether instance data is to be saved.
|
void |
setSeed(int newSeed)
Set the value of Seed.
|
void |
setSubtreeRaising(boolean v)
Set the value of subtreeRaising.
|
void |
setUnpruned(boolean v)
Set the value of unpruned.
|
void |
setUseLaplace(boolean newuseLaplace)
Set the value of useLaplace.
|
void |
setUseMDLcorrection(boolean newuseMDLcorrection)
Set the value of useMDLcorrection.
|
java.lang.String |
subtreeRaisingTipText()
Returns the tip text for this property
|
java.lang.String |
toSource(java.lang.String className)
Returns tree as an if-then statement.
|
java.lang.String |
toString()
Returns a description of the classifier.
|
java.lang.String |
toSummaryString()
Returns a superconcise version of the model
|
java.lang.String |
unprunedTipText()
Returns the tip text for this property
|
java.lang.String |
useLaplaceTipText()
Returns the tip text for this property
|
java.lang.String |
useMDLcorrectionTipText()
Returns the tip text for this property
|
batchSizeTipText, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
makeCopy
public java.lang.String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public Capabilities getCapabilities()
getCapabilities
in interface Classifier
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class AbstractClassifier
Capabilities
public void buildClassifier(Instances instances) throws java.lang.Exception
buildClassifier
in interface Classifier
instances
- the data to train the classifier withjava.lang.Exception
- if classifier can't be built successfullypublic double classifyInstance(Instance instance) throws java.lang.Exception
classifyInstance
in interface Classifier
classifyInstance
in class AbstractClassifier
instance
- the instance to classifyjava.lang.Exception
- if instance can't be classified successfullypublic final double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in interface Classifier
distributionForInstance
in class AbstractClassifier
instance
- the instance to calculate the class probabilities forjava.lang.Exception
- if distribution can't be computed successfullypublic int graphType()
public java.lang.String graph() throws java.lang.Exception
public java.lang.String prefix() throws java.lang.Exception
public java.lang.String toSource(java.lang.String className) throws java.lang.Exception
public java.util.Enumeration<Option> listOptions()
-U
Use unpruned tree.
-C confidence
Set confidence threshold for pruning. (Default: 0.25)
-M number
Set minimum number of instances per leaf. (Default: 2)
-R
Use reduced error pruning. No subtree raising is performed.
-N number
Set number of folds for reduced error pruning. One fold is used as the
pruning set. (Default: 3)
-B
Use binary splits for nominal attributes.
-S
Don't perform subtree raising.
-L
Do not clean up after the tree has been built.
-A
If set, Laplace smoothing is used for predicted probabilites.
-Q
The seed for reduced-error pruning.
listOptions
in interface OptionHandler
listOptions
in class AbstractClassifier
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-U Use unpruned tree.
-O Do not collapse tree.
-C <pruning confidence> Set confidence threshold for pruning. (default 0.25)
-M <minimum number of instances> Set minimum number of instances per leaf. (default 2)
-R Use reduced error pruning.
-N <number of folds> Set number of folds for reduced error pruning. One fold is used as pruning set. (default 3)
-B Use binary splits only.
-S Don't perform subtree raising.
-L Do not clean up after the tree has been built.
-A Laplace smoothing for predicted probabilities.
-J Do not use MDL correction for info gain on numeric attributes.
-Q <seed> Seed for random data shuffling (default 1).
-doNotMakeSplitPointActualValue Do not make split point actual value.
setOptions
in interface OptionHandler
setOptions
in class AbstractClassifier
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class AbstractClassifier
public java.lang.String seedTipText()
public int getSeed()
public void setSeed(int newSeed)
newSeed
- Value to assign to Seed.public java.lang.String useLaplaceTipText()
public boolean getUseLaplace()
public void setUseLaplace(boolean newuseLaplace)
newuseLaplace
- Value to assign to useLaplace.public java.lang.String useMDLcorrectionTipText()
public boolean getUseMDLcorrection()
public void setUseMDLcorrection(boolean newuseMDLcorrection)
newuseMDLcorrection
- Value to assign to useMDLcorrection.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toSummaryString()
toSummaryString
in interface Summarizable
public double measureTreeSize()
public double measureNumLeaves()
public double measureNumRules()
public java.util.Enumeration<java.lang.String> enumerateMeasures()
enumerateMeasures
in interface AdditionalMeasureProducer
public double getMeasure(java.lang.String additionalMeasureName)
getMeasure
in interface AdditionalMeasureProducer
additionalMeasureName
- the name of the measure to query for its valuejava.lang.IllegalArgumentException
- if the named measure is not supportedpublic java.lang.String unprunedTipText()
public boolean getUnpruned()
public void setUnpruned(boolean v)
v
- Value to assign to unpruned.public java.lang.String collapseTreeTipText()
public boolean getCollapseTree()
public void setCollapseTree(boolean v)
v
- Value to assign to collapseTree.public java.lang.String confidenceFactorTipText()
public float getConfidenceFactor()
public void setConfidenceFactor(float v)
v
- Value to assign to CF.public java.lang.String minNumObjTipText()
public int getMinNumObj()
public void setMinNumObj(int v)
v
- Value to assign to minNumObj.public java.lang.String reducedErrorPruningTipText()
public boolean getReducedErrorPruning()
public void setReducedErrorPruning(boolean v)
v
- Value to assign to reducedErrorPruning.public java.lang.String numFoldsTipText()
public int getNumFolds()
public void setNumFolds(int v)
v
- Value to assign to numFolds.public java.lang.String binarySplitsTipText()
public boolean getBinarySplits()
public void setBinarySplits(boolean v)
v
- Value to assign to binarySplits.public java.lang.String subtreeRaisingTipText()
public boolean getSubtreeRaising()
public void setSubtreeRaising(boolean v)
v
- Value to assign to subtreeRaising.public java.lang.String saveInstanceDataTipText()
public boolean getSaveInstanceData()
public void setSaveInstanceData(boolean v)
v
- true if instance data is to be savedpublic java.lang.String doNotMakeSplitPointActualValueTipText()
public boolean getDoNotMakeSplitPointActualValue()
public void setDoNotMakeSplitPointActualValue(boolean m_doNotMakeSplitPointActualValue)
m_doNotMakeSplitPointActualValue
- the value to setpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClassifier
public void generatePartition(Instances data) throws java.lang.Exception
generatePartition
in interface PartitionGenerator
java.lang.Exception
public double[] getMembershipValues(Instance inst) throws java.lang.Exception
getMembershipValues
in interface PartitionGenerator
java.lang.Exception
public int numElements() throws java.lang.Exception
numElements
in interface PartitionGenerator
java.lang.Exception
public static void main(java.lang.String[] argv)
argv
- the commandline options