SpectrumScale#

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

基类:TransformerMixin, OneToOneFeatureMixin, BaseEstimator

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

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

示例

>>> 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[源代码]

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.

返回类型:

SpectrumScale

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

Transform the input data by scaling 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)