ConstantBaselineCorrection#

class chemotools.baseline.ConstantBaselineCorrection(start: int = 0, end: int = 1, x_axis: ndarray | None = None, wavenumbers='deprecated')[ソース]

ベースクラス: TransformerMixin, OneToOneFeatureMixin, BaseEstimator

A transformer that corrects a baseline by subtracting a constant value. The constant value is taken by the mean of the features between the start and end indices. This is a common preprocessing technique for UV-Vis spectra.

パラメータ:
  • start (int, optional, default=0) -- The index of the first feature to use for the baseline correction.

  • end (int, optional, default=1) -- The index of the last feature to use for the baseline correction.

  • x_axis (np.ndarray, optional, default=None) -- The x-axis values corresponding to each feature in the input data.

  • wavenumbers (np.ndarray, optional) -- Deprecated alias for x_axis.

変数:
  • start_index (int) -- The index of the start of the range. It is 0 if the wavenumbers are not provided.

  • end_index (int) -- The index of the end of the range. It is 1 if the wavenumbers are not provided.

サンプル

>>> from chemotools.baseline import ConstantBaselineCorrection
>>> from chemotools.datasets import load_fermentation_train
>>> # Load sample data
>>> X, _ = load_fermentation_train()
>>> # Instantiate the transformer
>>> transformer = ConstantBaselineCorrection(start=0, end=1)
>>> transformer.fit(X)
>>> # Generate baseline-corrected data
>>> X_corrected = transformer.transform(X)
fit(X: ndarray, y=None) ConstantBaselineCorrection[ソース]

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.

戻り値の型:

ConstantBaselineCorrection

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 input data.

戻り値の型:

np.ndarray of shape (n_samples, n_features)