SubtractReference#

class chemotools.baseline.SubtractReference(reference: ndarray | None = None)[ソース]

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

A transformer that subtracts a reference spectrum from the input data.

パラメータ:

reference (np.ndarray, optional, default=None) -- The reference spectrum to subtract from the input data. If None, the original spectrum is returned.

変数:
  • n_features_in (int) -- The number of features in the input data.

  • reference (np.ndarray) -- The reference spectrum to subtract from the input data if the reference parameter is not None.

サンプル

>>> from chemotools.baseline import SubtractReference
>>> from chemotools.datasets import load_fermentation_train
>>> # Load sample data
>>> X, _ = load_fermentation_train()
>>> # Convert X to a numpy array
>>> X = np.array(X)
>>> # Instantiate the transformer with a reference spectrum
>>> reference = X[0]
>>> transformer = SubtractReference(reference=reference)
SubtractReference()
>>> transformer.fit(X)
>>> # Generate baseline-corrected data
>>> X_corrected = transformer.transform(X)
fit(X: ndarray, y=None) SubtractReference[ソース]

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.

戻り値の型:

SubtractReference

transform(X: ndarray, y=None) ndarray[ソース]

Transform the input data by subtracting the reference spectrum.

パラメータ:
  • 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)