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')[ソース]
ベースクラス:
_BaseFIRFilterA transformer that calculates the Savitzky-Golay filter of the input data.
- パラメータ:
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".
- 変数:
n_features_in (int) -- The number of features in the training data.
サンプル
>>> 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[ソース]
Fit the Savitzky-Golay filter to the data.
- パラメータ:
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.
- 戻り値:
self -- The fitted transformer.
- 戻り値の型:
SavitzkyGolayFilter
- transform(X: ndarray, y: ndarray | None = None) ndarray[ソース]
Transform the input data by applying the Savitzky-Golay filter.
- パラメータ:
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)