LinearCorrection#

class chemotools.baseline.LinearCorrection[源代码]

基类:TransformerMixin, OneToOneFeatureMixin, BaseEstimator

A transformer that corrects a baseline by subtracting a linear baseline through the initial and final points of the spectrum.

变量:

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

示例

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

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.

返回类型:

LinearCorrection

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

Transform the input data by subtracting the constant baseline value.

参数:
  • 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)