SavitzkyGolay#
- class chemotools.derivative.SavitzkyGolay(window_length: int = 3, polyorder: int = 1, deriv: int = 1, mode: Literal['mirror', 'constant', 'nearest', 'wrap', 'interp'] = 'nearest', window_size='deprecated', polynomial_order='deprecated', derivate_order='deprecated')[源代码]
基类:
TransformerMixin,OneToOneFeatureMixin,BaseEstimatorA transformer that calculates the Savitzky-Golay derivative of the input data.
- 参数:
window_length (int, optional, default=3) -- The size of the window to use for the derivative calculation. Must be odd. Default is 3.
polyorder (int, optional, default=1) -- The order of the polynomial to use for the derivative calculation. Must be less than
window_length. Default is 1.deriv (int, optional, default=1) -- The order of the derivative to calculate. Default is 1.
window_size (int, optional) -- Deprecated alias for
window_length.polynomial_order (int, optional) -- Deprecated alias for
polyorder.derivate_order (int, optional) -- Deprecated alias for
deriv.mode (str, optional, default="nearest") -- The mode to use for the derivative calculation. Can be "nearest", "constant", "reflect", "wrap", "mirror" or "interp". Default is "nearest".
- 变量:
n_features_in (int) -- The number of features in the input data.
引用
- [1] Åsmund Rinnan, Frans van den Berg, Søren Balling Engelsen,
"Review of the most common pre-processing techniques for near-infrared spectra," TrAC Trends in Analytical Chemistry 28 (10) 1201-1222 (2009).
示例
>>> from chemotools.derivative import SavitzkyGolay >>> from chemotools.datasets import load_fermentation_train >>> # Load sample data >>> X, _ = load_fermentation_train() >>> # Instantiate the transformer >>> transformer = SavitzkyGolay(window_length=3, polyorder=1) SavitzkyGolay() >>> transformer.fit(X) >>> # Calculate Savitzky-Golay derivative >>> X_corrected = transformer.transform(X)
- fit(X: ndarray, y=None) SavitzkyGolay[源代码]
Fit the transformer to the input data.
- 参数:
X (np.ndarray of shape (n_samples, n_features)) -- The input data to fit the transformer to.
y (None) -- Ignored to align with API.
- 返回:
self -- The fitted transformer.
- 返回类型:
SavitzkyGolay
- transform(X: ndarray, y=None) ndarray[源代码]
Transform the input data by calculating the Savitzky-Golay derivative.
- 参数:
X (np.ndarray of shape (n_samples, n_features)) -- The input data to transform.
y (None) -- Ignored to align with API.
- 返回:
X_transformed -- The transformed data.
- 返回类型:
np.ndarray of shape (n_samples, n_features)