MeanFilter#
- class chemotools.smooth.MeanFilter(window_length: int = 3, mode='nearest', window_size='deprecated')[源代码]
基类:
TransformerMixin,OneToOneFeatureMixin,BaseEstimatorA transformer that calculates the mean filter of the input data.
- 参数:
window_length (int, optional, default=3) -- The size of the window to use for the mean filter. Must be odd. Default is 3.
mode (str, optional, default="nearest") -- The mode to use for the mean filter. Can be "nearest", "constant", "reflect", "wrap", "mirror" or "interp". Default is "nearest".
window_size (int, optional) -- Deprecated alias for
window_length.
- 变量:
n_features_in (int) -- The number of features in the training data.
示例
>>> from chemotools.datasets import load_fermentation_train >>> from chemotools.smooth import MeanFilter >>> # Load sample data >>> X, _ = load_fermentation_train() >>> # Initialize MeanFilter >>> mf = MeanFilter() MeanFilter() >>> # Fit and transform the data >>> X_smoothed = mf.fit_transform(X)
- fit(X: ndarray, y=None) MeanFilter[源代码]
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.
- 返回类型:
MeanFilter
- transform(X: ndarray, y=None) ndarray[源代码]
Transform the input data by calculating the mean 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)