GaussianBroadening#

class chemotools.augmentation.GaussianBroadening(sigma: float = 1.0, mode: Literal['reflect', 'constant', 'nearest', 'mirror', 'wrap'] = 'reflect', pad_value: float = 0.0, random_state: int | None = None, truncate: float = 4.0)[source]

Bases: TransformerMixin, OneToOneFeatureMixin, BaseEstimator

Transform spectral data by broadening peaks using Gaussian convolution.

This transformer applies Gaussian smoothing to broaden peaks in spectral data. For each signal, a random sigma is chosen between 0 and the specified sigma value.

Parameters:
  • sigma (float, default=1.0) – Maximum standard deviation for the Gaussian kernel. The actual sigma used will be randomly chosen between 0 and this value.

  • mode ({'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, default='reflect') – The mode parameter determines how the input array is extended when the filter overlaps a border. Default is ‘reflect’.

  • pad_value (float, default=0.0) – Value to fill past edges of input if mode is ‘constant’.

  • random_state (int, optional, default=None) – Random state for reproducible sigma selection.

  • truncate (float, default=4.0) – Truncate the filter at this many standard deviations. Larger values increase computation time but improve accuracy.

Examples

>>> from chemotools.augmentation import GaussianBroadening
>>> from chemotools.datasets import load_fermentation_train
>>> # Load sample data
>>> X, _ = load_fermentation_train()
>>> # Instantiate the transformer
>>> transformer = GaussianBroadening(sigma=2.0, mode="reflect")
GaussianBroadening()
>>> transformer.fit(X)
>>> # Generate broadened data
>>> X_broadened = transformer.transform(X)
fit(X: ndarray, y=None) GaussianBroadening[source]

Fit the transformer to the data (in this case, only validates input).

Parameters:
  • X (np.ndarray of shape (n_samples, n_features)) – Input data to validate.

  • y (None) – Ignored.

Returns:

self – The fitted transformer.

Return type:

GaussianBroadening

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

Apply Gaussian broadening to the input data.

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

  • y (None) – Ignored.

Returns:

X_transformed – The transformed data with broadened peaks.

Return type:

np.ndarray of shape (n_samples, n_features)