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

Class weka.classifiers.j48.J48

java.lang.Object
   |
   +----weka.classifiers.Classifier
           |
           +----weka.classifiers.DistributionClassifier
                   |
                   +----weka.classifiers.j48.J48

public class J48
extends DistributionClassifier
implements OptionHandler, Drawable, Matchable, Sourcable, WeightedInstancesHandler, Summarizable, AdditionalMeasureProducer
Class for generating an unpruned or a pruned C4.5 decision tree. For more information, see

Ross Quinlan (1993). C4.5: Programs for Machine Learning, Morgan Kaufmann Publishers, San Mateo, CA.

Valid options are:

-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.

Author:
Eibe Frank (eibe@cs.waikato.ac.nz)

Constructor Index

 o J48()

Method Index

 o buildClassifier(Instances)
Generates the classifier.
 o classifyInstance(Instance)
Classifies an instance.
 o distributionForInstance(Instance)
Returns class probabilities for an instance.
 o enumerateMeasures()
Returns an enumeration of the additional measure names
 o getBinarySplits()
Get the value of binarySplits.
 o getConfidenceFactor()
Get the value of CF.
 o getMeasure(String)
Returns the value of the named measure
 o getMinNumObj()
Get the value of minNumObj.
 o getNumFolds()
Get the value of numFolds.
 o getOptions()
Gets the current settings of the Classifier.
 o getReducedErrorPruning()
Get the value of reducedErrorPruning.
 o getSaveInstanceData()
Check whether instance data is to be saved.
 o getSubtreeRaising()
Get the value of subtreeRaising.
 o getUnpruned()
Get the value of unpruned.
 o getUseLaplace()
Get the value of useLaplace.
 o graph()
Returns graph describing the tree.
 o listOptions()
Returns an enumeration describing the available options Valid options are:

-U
Use unpruned tree.

-C confidence
Set confidence threshold for pruning.

 o main(String[])
Main method for testing this class
 o measureNumLeaves()
Returns the number of leaves
 o measureNumRules()
Returns the number of rules (same as number of leaves)
 o measureTreeSize()
Returns the size of the tree
 o prefix()
Returns tree in prefix order.
 o setBinarySplits(boolean)
Set the value of binarySplits.
 o setConfidenceFactor(float)
Set the value of CF.
 o setMinNumObj(int)
Set the value of minNumObj.
 o setNumFolds(int)
Set the value of numFolds.
 o setOptions(String[])
Parses a given list of options.
 o setReducedErrorPruning(boolean)
Set the value of reducedErrorPruning.
 o setSaveInstanceData(boolean)
Set whether instance data is to be saved.
 o setSubtreeRaising(boolean)
Set the value of subtreeRaising.
 o setUnpruned(boolean)
Set the value of unpruned.
 o setUseLaplace(boolean)
Set the value of useLaplace.
 o toSource(String)
Returns tree as an if-then statement.
 o toString()
Returns a description of the classifier.
 o toSummaryString()
Returns a superconcise version of the model

Constructors

 o J48
 public J48()

Methods

 o buildClassifier
 public void buildClassifier(Instances instances) throws Exception
Generates the classifier.

Throws: Exception
if classifier can't be built successfully
Overrides:
buildClassifier in class Classifier
 o classifyInstance
 public double classifyInstance(Instance instance) throws Exception
Classifies an instance.

Throws: Exception
if instance can't be classified successfully
Overrides:
classifyInstance in class DistributionClassifier
 o distributionForInstance
 public final double[] distributionForInstance(Instance instance) throws Exception
Returns class probabilities for an instance.

Throws: Exception
if distribution can't be computed successfully
Overrides:
distributionForInstance in class DistributionClassifier
 o graph
 public String graph() throws Exception
Returns graph describing the tree.

Throws: Exception
if graph can't be computed
 o prefix
 public String prefix() throws Exception
Returns tree in prefix order.

Throws: Exception
if something goes wrong
 o toSource
 public String toSource(String className) throws Exception
Returns tree as an if-then statement.

