SavitzkyGolayFilter#
- class chemotools.smooth.SavitzkyGolayFilter(window_length: int = 3, polyorder: int = 1, mode: Literal['mirror', 'constant', 'nearest', 'wrap', 'interp'] = 'nearest', axis: int = 1, window_size='deprecated', polynomial_order='deprecated')[fuente]
Bases:
_BaseFIRFilterA transformer that calculates the Savitzky-Golay filter of the input data.
- Parámetros:
window_length (int, optional) – The size of the window to use for the Savitzky-Golay filter. Must be odd. Default is 3.
polyorder (int, optional) – The order of the polynomial to use for the Savitzky-Golay filter. Must be less than
window_length. Default is 1.window_size (int, optional) – Deprecated alias for
window_length.polynomial_order (int, optional) – Deprecated alias for
polyorder.mode (str, optional) – The mode to use for the Savitzky-Golay filter. Can be «nearest», «constant», «reflect», «wrap», «mirror» or «interp». Default is «nearest».
- Variables:
n_features_in (int) – The number of features in the training data.
Ejemplos
>>> from chemotools.datasets import load_fermentation_train >>> from chemotools.smooth import SavitzkyGolayFilter >>> # Load sample data >>> X, _ = load_fermentation_train() >>> # Initialize SavitzkyGolayFilter >>> sgf = SavitzkyGolayFilter() SavitzkyGolayFilter() >>> # Fit and transform the data >>> X_smoothed = sgf.fit_transform(X)
- fit(X: ndarray, y: ndarray | None = None) SavitzkyGolayFilter[fuente]
Fit the Savitzky-Golay filter to the data.
- Parámetros:
X (np.ndarray of shape (n_samples, n_features)) – The input data to fit the transformer.
y (Ignored) – Not used, present for API consistency by convention.
- Devuelve:
self – The fitted transformer.
- Tipo del valor devuelto:
SavitzkyGolayFilter
- transform(X: ndarray, y: ndarray | None = None) ndarray[fuente]
Transform the input data by applying the Savitzky-Golay filter.
- Parámetros:
X (np.ndarray of shape (n_samples, n_features)) – The input data to transform.
y (None) – Ignored to align with API.
- Devuelve:
X_transformed – The transformed data.
- Tipo del valor devuelto:
np.ndarray of shape (n_samples, n_features)