weka.classifiers.trees.m5

## Class M5Base

- java.lang.Object
- - weka.classifiers.AbstractClassifier
  - - weka.classifiers.trees.m5.M5Base

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Classifier, AdditionalMeasureProducer, BatchPredictor, CapabilitiesHandler, CapabilitiesIgnorer, CommandlineRunnable, OptionHandler, RevisionHandler, TechnicalInformationHandler
  Direct Known Subclasses:
    M5P, M5Rules

      public abstract class M5Base
      extends AbstractClassifier
      implements AdditionalMeasureProducer, 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: 12641 $
  Author:
    Mark Hall (mhall@cs.waikato.ac.nz)
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class weka.classifiers.AbstractClassifier

      `BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `M5Base()` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `buildClassifier(Instances data)` Generates the classifier.
    `java.lang.String` | `buildRegressionTreeTipText()` Returns the tip text for this property
    `double` | `classifyInstance(Instance inst)` Calculates a prediction for an instance using a set of rules or an M5 model tree
    `java.util.Enumeration<java.lang.String>` | `enumerateMeasures()` Returns an enumeration of the additional measure names
    `java.lang.String` | `generateRulesTipText()` Returns the tip text for this property
    `boolean` | `getBuildRegressionTree()` Get the value of regressionTree.
    `Capabilities` | `getCapabilities()` Returns default capabilities of the classifier, i.e., of LinearRegression.
    `RuleNode` | `getM5RootNode()`
    `double` | `getMeasure(java.lang.String additionalMeasureName)` Returns the value of the named measure
    `double` | `getMinNumInstances()` Get the minimum number of instances to allow at a leaf node
    `java.lang.String[]` | `getOptions()` Gets the current settings of the classifier.
    `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
    `java.lang.String` | `globalInfo()` returns information about the classifier
    `java.util.Enumeration<Option>` | `listOptions()` Returns an enumeration describing the available options
    `double` | `measureNumRules()` return the number of rules
    `java.lang.String` | `minNumInstancesTipText()` Returns the tip text for this property
    `void` | `setBuildRegressionTree(boolean newregressionTree)` Set the value of regressionTree.
    `void` | `setMinNumInstances(double minNum)` Set the minimum number of instances to allow at a leaf node
    `void` | `setOptions(java.lang.String[] options)` Parses a given list of options.
    `void` | `setUnpruned(boolean unpruned)` Use unpruned tree/rules
    `void` | `setUseUnsmoothed(boolean s)` Use unsmoothed predictions
    `java.lang.String` | `toString()` Returns a description of the classifier
    `java.lang.String` | `unprunedTipText()` Returns the tip text for this property
    `java.lang.String` | `useUnsmoothedTipText()` Returns the tip text for this property

    - ### Methods inherited from class weka.classifiers.AbstractClassifier

      `batchSizeTipText, debugTipText, distributionForInstance, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, getRevision, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### M5Base

          public M5Base()

      Constructor

  - ### Method Detail

    - #### globalInfo

          public java.lang.String globalInfo()

      returns information about the classifier
      Returns:
        a description suitable for displaying in the explorer/experimenter gui

    - #### getTechnicalInformation

          public 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 `TechnicalInformationHandler`
      Returns:
        the technical information about this class

    - #### listOptions

          public java.util.Enumeration<Option> listOptions()

      Returns an enumeration describing the available options
      Specified by:
        `listOptions` in interface `OptionHandler`
      Overrides:
        `listOptions` in class `AbstractClassifier`
      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.

      Valid options are:

      -U
      Use unsmoothed predictions.

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

      Specified by:
        `setOptions` in interface `OptionHandler`
      Overrides:
        `setOptions` in class `AbstractClassifier`
      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`
      Overrides:
        `getOptions` in class `AbstractClassifier`
      Returns:
        an array of strings suitable for passing to setOptions

    - #### unprunedTipText

          public java.lang.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 java.lang.String generateRulesTipText()

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

    - #### useUnsmoothedTipText

          public java.lang.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 java.lang.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 java.lang.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 Capabilities getCapabilities()

      Returns default capabilities of the classifier, i.e., of LinearRegression.
      Specified by:
        `getCapabilities` in interface `Classifier`
      Specified by:
        `getCapabilities` in interface `CapabilitiesHandler`
      Overrides:
        `getCapabilities` in class `AbstractClassifier`
      Returns:
        the capabilities of this classifier
      See Also:
        `Capabilities`

    - #### buildClassifier

          public void buildClassifier(Instances data)
                               throws java.lang.Exception

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

    - #### classifyInstance

          public double classifyInstance(Instance inst)
                                  throws java.lang.Exception

      Calculates a prediction for an instance using a set of rules or an M5 model tree
      Specified by:
        `classifyInstance` in interface `Classifier`
      Overrides:
        `classifyInstance` in class `AbstractClassifier`
      Parameters:
        `inst` - the instance whos class value is to be predicted
      Returns:
        the prediction
      Throws:
        `java.lang.Exception` - if a prediction can't be made.

    - #### toString

          public java.lang.String toString()

      Returns a description of the classifier
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a description of the classifier as a String

    - #### enumerateMeasures

          public java.util.Enumeration<java.lang.String> 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:
        `additionalMeasureName` - the name of the measure to query for its value
      Returns:
        the value of the named measure
      Throws:
        `java.lang.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 RuleNode getM5RootNode()