BaselineShift#

class chemotools.augmentation.BaselineShift(scale: float = 0.0, random_state: int | None = None)[源代码]

基类:TransformerMixin, OneToOneFeatureMixin, BaseEstimator

Adds a constant baseline to the data. The baseline is drawn from a one-sided uniform distribution between 0 and 0 + scale.

参数:
  • scale (float, default=0.0) -- Range of the uniform distribution to draw the baseline factor from.

  • random_state (int, default=None) -- The random state to use for the random number generator.

变量:

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

示例

>>> from chemotools.augmentation import BaselineShift
>>> from chemotools.datasets import load_fermentation_train
>>> # Load sample data
>>> X, _ = load_fermentation_train()
>>> # Instantiate the transformer
>>> transformer = BaselineShift(scale=0.1)
BaselineShift()
>>> transformer.fit(X)
>>> # Generate baseline-shifted data
>>> X_shifted = transformer.transform(X)
fit(X: ndarray, y=None) BaselineShift[源代码]

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.

返回:

self -- The fitted transformer.

返回类型:

BaselineShift

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

Transform the input data by adding a baseline to the spectrum.

参数:
  • X (np.ndarray of shape (n_samples, n_features)) -- The input data to transform.

  • y (None) -- Ignored.

返回:

X_transformed -- The transformed data.

返回类型:

np.ndarray of shape (n_samples, n_features)