SpectrumScale#

class chemotools.augmentation.SpectrumScale(scale: float = 0.0, random_state: int | None = None)[source]

Bases: TransformerMixin, OneToOneFeatureMixin, BaseEstimator

Scales the data by a value drawn from the uniform distribution centered around 1.0.

Parameters:
  • scale (float, default=0.0) – Range of the uniform distribution to draw the scaling factor from.

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

Examples

>>> from chemotools.augmentation import SpectrumScale
>>> from chemotools.datasets import load_fermentation_train
>>> # Load sample data
>>> X, _ = load_fermentation_train()
>>> # Instantiate the transformer
>>> transformer = SpectrumScale(scale=0.1)
SpectrumScale()
>>> transformer.fit(X)
>>> # Generate scaled data
>>> X_scaled = transformer.transform(X)
fit(X: ndarray, y=None) SpectrumScale[source]

Fit the transformer to the input data.

Parameters:
  • X (np.ndarray of shape (n_samples, n_features)) – The input data to fit the transformer to.

  • y (None) – Ignored.

Returns:

self – The fitted transformer.

Return type:

SpectrumScale

transform(X: ndarray, y=None) ndarray[source]

Transform the input data by scaling the spectrum.

Parameters:
  • X (np.ndarray of shape (n_samples, n_features)) – The input data to transform.

  • y (None) – Ignored.

Returns:

X_transformed – The transformed data.

Return type:

np.ndarray of shape (n_samples, n_features)