Class SpectrumClassifier

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

    public class SpectrumClassifier
    extends weka.classifiers.StoppableSingleClassifierEnhancer
    implements weka.classifiers.AbstainingClassifier
    Automatically removes some IDs from the dataset before training the base classifier: id, db_id, sample_id.

    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.functions.GPD)
     Options specific to classifier weka.classifiers.functions.GPD:
     
     -D
      If set, classifier is run in debug mode and
      may output additional info to the console
     -L <double>
      Level of Gaussian Noise.
      (default: 1.0)
     -G <double>
      Gamma for the RBF kernel.
      (default: 0.01)
     -N
      Whether to 0=normalize/1=standardize/2=neither.
      (default: 0=normalize)
     -D
      If set, classifier is run in debug mode and
      may output additional info to the console
    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.
      protected weka.filters.unsupervised.attribute.Remove m_Remove
      The filter for removing sample ID/database ID.
      • Fields inherited from class weka.classifiers.StoppableSingleClassifierEnhancer

        m_Stopped
      • 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
      SpectrumClassifier()
      Default constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buildClassifier​(weka.core.Instances data)
      Build the classifier on the filtered data.
      boolean canAbstain()
      Whether abstaining is possible, e.g., used in meta-classifiers.
      protected String defaultClassifierString()
      String describing default classifier.
      double[] distributionForInstance​(weka.core.Instance instance)
      Classifies a given instance after filtering.
      double[][] distributionsForInstances​(weka.core.Instances insts)
      Batch scoring method
      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.
      weka.core.Capabilities getCapabilities()
      Returns default capabilities of the classifier.
      String getRevision()
      Returns the revision string.
      String globalInfo()
      Returns a string describing this classifier.
      boolean implementsMoreEfficientBatchPrediction()
      Return true if this classifier can generate batch predictions in an efficient manner.
      static void main​(String[] args)
      Main method for executing this classifier.
      String toString()
      Output a representation of this classifier
      • Methods inherited from class weka.classifiers.StoppableSingleClassifierEnhancer

        isStopped, stopExecution
      • Methods inherited from class weka.classifiers.SingleClassifierEnhancer

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

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

        classifyInstance
    • Field Detail

      • m_Remove

        protected weka.filters.unsupervised.attribute.Remove m_Remove
        The filter for removing sample ID/database ID.
      • m_CanAbstain

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

      • SpectrumClassifier

        public SpectrumClassifier()
        Default constructor.
    • Method Detail

      • globalInfo

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

        protected String defaultClassifierString()
        String describing default classifier.
        Overrides:
        defaultClassifierString in class weka.classifiers.SingleClassifierEnhancer
        Returns:
        the default classifier classname
      • getCapabilities

        public weka.core.Capabilities getCapabilities()
        Returns default capabilities of the classifier.
        Specified by:
        getCapabilities in interface weka.core.CapabilitiesHandler
        Specified by:
        getCapabilities in interface weka.classifiers.Classifier
        Overrides:
        getCapabilities in class weka.classifiers.SingleClassifierEnhancer
        Returns:
        the capabilities of this classifier
      • implementsMoreEfficientBatchPrediction

        public boolean implementsMoreEfficientBatchPrediction()
        Return true if this classifier can generate batch predictions in an efficient manner. Default implementation here returns false. Subclasses to override as appropriate.
        Specified by:
        implementsMoreEfficientBatchPrediction in interface weka.core.BatchPredictor
        Overrides:
        implementsMoreEfficientBatchPrediction in class weka.classifiers.AbstractClassifier
        Returns:
        true if this classifier can generate batch predictions in an efficient manner.
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Build the classifier on the filtered data.
        Specified by:
        buildClassifier in interface weka.classifiers.Classifier
        Parameters:
        data - the training data
        Throws:
        Exception - if the classifier could not be built successfully
      • distributionForInstance

        public double[] distributionForInstance​(weka.core.Instance instance)
                                         throws Exception
        Classifies a given instance after filtering.
        Specified by:
        distributionForInstance in interface weka.classifiers.Classifier
        Overrides:
        distributionForInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        instance - the instance to be classified
        Returns:
        the class distribution for the given instance
        Throws:
        Exception - if instance could not be classified successfully
      • distributionsForInstances

        public double[][] distributionsForInstances​(weka.core.Instances insts)
                                             throws Exception
        Batch scoring method
        Specified by:
        distributionsForInstances in interface weka.core.BatchPredictor
        Overrides:
        distributionsForInstances in class weka.classifiers.AbstractClassifier
        Parameters:
        insts - the instances to get predictions for
        Returns:
        an array of probability distributions, one for each instance
        Throws:
        Exception - if a problem occurs
      • canAbstain

        public boolean canAbstain()
        Whether abstaining is possible, e.g., used in meta-classifiers.
        Specified by:
        canAbstain in interface weka.classifiers.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 weka.classifiers.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 weka.classifiers.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()
        Output a representation of this classifier
        Overrides:
        toString in class Object
        Returns:
        a representation of this classifier
      • 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
      • main

        public static void main​(String[] args)
        Main method for executing this classifier.
        Parameters:
        args - the commandline options, use -h for help