weka.classifiers.m5
Class M5Prime

java.lang.Object
  |
  +--weka.classifiers.Classifier
        |
        +--weka.classifiers.m5.M5Prime
All Implemented Interfaces:
AdditionalMeasureProducer, java.lang.Cloneable, OptionHandler, java.io.Serializable

public final class M5Prime
extends Classifier
implements OptionHandler, AdditionalMeasureProducer

Class for contructing and evaluating model trees; M5' algorithm.

Reference: Wang, Y. and Witten, I.H. (1997). Induction of model trees for predicting continuous classes. Proceedings of the poster papers of the European Conference on Machine Learning. University of Economics, Faculty of Informatics and Statistics, Prague.

Valid options are:

-O
Type of model to be used. (l: linear regression, r: regression tree, m: model tree) (default: m)

-U
Use unsmoothed tree.

-F factor
Set pruning factor (default: 2).

-V <0|1|2>
Verbosity (default: 0).

Author:
Yong Wang (yongwang@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
static int MODEL_LINEAR_REGRESSION
           
static int MODEL_MODEL_TREE
           
static int MODEL_REGRESSION_TREE
           
static Tag[] TAGS_MODEL_TYPES
           
 
Constructor Summary
M5Prime()
           
 
Method Summary
 void buildClassifier(Instances inst)
          Construct a model tree by training instances
 double classifyInstance(Instance ins)
          Classifies the given test instance.
 java.util.Enumeration enumerateMeasures()
          Returns an enumeration of the additional measure names
 double getMeasure(java.lang.String additionalMeasureName)
          Returns the value of the named measure
 SelectedTag getModelType()
          Get the value of Model.
 java.lang.String[] getOptions()
          Gets the current settings of the Classifier.
 double getPruningFactor()
          Get the value of PruningFactor.
 boolean getUseUnsmoothed()
          Get the value of UseUnsmoothed.
 int getVerbosity()
          Get the value of Verbosity.
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
static void main(java.lang.String[] argv)
          Main method for M5' algorithm
 double measureNumLeaves()
          return the number of leaves in the tree
 double measureNumLinearModels()
          return the number of linear models
 double measureNumRules()
          return the number of rules
 void setModelType(SelectedTag newMethod)
          Set the value of Model.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setPruningFactor(double v)
          Set the value of PruningFactor.
 void setUseUnsmoothed(boolean v)
          Set the value of UseUnsmoothed.
 void setVerbosity(int v)
          Set the value of Verbosity.
 java.lang.String toString()
          Converts the output of the training process into a string
 
Methods inherited from class weka.classifiers.Classifier
forName, makeCopies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MODEL_LINEAR_REGRESSION

public static final int MODEL_LINEAR_REGRESSION

MODEL_REGRESSION_TREE

public static final int MODEL_REGRESSION_TREE

MODEL_MODEL_TREE

public static final int MODEL_MODEL_TREE

TAGS_MODEL_TYPES

public static final Tag[] TAGS_MODEL_TYPES
Constructor Detail

M5Prime

public M5Prime()
Method Detail

buildClassifier

public final void buildClassifier(Instances inst)
                           throws java.lang.Exception
Construct a model tree by training instances
Overrides:
buildClassifier in class Classifier
Parameters:
inst - training instances
options - information for constructing the model tree, mostly from command line options
Returns:
the root of the model tree
Throws:
java.lang.Exception - if the classifier can't be built

classifyInstance

public double classifyInstance(Instance ins)
                        throws java.lang.Exception
Classifies the given test instance.
Overrides:
classifyInstance in class Classifier
Parameters:
instance - the instance to be classified
Returns:
the predicted class for the instance
Throws:
java.lang.Exception - if the instance can't be classified

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration describing the available options. Valid options are:

-O
Type of model to be used. (l: linear regression, r: regression tree, m: model tree) (default: m)

-U
Use unsmoothed tree.

-F factor
Set pruning factor (default: 2).

-V <0|1|2>
Verbosity (default: 0).

Specified by:
listOptions in interface OptionHandler
Returns:
an enumeration of all the available options

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Parses a given list of options.
Specified by:
setOptions in interface OptionHandler
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

getOptions

public java.lang.String[] getOptions()
Gets the current settings of the Classifier.
Specified by:
getOptions in interface OptionHandler
Returns:
an array of strings suitable for passing to setOptions

toString

public final java.lang.String toString()
Converts the output of the training process into a string
Overrides:
toString in class java.lang.Object
Returns:
the converted string

measureNumLinearModels

public double measureNumLinearModels()
return the number of linear models
Returns:
the number of linear models

measureNumLeaves

public double measureNumLeaves()
return the number of leaves in the tree
Returns:
the number leaves in the tree (same as # linear models & # rules)

measureNumRules

public double measureNumRules()
return the number of rules
Returns:
the number of rules (same as # linear models & # leaves in the tree)

enumerateMeasures

public java.util.Enumeration enumerateMeasures()
Returns an enumeration of the additional measure names
Specified by:
enumerateMeasures in interface AdditionalMeasureProducer
Returns:
an enumeration of the measure names

getMeasure

public double getMeasure(java.lang.String additionalMeasureName)
Returns the value of the named measure
Specified by:
getMeasure in interface AdditionalMeasureProducer
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

getUseUnsmoothed

public boolean getUseUnsmoothed()
Get the value of UseUnsmoothed.
Returns:
Value of UseUnsmoothed.

setUseUnsmoothed

public void setUseUnsmoothed(boolean v)
Set the value of UseUnsmoothed.
Parameters:
v - Value to assign to UseUnsmoothed.

getPruningFactor

public double getPruningFactor()
Get the value of PruningFactor.
Returns:
Value of PruningFactor.

setPruningFactor

public void setPruningFactor(double v)
Set the value of PruningFactor.
Parameters:
v - Value to assign to PruningFactor.

getModelType

public SelectedTag getModelType()
Get the value of Model.
Returns:
Value of Model.

setModelType

public void setModelType(SelectedTag newMethod)
Set the value of Model.
Parameters:
v - Value to assign to Model.

getVerbosity

public int getVerbosity()
Get the value of Verbosity.
Returns:
Value of Verbosity.

setVerbosity

public void setVerbosity(int v)
Set the value of Verbosity.
Parameters:
v - Value to assign to Verbosity.

main

public static void main(java.lang.String[] argv)
Main method for M5' algorithm
Parameters:
argv - command line arguments