Class SavitzkyGolay2
- java.lang.Object
-
- weka.filters.Filter
-
- weka.filters.SimpleFilter
-
- weka.filters.SimpleStreamFilter
-
- weka.filters.unsupervised.attribute.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.
-
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.Filter
batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, getCapabilities, getCopyOfInputFormat, 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.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing this classifier.- Specified by:
globalInfo
in classweka.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 interfaceweka.core.TechnicalInformationHandler
- Returns:
- the technical information about this class
-
listOptions
public Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceweka.core.OptionHandler
- Overrides:
listOptions
in classweka.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).
-
getOptions
public String[] getOptions()
Gets the current settings of the filter.- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.filters.Filter
- Returns:
- an array of strings suitable for passing to setOptions
-
reset
protected void reset()
Resets the filter.- Overrides:
reset
in classweka.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 interfaceweka.core.CapabilitiesHandler
- Overrides:
getCapabilities
in classweka.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 classweka.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 classweka.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 interfaceweka.core.RevisionHandler
- Overrides:
getRevision
in classweka.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
-
-