PolynomialCorrection#
- class chemotools.baseline.PolynomialCorrection(order: int = 1, indices: list | None = None)[源代码]
基类:
TransformerMixin,OneToOneFeatureMixin,BaseEstimatorA transformer that subtracts a polynomial baseline from the input data. The polynomial is fitted to the points in the spectrum specified by the indices parameter.
- 参数:
order (int, optional, default=1) -- The order of the polynomial to fit to the baseline. Defaults to 1.
indices (list, optional, default=None) -- The indices of the points in the spectrum to fit the polynomial to. Defaults to None, which fits the polynomial to all points in the spectrum (equivalent to detrend).
- 变量:
示例
>>> from chemotools.baseline import PolynomialCorrection >>> from chemotools.datasets import load_fermentation_train >>> # Load sample data >>> X, _ = load_fermentation_train() >>> # Instantiate the transformer >>> transformer = PolynomialCorrection( ... order=2, indices=[0, 100, 200, 300, 400, 500] ... ) PolynomialCorrection() >>> transformer.fit(X) >>> # Generate baseline-corrected data >>> X_corrected = transformer.transform(X)
- fit(X: ndarray, y=None) PolynomialCorrection[源代码]
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.
- 返回类型:
PolynomialCorrection
- transform(X: ndarray, y=None) ndarray[源代码]
Transform the input data by subtracting the polynomial baseline.
- 参数:
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)