Class WeightedInstancesHandlerWrapper

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

    public class WeightedInstancesHandlerWrapper
    extends weka.classifiers.SingleClassifierEnhancer
    implements weka.core.WeightedInstancesHandler
    A meta-classifier that implements the weka.core.WeightedInstancesHandler interface in order to enable all classifiers to be used in other meta-classifiers that require the base classifier to implem ent the WeightedInstancesHandler interface. This meta-classifier does nothing with the weights, it is just a dumb (but useful) wrapper.

    Valid options are:

     -D
      If set, classifier is run in debug mode and
      may output additional info to the console
     -W
      Full name of base classifier.
      (default: weka.classifiers.rules.ZeroR)
     Options specific to classifier weka.classifiers.rules.ZeroR:
     
     -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 Summary

      • Fields inherited from class weka.classifiers.SingleClassifierEnhancer

        m_Classifier
      • Fields inherited from class weka.classifiers.AbstractClassifier

        BATCH_SIZE_DEFAULT, m_BatchSize, m_Debug, m_DoNotCheckCapabilities, m_numDecimalPlaces, NUM_DECIMAL_PLACES_DEFAULT
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buildClassifier​(weka.core.Instances data)
      Generates a classifier.
      double classifyInstance​(weka.core.Instance instance)
      Classifies the given test instance.
      double[] distributionForInstance​(weka.core.Instance instance)
      Predicts the class memberships for a given instance.
      String globalInfo()
      Returns a string describing the classifier.
      static void main​(String[] args)
      Main method for running this class.
      String toString()
      Returns a string representation of the base classifier.
      • Methods inherited from class weka.classifiers.SingleClassifierEnhancer

        classifierTipText, defaultClassifierOptions, defaultClassifierString, getCapabilities, getClassifier, getClassifierSpec, getOptions, listOptions, postExecution, preExecution, setClassifier, setOptions
      • Methods inherited from class weka.classifiers.AbstractClassifier

        batchSizeTipText, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, getRevision, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
    • Constructor Detail

      • WeightedInstancesHandlerWrapper

        public WeightedInstancesHandlerWrapper()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the classifier.
        Returns:
        a description suitable for displaying in the explorer/experimenter gui
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Generates a classifier. Must initialize all fields of the classifier that are not being set via options (ie. multiple calls of buildClassifier must always lead to the same result). Must not change the dataset in any way.
        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 instance)
                                throws Exception
        Classifies the given test instance. The instance has to belong to a dataset when it's being classified.
        Specified by:
        classifyInstance in interface weka.classifiers.Classifier
        Overrides:
        classifyInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        instance - the instance to be classified
        Returns:
        the predicted most likely class for the instance or Instance.missingValue() if no prediction is made
        Throws:
        Exception - if an error occurred during the prediction
      • 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
      • toString

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

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