weka.classifiers.trees.m5
Class M5Base2

java.lang.Object
  extended by weka.classifiers.AbstractClassifier
      extended by weka.classifiers.trees.m5.M5Base2
All Implemented Interfaces:
Serializable, Cloneable, weka.classifiers.Classifier, weka.core.AdditionalMeasureProducer, weka.core.CapabilitiesHandler, weka.core.OptionHandler, weka.core.RevisionHandler, weka.core.TechnicalInformationHandler
Direct Known Subclasses:
M5P2

public abstract class M5Base2
extends weka.classifiers.AbstractClassifier
implements weka.core.AdditionalMeasureProducer, weka.core.TechnicalInformationHandler

M5Base. Implements base routines for generating M5 Model trees and rules.

The original algorithm M5 was invented by Quinlan:
Quinlan J. R. (1992). Learning with continuous classes. Proceedings of the Australian Joint Conference on Artificial Intelligence. 343--348. World Scientific, Singapore.

Yong Wang made improvements and created M5':
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:

-U
Use unsmoothed predictions.

-R
Build regression tree/rule rather than model tree/rule

Version:
$Revision: 4584 $
Author:
Mark Hall (mhall@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
protected  double m_minNumInstances
          The minimum number of instances to allow at a leaf node
protected  boolean m_regressionTree
          Make a regression tree/rule instead of a model tree/rule
protected  weka.core.FastVector m_ruleSet
          the rule set
protected  boolean m_saveInstances
          Save instances at each node in an M5 tree for visualization purposes.
protected  boolean m_useUnpruned
          Do not prune tree/rules
 
Fields inherited from class weka.classifiers.AbstractClassifier
m_Debug
 
Constructor Summary
M5Base2()
          Constructor
 
Method Summary
 void buildClassifier(weka.core.Instances data)
          Generates the classifier.
 String buildRegressionTreeTipText()
          Returns the tip text for this property
 double classifyInstance(weka.core.Instance inst)
          Calculates a prediction for an instance using a set of rules or an M5 model tree
 Enumeration enumerateMeasures()
          Returns an enumeration of the additional measure names
 String generateRulesTipText()
          Returns the tip text for this property
 boolean getBuildRegressionTree()
          Get the value of regressionTree.
 weka.core.Capabilities getCapabilities()
          Returns default capabilities of the classifier, i.e., of LinearRegression.
protected  boolean getGenerateRules()
          get whether rules are being generated rather than a tree
 RuleNode2 getM5RootNode()
           
 double getMeasure(String additionalMeasureName)
          Returns the value of the named measure
 double getMinNumInstances()
          Get the minimum number of instances to allow at a leaf node
 String[] getOptions()
          Gets the current settings of the classifier.
 weka.core.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 whether unpruned tree/rules are being generated
 boolean getUseUnsmoothed()
          Get whether or not smoothing is being used
 String globalInfo()
          returns information about the classifier
 Enumeration listOptions()
          Returns an enumeration describing the available options
 double measureNumRules()
          return the number of rules
 String minNumInstancesTipText()
          Returns the tip text for this property
 void setBuildRegressionTree(boolean newregressionTree)
          Set the value of regressionTree.
protected  void setGenerateRules(boolean u)
          Generate rules (decision list) rather than a tree
 void setMinNumInstances(double minNum)
          Set the minimum number of instances to allow at a leaf node
 void setOptions(String[] options)
          Parses a given list of options.
 void setUnpruned(boolean unpruned)
          Use unpruned tree/rules
 void setUseUnsmoothed(boolean s)
          Use unsmoothed predictions
 String toString()
          Returns a description of the classifier
 String unprunedTipText()
          Returns the tip text for this property
 String useUnsmoothedTipText()
          Returns the tip text for this property
 
Methods inherited from class weka.classifiers.AbstractClassifier
debugTipText, distributionForInstance, forName, getDebug, getRevision, makeCopies, makeCopy, runClassifier, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_ruleSet

protected weka.core.FastVector m_ruleSet
the rule set


m_saveInstances

protected boolean m_saveInstances
Save instances at each node in an M5 tree for visualization purposes.


m_regressionTree

protected boolean m_regressionTree
Make a regression tree/rule instead of a model tree/rule


m_useUnpruned

protected boolean m_useUnpruned
Do not prune tree/rules


m_minNumInstances

protected double m_minNumInstances
The minimum number of instances to allow at a leaf node

Constructor Detail

M5Base2

public M5Base2()
Constructor

Method Detail

globalInfo

public String globalInfo()
returns information about the classifier

Returns:
a description suitable for displaying in the explorer/experimenter gui

getTechnicalInformation

public weka.core.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.

Specified by:
getTechnicalInformation in interface weka.core.TechnicalInformationHandler
Returns:
the technical information about this class

listOptions

public Enumeration listOptions()
Returns an enumeration describing the available options

Specified by:
listOptions in interface weka.core.OptionHandler
Overrides:
listOptions in class weka.classifiers.AbstractClassifier
Returns:
an enumeration of all the available options

setOptions

public void setOptions(String[] options)
                throws Exception
Parses a given list of options.

Valid options are:

-U
Use unsmoothed predictions.

-R
Build a regression tree rather than a model tree.

Specified by:
setOptions in interface weka.core.OptionHandler
Overrides:
setOptions in class weka.classifiers.AbstractClassifier
Parameters:
options - the list of options as an array of strings
Throws:
Exception - if an option is not supported

getOptions

public String[] getOptions()
Gets the current settings of the classifier.

Specified by:
getOptions in interface weka.core.OptionHandler
Overrides:
getOptions in class weka.classifiers.AbstractClassifier
Returns:
an array of strings suitable for passing to setOptions

unprunedTipText

public String unprunedTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setUnpruned

public void setUnpruned(boolean unpruned)
Use unpruned tree/rules

Parameters:
unpruned - true if unpruned tree/rules are to be generated

getUnpruned

public boolean getUnpruned()
Get whether unpruned tree/rules are being generated

Returns:
true if unpruned tree/rules are to be generated

generateRulesTipText

public String generateRulesTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setGenerateRules

protected void setGenerateRules(boolean u)
Generate rules (decision list) rather than a tree

Parameters:
u - true if rules are to be generated

getGenerateRules

protected boolean getGenerateRules()
get whether rules are being generated rather than a tree

Returns:
true if rules are to be generated

useUnsmoothedTipText

public String useUnsmoothedTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setUseUnsmoothed

public void setUseUnsmoothed(boolean s)
Use unsmoothed predictions

Parameters:
s - true if unsmoothed predictions are to be used

getUseUnsmoothed

public boolean getUseUnsmoothed()
Get whether or not smoothing is being used

Returns:
true if unsmoothed predictions are to be used

buildRegressionTreeTipText

public String buildRegressionTreeTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getBuildRegressionTree

public boolean getBuildRegressionTree()
Get the value of regressionTree.

Returns:
Value of regressionTree.

setBuildRegressionTree

public void setBuildRegressionTree(boolean newregressionTree)
Set the value of regressionTree.

Parameters:
newregressionTree - Value to assign to regressionTree.

minNumInstancesTipText

public String minNumInstancesTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setMinNumInstances

public void setMinNumInstances(double minNum)
Set the minimum number of instances to allow at a leaf node

Parameters:
minNum - the minimum number of instances

getMinNumInstances

public double getMinNumInstances()
Get the minimum number of instances to allow at a leaf node

Returns:
a double value

getCapabilities

public weka.core.Capabilities getCapabilities()
Returns default capabilities of the classifier, i.e., of LinearRegression.

Specified by:
getCapabilities in interface weka.classifiers.Classifier
Specified by:
getCapabilities in interface weka.core.CapabilitiesHandler
Overrides:
getCapabilities in class weka.classifiers.AbstractClassifier
Returns:
the capabilities of this classifier

buildClassifier

public void buildClassifier(weka.core.Instances data)
                     throws Exception
Generates the classifier.

Specified by:
buildClassifier in interface weka.classifiers.Classifier
Parameters:
data - set of instances serving as training data
Throws:
Exception - if the classifier has not been generated successfully

classifyInstance

public double classifyInstance(weka.core.Instance inst)
                        throws Exception
Calculates a prediction for an instance using a set of rules or an M5 model tree

Specified by:
classifyInstance in interface weka.classifiers.Classifier
Overrides:
classifyInstance in class weka.classifiers.AbstractClassifier
Parameters:
inst - the instance whos class value is to be predicted
Returns:
the prediction
Throws:
Exception - if a prediction can't be made.

toString

public String toString()
Returns a description of the classifier

Overrides:
toString in class Object
Returns:
a description of the classifier as a String

enumerateMeasures

public Enumeration enumerateMeasures()
Returns an enumeration of the additional measure names

Specified by:
enumerateMeasures in interface weka.core.AdditionalMeasureProducer
Returns:
an enumeration of the measure names

getMeasure

public double getMeasure(String additionalMeasureName)
Returns the value of the named measure

Specified by:
getMeasure in interface weka.core.AdditionalMeasureProducer
Parameters:
additionalMeasureName - the name of the measure to query for its value
Returns:
the value of the named measure
Throws:
Exception - if the named measure is not supported

measureNumRules

public double measureNumRules()
return the number of rules

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

getM5RootNode

public RuleNode2 getM5RootNode()


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.