MeanFilter#
- class chemotools.smooth.MeanFilter(window_size: int = 3, mode='nearest')[source]
Bases:
TransformerMixin,OneToOneFeatureMixin,BaseEstimatorA transformer that calculates the mean filter of the input data.
- Parameters:
- Variables:
n_features_in (int) – The number of features in the training data.
Examples
>>> 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[source]
Fit the transformer to the input data.
- Parameters:
X (np.ndarray of shape (n_samples, n_features)) – The input data to fit the transformer to.
y (None) – Ignored to align with API.
- Returns:
self – The fitted transformer.
- Return type:
MeanFilter
- transform(X: ndarray, y=None) ndarray[source]
Transform the input data by calculating the mean filter.
- Parameters:
X (np.ndarray of shape (n_samples, n_features)) – The input data to transform.
y (None) – Ignored to align with API.
- Returns:
X_transformed – The transformed data.
- Return type:
np.ndarray of shape (n_samples, n_features)