Class MOA

  • All Implemented Interfaces:
    Serializable, Cloneable, weka.classifiers.Classifier, weka.classifiers.UpdateableClassifier, weka.core.BatchPredictor, weka.core.CapabilitiesHandler, weka.core.CapabilitiesIgnorer, weka.core.CommandlineRunnable, weka.core.OptionHandler, weka.core.RevisionHandler

    public class MOA
    extends weka.classifiers.AbstractClassifier
    implements weka.classifiers.UpdateableClassifier
    Wrapper for MOA classifiers.

    Since MOA doesn't offer a mechanism to query a classifier for the types of attributes and classes it can handle, the capabilities of this wrapper are hard-coded: nominal and numeric attributes and only nominal class attributes are allowed.

    Valid options are:

     -B <classname + options>
      The MOA classifier to use.
      (default: moa.classifiers.DecisionStump)
     -D
      If set, classifier is run in debug mode and
      may output additional info to the console
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_ActualClassifier

        protected Classifier m_ActualClassifier
        the actual moa classifier to use for learning.
      • m_Classifier

        protected ClassOption m_Classifier
        the moa classifier option (this object is used in the GenericObjectEditor).
    • Constructor Detail

      • MOA

        public MOA()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the classifier.
        Returns:
        a description suitable for displaying in the explorer/experimenter gui
      • 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:

         -B <classname + options>
          The MOA classifier to use.
          (default: moa.classifiers.trees.DecisionStump)
         -D
          If set, classifier is run in debug mode and
          may output additional info to the console
        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
      • setClassifier

        public void setClassifier​(ClassOption value)
        Sets the MOA classifier to use.
        Parameters:
        value - the classifier to use
      • getClassifier

        public ClassOption getClassifier()
        Returns the current MOA classifier in use.
        Returns:
        the classifier in use
      • classifierTipText

        public String classifierTipText()
        Returns the tooltip displayed in the GUI.
        Returns:
        the tooltip
      • getCapabilities

        public weka.core.Capabilities getCapabilities()
        Returns the Capabilities of this classifier. Maximally permissive capabilities are allowed by default. MOA doesn't specify what
        Specified by:
        getCapabilities in interface weka.core.CapabilitiesHandler
        Specified by:
        getCapabilities in interface weka.classifiers.Classifier
        Overrides:
        getCapabilities in class weka.classifiers.AbstractClassifier
        Returns:
        the capabilities of this object
        See Also:
        Capabilities
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Generates a 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
      • updateClassifier

        public void updateClassifier​(weka.core.Instance instance)
                              throws Exception
        Updates a classifier using the given instance.
        Specified by:
        updateClassifier in interface weka.classifiers.UpdateableClassifier
        Parameters:
        instance - the instance to included
        Throws:
        Exception - if instance could not be incorporated successfully
      • distributionForInstance

        public double[] distributionForInstance​(weka.core.Instance instance)
                                         throws Exception
        Predicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero. If the class is numeric, the array must consist of only one element, which contains the predicted value.
        Specified by:
        distributionForInstance in interface weka.classifiers.Classifier
        Overrides:
        distributionForInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        instance - the instance to be classified
        Returns:
        an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction
        Throws:
        Exception - if distribution could not be computed successfully
      • getRevision

        public String getRevision()
        Returns the revision string.
        Specified by:
        getRevision in interface weka.core.RevisionHandler
        Overrides:
        getRevision in class weka.classifiers.AbstractClassifier
        Returns:
        the revision
      • toString

        public String toString()
        Returns a string representation of the model.
        Overrides:
        toString in class Object
        Returns:
        the string representation
      • main

        public static void main​(String[] args)
        Main method for testing this class.
        Parameters:
        args - the options