Class AbstainingLWL

  • All Implemented Interfaces:
    Stoppable, StoppableWithFeedback, Serializable, Cloneable, AbstainingClassifier, weka.classifiers.Classifier, ThreadSafeClassifier, weka.classifiers.UpdateableClassifier, weka.core.BatchPredictor, weka.core.CapabilitiesHandler, weka.core.CapabilitiesIgnorer, weka.core.CommandlineRunnable, weka.core.OptionHandler, weka.core.RevisionHandler, weka.core.TechnicalInformationHandler, weka.core.WeightedInstancesHandler

    public class AbstainingLWL
    extends LWLSynchro
    implements AbstainingClassifier
    LWL variant that supports abstaining if the base classifier is able to.
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean m_CanAbstain
      whether the base classifier can abstain.
      • Fields inherited from class weka.classifiers.lazy.LWL

        CONSTANT, EPANECHNIKOV, GAUSS, INVERSE, LINEAR, m_kNN, m_NNSearch, m_Train, m_UseAllK, m_WeightKernel, m_ZeroR, TRICUBE
      • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstainingLWL()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buildClassifier​(weka.core.Instances instances)
      Generates the classifier.
      boolean canAbstain()
      Whether abstaining is possible, e.g., used in meta-classifiers.
      double getAbstentionClassification​(weka.core.Instance inst)
      The prediction that made the classifier abstain.
      double[] getAbstentionDistribution​(weka.core.Instance inst)
      The class distribution that made the classifier abstain.
      String globalInfo()
      Returns a string describing classifier.
      String toString()
      Returns a description of this classifier.
      • Methods inherited from class weka.classifiers.lazy.LWL

        enumerateMeasures, getCapabilities, getKNN, getMeasure, getNearestNeighbourSearchAlgorithm, getTechnicalInformation, getWeightingKernel, KNNTipText, nearestNeighbourSearchAlgorithmTipText, setKNN, setNearestNeighbourSearchAlgorithm, setWeightingKernel, updateClassifier, weightingKernelTipText
      • Methods inherited from class weka.classifiers.SingleClassifierEnhancer

        classifierTipText, defaultClassifierOptions, getClassifier, getClassifierSpec, postExecution, preExecution, setClassifier
      • Methods inherited from class weka.classifiers.AbstractClassifier

        batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
      • Methods inherited from interface weka.classifiers.Classifier

        classifyInstance, distributionForInstance, getCapabilities
    • Field Detail

      • m_CanAbstain

        protected boolean m_CanAbstain
        whether the base classifier can abstain.
    • Constructor Detail

      • AbstainingLWL

        public AbstainingLWL()
    • Method Detail

      • globalInfo

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

        public void buildClassifier​(weka.core.Instances instances)
                             throws Exception
        Generates the classifier.
        Specified by:
        buildClassifier in interface weka.classifiers.Classifier
        Overrides:
        buildClassifier in class LWLSynchro
        Parameters:
        instances - set of instances serving as training data
        Throws:
        Exception - if the classifier has not been generated successfully
      • canAbstain

        public boolean canAbstain()
        Whether abstaining is possible, e.g., used in meta-classifiers.
        Specified by:
        canAbstain in interface AbstainingClassifier
        Returns:
        true if abstaining is possible
      • getAbstentionClassification

        public double getAbstentionClassification​(weka.core.Instance inst)
                                           throws Exception
        The prediction that made the classifier abstain.
        Specified by:
        getAbstentionClassification in interface AbstainingClassifier
        Parameters:
        inst - the instance to get the prediction for
        Returns:
        the prediction, Utils.missingValue() if abstaining is not possible
        Throws:
        Exception - if fails to make prediction
      • getAbstentionDistribution

        public double[] getAbstentionDistribution​(weka.core.Instance inst)
                                           throws Exception
        The class distribution that made the classifier abstain.
        Specified by:
        getAbstentionDistribution in interface AbstainingClassifier
        Parameters:
        inst - the instance to get the prediction for
        Returns:
        the class distribution, null if abstaining is not possible
        Throws:
        Exception - if fails to make prediction
      • toString

        public String toString()
        Returns a description of this classifier.
        Overrides:
        toString in class LWLSynchro
        Returns:
        a description of this classifier as a string.