Class SavitzkyGolay2

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

    public class SavitzkyGolay2
    extends weka.filters.SimpleStreamFilter
    implements weka.core.TechnicalInformationHandler, weka.filters.UnsupervisedFilter
    A filter that applies Savitzky-Golay smoothing.
    If a class attribute is present this will not be touched and moved to the end.

    For more information see:

    A. Savitzky, Marcel J.E. Golay (1964). Smoothing and Differentiation of Data by Simplified Least Squares Procedures. Analytical Chemistry. 36:1627-1639.

    William H. Press, Saul A. Teukolsky, William T. Vetterling, Brian P. Flannery (1992). Savitzky-Golay Smoothing Filters.

    BibTeX:
     @article{Savitzky1964,
        author = {A. Savitzky and Marcel J.E. Golay},
        journal = {Analytical Chemistry},
        pages = {1627-1639},
        title = {Smoothing and Differentiation of Data by Simplified Least Squares Procedures},
        volume = {36},
        year = {1964},
        HTTP = {http://dx.doi.org/10.1021/ac60214a047}
     }
    
     @inbook{Press1992,
        author = {William H. Press and Saul A. Teukolsky and William T. Vetterling and Brian P. Flannery},
        chapter = {14.8},
        edition = {Second},
        pages = {650-655},
        publisher = {Cambridge University Press},
        series = {Numerical Recipes in C},
        title = {Savitzky-Golay Smoothing Filters},
        year = {1992},
        PDF = {http://www.nrbook.com/a/bookcpdf/c14-8.pdf}
     }
     


    Valid options are:

     -left <int>
      The number of points to the left (>= 0).
      (default: 3)
     -right <int>
      The number of points to the right (>= 0).
      (default: 3)
     -polynomial <int>
      The polynomial order (>= 2).
      (default: 2)
     -derivative <int>
      The order of the derivative (>= 0).
      (default: 1)
     -keep-attribute-names
      Whether to keep the original attribute names or use new ones ('att-XYZ').
      (default: don't keep)
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected double[] m_Coefficients
      the calculated coefficients.
      protected int m_DerivativeOrder
      the order of the derivative.
      protected boolean m_KeepAttributeNames
      whether to keep the original attribute names.
      protected int m_NumPoints
      the number of points to the left of a data point.
      protected int m_PolynomialOrder
      the polynomial order.
      • Fields inherited from class weka.filters.Filter

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

      Constructors 
      Constructor Description
      SavitzkyGolay2()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String derivativeOrderTipText()
      Returns the tip text for this property.
      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 getDerivativeOrder()
      Returns the order of the derivative.
      boolean getKeepAttributeNames()
      Returns whether to keep the original attribute names.
      int getNumPoints()
      Returns the number of points to the left of a data point.
      String[] getOptions()
      Gets the current settings of the filter.
      int getPolynomialOrder()
      Returns the polynominal order.
      String getRevision()
      Returns the revision string.
      weka.core.TechnicalInformation getTechnicalInformation()
      Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
      String globalInfo()
      Returns a string describing this classifier.
      String keepAttributeNamesTipText()
      Returns the tip text for this property.
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      static void main​(String[] args)
      Main method for testing this class.
      String numPointsTipText()
      Returns the tip text for this property.
      String polynomialOrderTipText()
      Returns the tip text for this property.
      protected weka.core.Instance process​(weka.core.Instance instance)
      processes the given instance (may change the provided instance) and returns the modified version.
      protected void reset()
      Resets the filter.
      void setDerivativeOrder​(int value)
      Sets the order of the derivative.
      void setKeepAttributeNames​(boolean value)
      Sets whether to keep the original attribute names.
      void setNumPoints​(int value)
      Sets the number of points to the left of a data point.
      void setOptions​(String[] options)
      Parses a list of options for this object.
      void setPolynomialOrder​(int value)
      Sets the polynomial order.
      • Methods inherited from class weka.filters.SimpleStreamFilter

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

        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_PolynomialOrder

        protected int m_PolynomialOrder
        the polynomial order.
      • m_DerivativeOrder

        protected int m_DerivativeOrder
        the order of the derivative.
      • m_NumPoints

        protected int m_NumPoints
        the number of points to the left of a data point.
      • m_KeepAttributeNames

        protected boolean m_KeepAttributeNames
        whether to keep the original attribute names.
      • m_Coefficients

        protected double[] m_Coefficients
        the calculated coefficients.
    • Constructor Detail

      • SavitzkyGolay2

        public SavitzkyGolay2()
    • 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
      • getTechnicalInformation

        public weka.core.TechnicalInformation getTechnicalInformation()
        Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
        Specified by:
        getTechnicalInformation in interface weka.core.TechnicalInformationHandler
        Returns:
        the technical information about this class
      • listOptions

        public Enumeration 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 list of options for this object. Also resets the state of the filter (this reset doesn't affect the 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
        See Also:
        reset()
      • getOptions

        public String[] getOptions()
        Gets the current settings of the filter.
        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
      • reset

        protected void reset()
        Resets the filter.
        Overrides:
        reset in class weka.filters.SimpleFilter
      • setPolynomialOrder

        public void setPolynomialOrder​(int value)
        Sets the polynomial order.
        Parameters:
        value - the order
      • getPolynomialOrder

        public int getPolynomialOrder()
        Returns the polynominal order.
        Returns:
        the order
      • polynomialOrderTipText

        public String polynomialOrderTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setDerivativeOrder

        public void setDerivativeOrder​(int value)
        Sets the order of the derivative.
        Parameters:
        value - the order
      • getDerivativeOrder

        public int getDerivativeOrder()
        Returns the order of the derivative.
        Returns:
        the order
      • derivativeOrderTipText

        public String derivativeOrderTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setNumPoints

        public void setNumPoints​(int value)
        Sets the number of points to the left of a data point.
        Parameters:
        value - the number of points
      • getNumPoints

        public int getNumPoints()
        Returns the number of points to the left of a data point.
        Returns:
        the number of points
      • numPointsTipText

        public String numPointsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setKeepAttributeNames

        public void setKeepAttributeNames​(boolean value)
        Sets whether to keep the original attribute names.
        Parameters:
        value - true if to keep
      • getKeepAttributeNames

        public boolean getKeepAttributeNames()
        Returns whether to keep the original attribute names.
        Returns:
        true if to keep
      • keepAttributeNamesTipText

        public String keepAttributeNamesTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getCapabilities

        public weka.core.Capabilities getCapabilities()
        Returns the Capabilities of this filter. Derived filters have to override this method to enable capabilities.
        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. In case the output format cannot be returned immediately, i.e., hasImmediateOutputFormat() returns false, then this method will called from batchFinished() after the call of preprocess(Instances), in which, e.g., statistics for the actual processing step can be gathered.
        Specified by:
        determineOutputFormat in class weka.filters.SimpleStreamFilter
        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.Instance process​(weka.core.Instance instance)
                                      throws Exception
        processes the given instance (may change the provided instance) and returns the modified version.
        Specified by:
        process in class weka.filters.SimpleStreamFilter
        Parameters:
        instance - the instance 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