Class AccumulatedLWLWeights

  • All Implemented Interfaces:
    Serializable, weka.core.CapabilitiesHandler, weka.core.CapabilitiesIgnorer, weka.core.CommandlineRunnable, weka.core.OptionHandler, weka.core.RevisionHandler, weka.core.WeightedInstancesHandler, weka.filters.UnsupervisedFilter

    public class AccumulatedLWLWeights
    extends weka.filters.SimpleBatchFilter
    implements weka.filters.UnsupervisedFilter, weka.core.WeightedInstancesHandler
    Generates an LWL-like dataset for each instance of the data from the first batch and accumulate these weights. Once accumulated, the weights get normalized to be within the range of [0;1] and the output dataset accordingly adjusted.

    Valid options are:

     -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)
     -no-update
      Suppresses the update of the nearest neighbor search (nns)
      algorithm with the data that is to be classified.
     (default: nns gets updated).
     
     -row-finder-enabled
      Whether to use a row finder to limit the instances for which  to determine the LWL neighborhoods for.
      (default off)
     -row-finder <classname + options>
      The row finder scheme to use for limiting the instances to  determine the LWL neighborhoods for.
      (default: adams.data.weka.rowfinder.NullFinder)
     -output-debug-info
      If set, filter is run in debug mode and
      may output additional info to the console
     -do-not-check-capabilities
      If set, filter capabilities are not checked before filter is built
      (use with caution).
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int m_kNN
      The number of neighbours used to select the kernel bandwidth.
      protected weka.core.neighboursearch.NearestNeighbourSearch m_NNSearch
      The nearest neighbour search algorithm to use.
      protected boolean m_NoUpdate
      whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
      protected RowFinder m_RowFinder
      the row finder to use if enabled.
      protected boolean m_RowFinderEnabled
      whether to use the row finder.
      protected int m_WeightKernel
      The weighting kernel method currently selected.
      • Fields inherited from class weka.filters.Filter

        m_Debug, m_DoNotCheckCapabilities, m_FirstBatchDone, m_InputRelAtts, m_InputStringAtts, m_NewBatch, m_OutputRelAtts, m_OutputStringAtts
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected weka.core.Instances determineOutputFormat​(weka.core.Instances inputFormat)
      Determines the output format based on the input format and returns this.
      weka.core.Capabilities getCapabilities()
      Returns the Capabilities of this filter.
      int getKNN()
      Gets the number of neighbours used for kernel bandwidth setting.
      weka.core.neighboursearch.NearestNeighbourSearch getNearestNeighbourSearchAlgorithm()
      Returns the current nearestNeighbourSearch algorithm in use.
      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.
      RowFinder getRowFinder()
      Returns the row finder scheme.
      boolean getRowFinderEnabled()
      Returns whether to use the row finder.
      int getWeightingKernel()
      Gets the kernel weighting method to use.
      String globalInfo()
      Returns a string describing this classifier.
      String KNNTipText()
      Returns the tip text for this property.
      Enumeration<weka.core.Option> listOptions()
      Returns an enumeration describing the available options.
      static void main​(String[] args)
      Main method for testing this class.
      String nearestNeighbourSearchAlgorithmTipText()
      Returns the tip text for this property.
      String noUpdateTipText()
      Returns the tip text for this property.
      protected weka.core.Instances process​(weka.core.Instances instances)
      Processes the given data (may change the provided dataset) and returns the modified version.
      String rowFinderEnabledTipText()
      Returns the tip text for this property.
      String rowFinderTipText()
      Returns the tip text for this property.
      void setKNN​(int knn)
      Sets the number of neighbours used for kernel bandwidth setting.
      void setNearestNeighbourSearchAlgorithm​(weka.core.neighboursearch.NearestNeighbourSearch nearestNeighbourSearchAlgorithm)
      Sets the nearestNeighbourSearch algorithm to be used for finding nearest neighbour(s).
      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.
      void setRowFinder​(RowFinder value)
      Sets the row finder scheme.
      void setRowFinderEnabled​(boolean value)
      Sets the whether to use the row finder.
      void setWeightingKernel​(int kernel)
      Sets the kernel weighting method to use.
      String weightingKernelTipText()
      Returns the tip text for this property.
      • Methods inherited from class weka.filters.SimpleBatchFilter

        allowAccessToFullInputFormat, batchFinished, hasImmediateOutputFormat, input
      • Methods inherited from class weka.filters.SimpleFilter

        reset, setInputFormat
      • Methods inherited from class weka.filters.Filter

        batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, getCapabilities, getDebug, getDoNotCheckCapabilities, getInputFormat, getOutputFormat, initInputLocators, initOutputLocators, inputFormatPeek, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputFormatPeek, outputPeek, postExecution, preExecution, push, push, resetQueue, run, runFilter, setDebug, setDoNotCheckCapabilities, setOutputFormat, testInputFormat, toString, useFilter, wekaStaticWrapper
    • Field Detail

      • m_kNN

        protected int m_kNN
        The number of neighbours used to select the kernel bandwidth.
      • m_WeightKernel

        protected int m_WeightKernel
        The weighting kernel method currently selected.
      • m_NNSearch

        protected weka.core.neighboursearch.NearestNeighbourSearch m_NNSearch
        The nearest neighbour search algorithm to use. (Default: weka.core.neighboursearch.LinearNNSearch)
      • m_NoUpdate

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

        protected boolean m_RowFinderEnabled
        whether to use the row finder.
      • m_RowFinder

        protected RowFinder m_RowFinder
        the row finder to use if enabled.
    • Constructor Detail

      • AccumulatedLWLWeights

        public AccumulatedLWLWeights()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing this classifier.
        Specified by:
        globalInfo in class weka.filters.SimpleFilter
        Returns:
        a description of the classifier suitable for displaying in the explorer/experimenter gui
      • listOptions

        public Enumeration<weka.core.Option> listOptions()
        Returns an enumeration describing the available options.
        Specified by:
        listOptions in interface weka.core.OptionHandler
        Overrides:
        listOptions in class weka.filters.Filter
        Returns:
        an enumeration of all the available options.
      • setOptions

        public void setOptions​(String[] options)
                        throws Exception
        Parses a given list of options.
        Specified by:
        setOptions in interface weka.core.OptionHandler
        Overrides:
        setOptions in class weka.filters.Filter
        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.filters.Filter
        Returns:
        an array of strings suitable for passing to setOptions
      • setKNN

        public void setKNN​(int knn)
        Sets the number of neighbours used for kernel bandwidth setting. The bandwidth is taken as the distance to the kth neighbour.
        Parameters:
        knn - the number of neighbours included inside the kernel bandwidth, or 0 to specify using all neighbors.
      • getKNN

        public int getKNN()
        Gets the number of neighbours used for kernel bandwidth setting. The bandwidth is taken as the distance to the kth neighbour.
        Returns:
        the number of neighbours included inside the kernel bandwidth, or 0 for all neighbours
      • KNNTipText

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

        public void setWeightingKernel​(int kernel)
        Sets the kernel weighting method to use. Must be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT, other values are ignored.
        Parameters:
        kernel - the new kernel method to use. Must be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT.
      • getWeightingKernel

        public int getWeightingKernel()
        Gets the kernel weighting method to use.
        Returns:
        the new kernel method to use. Will be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT.
      • weightingKernelTipText

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

        public void setNearestNeighbourSearchAlgorithm​(weka.core.neighboursearch.NearestNeighbourSearch nearestNeighbourSearchAlgorithm)
        Sets the nearestNeighbourSearch algorithm to be used for finding nearest neighbour(s).
        Parameters:
        nearestNeighbourSearchAlgorithm - - The NearestNeighbourSearch class.
      • getNearestNeighbourSearchAlgorithm

        public weka.core.neighboursearch.NearestNeighbourSearch getNearestNeighbourSearchAlgorithm()
        Returns the current nearestNeighbourSearch algorithm in use.
        Returns:
        the NearestNeighbourSearch algorithm currently in use.
      • nearestNeighbourSearchAlgorithmTipText

        public String nearestNeighbourSearchAlgorithmTipText()
        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
      • 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
      • setRowFinderEnabled

        public void setRowFinderEnabled​(boolean value)
        Sets the whether to use the row finder.
        Parameters:
        value - true if to use the row finder
      • getRowFinderEnabled

        public boolean getRowFinderEnabled()
        Returns whether to use the row finder.
        Returns:
        true if to use the row finder
      • rowFinderEnabledTipText

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

        public void setRowFinder​(RowFinder value)
        Sets the row finder scheme.
        Parameters:
        value - the row finder scheme
      • getRowFinder

        public RowFinder getRowFinder()
        Returns the row finder scheme.
        Returns:
        the row finder
      • rowFinderTipText

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

        public weka.core.Capabilities getCapabilities()
        Returns the Capabilities of this filter.
        Specified by:
        getCapabilities in interface weka.core.CapabilitiesHandler
        Overrides:
        getCapabilities in class weka.filters.Filter
        Returns:
        the capabilities of this object
        See Also:
        Capabilities
      • determineOutputFormat

        protected weka.core.Instances determineOutputFormat​(weka.core.Instances inputFormat)
                                                     throws Exception
        Determines the output format based on the input format and returns this.
        Specified by:
        determineOutputFormat in class weka.filters.SimpleFilter
        Parameters:
        inputFormat - the input format to base the output format on
        Returns:
        the output format
        Throws:
        Exception - in case the determination goes wrong
      • process

        protected weka.core.Instances process​(weka.core.Instances instances)
                                       throws Exception
        Processes the given data (may change the provided dataset) and returns the modified version. This method is called in batchFinished().
        Specified by:
        process in class weka.filters.SimpleFilter
        Parameters:
        instances - the data to process
        Returns:
        the modified data
        Throws:
        Exception - in case the processing goes wrong
      • getRevision

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

        public static void main​(String[] args)
        Main method for testing this class.
        Parameters:
        args - should contain arguments to the filter: use -h for help