RubberbandCorrection#

class chemotools.baseline.RubberbandCorrection(n_jobs: int = 1)[源代码]

基类:DocLinkMixin, TransformerMixin, OneToOneFeatureMixin, BaseEstimator

A transformer that removes a baseline using the rubberband method.

The rubberband baseline is the lower convex hull of the spectrum — the set of straight-line segments a rubber band would form if stretched along the underside of the spectrum. The baseline is subtracted from each spectrum, leaving the peaks resting on a flat zero background.

The lower convex hull is computed with Andrew's monotone chain algorithm [1] [2] in feature-index space, so the feature axis (e.g. wavenumbers) is assumed to be sorted; even spacing is not required.

参数:

n_jobs (int, default=1) -- Number of parallel jobs used to process spectra independently during transform().

变量:

n_features_in (int) -- The number of features in the input data.

引用

示例

>>> from chemotools.baseline import RubberbandCorrection
>>> from chemotools.datasets import load_fermentation_train
>>> # Load sample data
>>> X, _ = load_fermentation_train()
>>> # Instantiate the transformer
>>> transformer = RubberbandCorrection()
RubberbandCorrection()
>>> transformer.fit(X)
>>> # Generate baseline-corrected data
>>> X_corrected = transformer.transform(X)
fit(X: ndarray, y=None) RubberbandCorrection[源代码]

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.

返回类型:

RubberbandCorrection

transform(X: ndarray, y=None) ndarray[源代码]

Transform the input data by subtracting the rubberband 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 baseline-corrected data.

返回类型:

np.ndarray of shape (n_samples, n_features)