Class LWLSynchroPrefilter

  • All Implemented Interfaces:
    Serializable, Cloneable, 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 LWLSynchroPrefilter
    extends weka.classifiers.lazy.LWL
    implements ThreadSafeClassifier
    Locally weighted learning. Uses an instance-based algorithm to assign instance weights which are then used by a specified WeightedInstancesHandler.
    Can do classification (e.g. using naive Bayes) or regression (e.g. using linear regression).

    For more info, see

    Eibe Frank, Mark Hall, Bernhard Pfahringer: Locally Weighted Naive Bayes. In: 19th Conference in Uncertainty in Artificial Intelligence, 249-256, 2003.

    C. Atkeson, A. Moore, S. Schaal (1996). Locally weighted learning. AI Review..

    BibTeX:
     @inproceedings{Frank2003,
        author = {Eibe Frank and Mark Hall and Bernhard Pfahringer},
        booktitle = {19th Conference in Uncertainty in Artificial Intelligence},
        pages = {249-256},
        publisher = {Morgan Kaufmann},
        title = {Locally Weighted Naive Bayes},
        year = {2003}
     }
    
     @article{Atkeson1996,
        author = {C. Atkeson and A. Moore and S. Schaal},
        journal = {AI Review},
        title = {Locally weighted learning},
        year = {1996}
     }
     


    Valid options are:

     -no-update
      Suppresses the update of the nearest neighbor search (nns)
      algorithm with the data that is to be classified.
     (default: nns gets updated).
     
     -A
      The nearest neighbour search algorithm to use (default: weka.core.neighboursearch.LinearNNSearch).
     
     -K <number of neighbours>
      Set the number of neighbours used to set the kernel bandwidth.
      (default all)
     -U <number of weighting method>
      Set the weighting kernel shape to use. 0=Linear, 1=Epanechnikov,
      2=Tricube, 3=Inverse, 4=Gaussian.
      (default 0 = Linear)
     -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.GaussianProcesses)
     Options specific to classifier weka.classifiers.functions.GaussianProcesses:
     
     -D
      If set, classifier is run in debug mode and
      may output additional info to the console
     -L <double>
      Level of Gaussian Noise wrt transformed target. (default 1)
     -N
      Whether to 0=normalize/1=standardize/2=neither. (default 0=normalize)
     -K <classname and parameters>
      The Kernel to use.
      (default: weka.classifiers.functions.supportVector.PolyKernel)
     Options specific to kernel weka.classifiers.functions.supportVector.PolyKernel:
     
     -D
      Enables debugging output (if available) to be printed.
      (default: off)
     -no-checks
      Turns off all checks - use with caution!
      (default: checks on)
     -C <num>
      The size of the cache (a prime number), 0 for full cache and
      -1 to turn it off.
      (default: 250007)
     -E <num>
      The Exponent to use.
      (default: 1.0)
     -L
      Use lower-order terms.
      (default: no)
    Note: the build(Instance) needs manual syncing with the original WEKA classifier (distributionForInstance(Instance) method).
    Version:
    $Revision: 12986 $
    Author:
    Len Trigg (trigg@cs.waikato.ac.nz), Eibe Frank (eibe@cs.waikato.ac.nz), Ashraf M. Kibriya (amk14[at-the-rate]cs[dot]waikato[dot]ac[dot]nz)
    See Also:
    LWL.distributionForInstance(Instance), Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected weka.filters.unsupervised.attribute.AddID m_addId  
      protected weka.core.Instances m_filtered  
      protected int m_IndexOfID  
      protected weka.core.neighboursearch.NearestNeighbourSearch m_ModifiedSearchMethod  
      protected boolean m_NoUpdate
      whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
      protected weka.core.Instances m_original  
      protected weka.filters.Filter m_PreFilter  
      protected boolean m_run  
      • 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
      LWLSynchroPrefilter()
      Initializes the classifier.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void build​(weka.core.Instance instance)
      Builds the classifier.
      protected String defaultClassifierString()
      Default classifier classname.
      double[] distributionForInstance​(weka.core.Instance instance)
      Calculates the class membership probabilities for the given test instance.
      String filterTipText()  
      weka.filters.Filter getFilter()  
      protected String getFilterSpec()  
      boolean getNoUpdate()
      Returns whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
      String[] getOptions()
      Gets the current settings of the classifier.
      String getRevision()
      Returns the revision string.
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      static void main​(String[] argv)
      Main method for testing this class.
      String noUpdateTipText()
      Returns the tip text for this property.
      void setFilter​(weka.filters.Filter filter)  
      void setNoUpdate​(boolean value)
      Sets whether to suppress updating the nearest-neighbor search algorithm when making predictions.
      void setOptions​(String[] options)
      Parses a given list of options.
      protected void setUp​(weka.core.Instances data)  
      String toString()
      Returns a description of this classifier.
      • Methods inherited from class weka.classifiers.lazy.LWL

        buildClassifier, enumerateMeasures, getCapabilities, getKNN, getMeasure, getNearestNeighbourSearchAlgorithm, getTechnicalInformation, getWeightingKernel, globalInfo, 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

        buildClassifier, classifyInstance, getCapabilities
    • Field Detail

      • m_NoUpdate

        protected boolean m_NoUpdate
        whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
      • m_PreFilter

        protected weka.filters.Filter m_PreFilter
      • m_filtered

        protected weka.core.Instances m_filtered
      • m_original

        protected weka.core.Instances m_original
      • m_run

        protected boolean m_run
      • m_addId

        protected weka.filters.unsupervised.attribute.AddID m_addId
      • m_ModifiedSearchMethod

        protected weka.core.neighboursearch.NearestNeighbourSearch m_ModifiedSearchMethod
      • m_IndexOfID

        protected int m_IndexOfID
    • Constructor Detail

      • LWLSynchroPrefilter

        public LWLSynchroPrefilter()
        Initializes the classifier.
    • Method Detail

      • setUp

        protected void setUp​(weka.core.Instances data)
                      throws Exception
        Throws:
        Exception
      • defaultClassifierString

        protected String defaultClassifierString()
        Default classifier classname.
        Overrides:
        defaultClassifierString in class weka.classifiers.lazy.LWL
        Returns:
        the classname
      • filterTipText

        public String filterTipText()
      • setFilter

        public void setFilter​(weka.filters.Filter filter)
      • getFilter

        public weka.filters.Filter getFilter()
      • getFilterSpec

        protected String getFilterSpec()
      • 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.lazy.LWL
        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:

         -no-update
          Suppresses the update of the nearest neighbor search (nns)
          algorithm with the data that is to be classified.
         (default: nns gets updated).
         
         -A
          The nearest neighbour search algorithm to use (default: weka.core.neighboursearch.LinearNNSearch).
         
         -K <number of neighbours>
          Set the number of neighbours used to set the kernel bandwidth.
          (default all)
         -U <number of weighting method>
          Set the weighting kernel shape to use. 0=Linear, 1=Epanechnikov,
          2=Tricube, 3=Inverse, 4=Gaussian.
          (default 0 = Linear)
         -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.GaussianProcesses)
         Options specific to classifier weka.classifiers.functions.GaussianProcesses:
         
         -D
          If set, classifier is run in debug mode and
          may output additional info to the console
         -L <double>
          Level of Gaussian Noise wrt transformed target. (default 1)
         -N
          Whether to 0=normalize/1=standardize/2=neither. (default 0=normalize)
         -K <classname and parameters>
          The Kernel to use.
          (default: weka.classifiers.functions.supportVector.PolyKernel)
         Options specific to kernel weka.classifiers.functions.supportVector.PolyKernel:
         
         -D
          Enables debugging output (if available) to be printed.
          (default: off)
         -no-checks
          Turns off all checks - use with caution!
          (default: checks on)
         -C <num>
          The size of the cache (a prime number), 0 for full cache and
          -1 to turn it off.
          (default: 250007)
         -E <num>
          The Exponent to use.
          (default: 1.0)
         -L
          Use lower-order terms.
          (default: no)
        Specified by:
        setOptions in interface weka.core.OptionHandler
        Overrides:
        setOptions in class weka.classifiers.lazy.LWL
        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.lazy.LWL
        Returns:
        an array of strings suitable for passing to setOptions
      • noUpdateTipText

        public String noUpdateTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • setNoUpdate

        public void setNoUpdate​(boolean value)
        Sets whether to suppress updating the nearest-neighbor search algorithm when making predictions.
        Parameters:
        value - if true then no update happens.
      • getNoUpdate

        public boolean getNoUpdate()
        Returns whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
        Returns:
        true if the update is suppressed
      • build

        protected void build​(weka.core.Instance instance)
                      throws Exception
        Builds the classifier.

        Note: needs manual syncing with the distributionForInstance method of the original WEKA classifier.
        Parameters:
        instance - the instance to make prediction for
        Throws:
        Exception - if build fails
        See Also:
        LWL.distributionForInstance(Instance)
      • distributionForInstance

        public double[] distributionForInstance​(weka.core.Instance instance)
                                         throws Exception
        Calculates the class membership probabilities for the given test instance.
        Specified by:
        distributionForInstance in interface weka.classifiers.Classifier
        Overrides:
        distributionForInstance in class weka.classifiers.lazy.LWL
        Parameters:
        instance - the instance to be classified
        Returns:
        predicted class probability distribution
        Throws:
        Exception - if distribution can't be computed successfully
      • toString

        public String toString()
        Returns a description of this classifier.
        Overrides:
        toString in class weka.classifiers.lazy.LWL
        Returns:
        a description of this classifier as a string.
      • getRevision

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

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