IndexShift#
- class chemotools.augmentation.IndexShift(shift: int = 0, padding_mode: Literal['zeros', 'constant', 'wrap', 'extend', 'mirror', 'linear'] = 'linear', pad_value: float = 0.0, random_state: int | None = None)[fuente]
Bases:
TransformerMixin,OneToOneFeatureMixin,BaseEstimatorShift the spectrum a given number of indices between -shift and +shift drawn from a discrete uniform distribution.
- Parámetros:
shift (int, default=0) – Maximum number of indices by which the data is randomly shifted. The actual shift is a random integer between -shift and shift (inclusive).
padding_mode ({'zeros', 'constant', 'wrap', 'extend',) –
“mirror”, “linear”}, default=”linear” Specifies how to handle padding when shifting the data:
”zeros”: Pads with zeros.
”constant”: Pads with a constant value defined by pad_value.
”wrap”: Circular shift (wraps around).
”extend”: Extends using edge values.
”mirror”: Mirrors the signal.
”linear”: Uses linear regression to extrapolate values.
pad_value (float, default=0.0) – The value used for padding when padding_mode=”constant”.
random_state (int, optional, default=None) – The random seed for reproducibility.
- Variables:
n_features_in (int) – The number of features in the input data.
Ejemplos
>>> from chemotools.augmentation import IndexShift >>> from chemotools.datasets import load_fermentation_train >>> # Load sample data >>> X, _ = load_fermentation_train() >>> # Instantiate the transformer >>> transformer = IndexShift(shift=2, padding_mode="constant",) IndexShift() >>> transformer.fit(X) >>> # Generate shifted data >>> X_shifted = transformer.transform(X)
- fit(X: ndarray, y=None) IndexShift[fuente]
Fit the transformer to the input data.
- Parámetros:
X (np.ndarray of shape (n_samples, n_features)) – The input data to fit the transformer to.
y (None) – Ignored.
- Devuelve:
self – The fitted transformer.
- Tipo del valor devuelto:
IndexShift
- transform(X: ndarray, y=None) ndarray[fuente]
Transform the input data by shifting the spectrum.
- Parámetros:
X (np.ndarray of shape (n_samples, n_features)) – The input data to transform.
y (None) – Ignored.
- Devuelve:
X_transformed – The transformed data with the applied shifts.
- Tipo del valor devuelto:
np.ndarray of shape (n_samples, n_features)