Returns:
the tree as a Java if-then type statement
Throws: Exception
if something goes wrong
 o listOptions
 public Enumeration listOptions()
Returns an enumeration describing the available options Valid options are:

-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.

Returns:
an enumeration of all the available options
 o setOptions
 public void setOptions(String options[]) throws Exception
Parses a given list of options.

Parameters:
options - the list of options as an array of strings
Throws: Exception
if an option is not supported
 o getOptions
 public String[] getOptions()
Gets the current settings of the Classifier.

Returns:
an array of strings suitable for passing to setOptions
 o getUseLaplace
 public boolean getUseLaplace()
Get the value of useLaplace.

Returns:
Value of useLaplace.
 o setUseLaplace
 public void setUseLaplace(boolean newuseLaplace)
Set the value of useLaplace.

Parameters:
newuseLaplace - Value to assign to useLaplace.
 o toString
 public String toString()
Returns a description of the classifier.

Overrides:
toString in class Object
 o toSummaryString
 public String toSummaryString()
Returns a superconcise version of the model

 o measureTreeSize
 public double measureTreeSize()
Returns the size of the tree

Returns:
the size of the tree
 o measureNumLeaves
 public double measureNumLeaves()
Returns the number of leaves

Returns:
the number of leaves
 o measureNumRules
 public double measureNumRules()
Returns the number of rules (same as number of leaves)

Returns:
the number of rules
 o enumerateMeasures
 public Enumeration enumerateMeasures()
Returns an enumeration of the additional measure names

Returns:
an enumeration of the measure names
 o getMeasure
 public double getMeasure(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: IllegalArgumentException
if the named measure is not supported
 o getUnpruned
 public boolean getUnpruned()
Get the value of unpruned.

Returns:
Value of unpruned.
 o setUnpruned
 public void setUnpruned(boolean v)
Set the value of unpruned. Turns reduced-error pruning off if set.

Parameters:
v - Value to assign to unpruned.
 o getConfidenceFactor
 public float getConfidenceFactor()
Get the value of CF.

Returns:
Value of CF.
 o setConfidenceFactor
 public void setConfidenceFactor(float v)
Set the value of CF.

Parameters:
v - Value to assign to CF.
 o getMinNumObj
 public int getMinNumObj()
Get the value of minNumObj.

Returns:
Value of minNumObj.
 o setMinNumObj
 public void setMinNumObj(int v)
Set the value of minNumObj.

Parameters:
v - Value to assign to minNumObj.
 o getReducedErrorPruning
 public boolean getReducedErrorPruning()
Get the value of reducedErrorPruning.

Returns:
Value of reducedErrorPruning.
 o setReducedErrorPruning
 public void setReducedErrorPruning(boolean v)
Set the value of reducedErrorPruning. Turns unpruned trees off if set.

Parameters:
v - Value to assign to reducedErrorPruning.
 o getNumFolds
 public int getNumFolds()
Get the value of numFolds.

Returns:
Value of numFolds.
 o setNumFolds
 public void setNumFolds(int v)
Set the value of numFolds.

Parameters:
v - Value to assign to numFolds.
 o getBinarySplits
 public boolean getBinarySplits()
Get the value of binarySplits.

Returns:
Value of binarySplits.
 o setBinarySplits
 public void setBinarySplits(boolean v)
Set the value of binarySplits.

Parameters:
v - Value to assign to binarySplits.
 o getSubtreeRaising
 public boolean getSubtreeRaising()
Get the value of subtreeRaising.

Returns:
Value of subtreeRaising.
 o setSubtreeRaising
 public void setSubtreeRaising(boolean v)
Set the value of subtreeRaising.

Parameters:
v - Value to assign to subtreeRaising.
 o getSaveInstanceData
 public boolean getSaveInstanceData()
Check whether instance data is to be saved.

Returns:
true if instance data is saved
 o setSaveInstanceData
 public void setSaveInstanceData(boolean v)
Set whether instance data is to be saved.

Parameters:
v - true if instance data is to be saved
 o main
 public static void main(String argv[])
Main method for testing this class

Parameters:
String - options

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