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.UnsupervisedFilterA 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)-fix-att-count Whether to fix the number of generated attributes. (default: don't apply fix)
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected double[]m_Coefficientsthe calculated coefficients.protected intm_DerivativeOrderthe order of the derivative.protected booleanm_FixAttCountwhether to use corrected output.protected booleanm_KeepAttributeNameswhether to keep the original attribute names.protected intm_NumPointsthe number of points to the left of a data point.protected intm_PolynomialOrderthe polynomial order.
-
Constructor Summary
Constructors Constructor Description SavitzkyGolay2()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringderivativeOrderTipText()Returns the tip text for this property.protected weka.core.InstancesdetermineOutputFormat(weka.core.Instances inputFormat)Determines the output format based on the input format and returns this.StringfixAttCountTipText()Returns the tip text for this property.weka.core.CapabilitiesgetCapabilities()Returns the Capabilities of this filter.intgetDerivativeOrder()Returns the order of the derivative.booleangetFixAttCount()Returns whether to apply fix to generate correct number of attributes.booleangetKeepAttributeNames()Returns whether to keep the original attribute names.intgetNumPoints()Returns the number of points to the left of a data point.String[]getOptions()Gets the current settings of the filter.intgetPolynomialOrder()Returns the polynominal order.StringgetRevision()Returns the revision string.weka.core.TechnicalInformationgetTechnicalInformation()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.StringglobalInfo()Returns a string describing this classifier.StringkeepAttributeNamesTipText()Returns the tip text for this property.EnumerationlistOptions()Returns an enumeration describing the available options.static voidmain(String[] args)Main method for testing this class.StringnumPointsTipText()Returns the tip text for this property.StringpolynomialOrderTipText()Returns the tip text for this property.protected weka.core.Instanceprocess(weka.core.Instance instance)processes the given instance (may change the provided instance) and returns the modified version.protected weka.core.InstanceprocessCorrectAttCount(weka.core.Instance instance)processes the given instance (may change the provided instance) and returns the modified version.protected weka.core.InstanceprocessIncorrectAttCount(weka.core.Instance instance)processes the given instance (may change the provided instance) and returns the modified version.protected voidreset()Resets the filter.voidsetDerivativeOrder(int value)Sets the order of the derivative.voidsetFixAttCount(boolean value)Sets whether to apply fix to generate correct number of attributes.voidsetKeepAttributeNames(boolean value)Sets whether to keep the original attribute names.voidsetNumPoints(int value)Sets the number of points to the left of a data point.voidsetOptions(String[] options)Parses a list of options for this object.voidsetPolynomialOrder(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_FixAttCount
protected boolean m_FixAttCount
whether to use corrected output.
-
m_Coefficients
protected double[] m_Coefficients
the calculated coefficients.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing this classifier.- Specified by:
globalInfoin 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:
getTechnicalInformationin interfaceweka.core.TechnicalInformationHandler- Returns:
- the technical information about this class
-
listOptions
public Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceweka.core.OptionHandler- Overrides:
listOptionsin 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:
getOptionsin interfaceweka.core.OptionHandler- Overrides:
getOptionsin classweka.filters.Filter- Returns:
- an array of strings suitable for passing to setOptions
-
reset
protected void reset()
Resets the filter.- Overrides:
resetin 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.
-
setFixAttCount
public void setFixAttCount(boolean value)
Sets whether to apply fix to generate correct number of attributes.- Parameters:
value- true if to fix
-
getFixAttCount
public boolean getFixAttCount()
Returns whether to apply fix to generate correct number of attributes.- Returns:
- true if to fix
-
fixAttCountTipText
public String fixAttCountTipText()
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:
getCapabilitiesin interfaceweka.core.CapabilitiesHandler- Overrides:
getCapabilitiesin classweka.filters.Filter- Returns:
- the capabilities of this object
- See Also:
Capabilities
-
determineOutputFormat
protected weka.core.Instances determineOutputFormat(weka.core.Instances inputFormat) throws ExceptionDetermines 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:
determineOutputFormatin 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
-
processIncorrectAttCount
protected weka.core.Instance processIncorrectAttCount(weka.core.Instance instance) throws Exceptionprocesses the given instance (may change the provided instance) and returns the modified version.- Parameters:
instance- the instance to process- Returns:
- the modified data
- Throws:
Exception- in case the processing goes wrong
-
processCorrectAttCount
protected weka.core.Instance processCorrectAttCount(weka.core.Instance instance) throws Exceptionprocesses the given instance (may change the provided instance) and returns the modified version.- Parameters:
instance- the instance to process- Returns:
- the modified data
- Throws:
Exception- in case the processing goes wrong
-
process
protected weka.core.Instance process(weka.core.Instance instance) throws Exceptionprocesses the given instance (may change the provided instance) and returns the modified version.- Specified by:
processin 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:
getRevisionin interfaceweka.core.RevisionHandler- Overrides:
getRevisionin 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
-
-