PointScaler#
- class chemotools.scale.PointScaler(point: int = 0, wavenumbers: ndarray | None = None)[source]
Bases:
TransformerMixin,OneToOneFeatureMixin,BaseEstimatorA transformer that scales the input data by the intensity value at a given point. The point can be specified by an index or by a wavenumber.
- Parameters:
point (int, optional, default=0) – The point to scale the data by. It can be an index or a wavenumber.
wavenumber (array-like, optional, default=None) – The wavenumbers of the input data. If not provided, the indices will be used instead. Default is None. If provided, the wavenumbers must be provided in ascending order.
- Variables:
Examples
>>> from chemotools.datasets import load_fermentation_train >>> from chemotools.scale import PointScaler >>> # Load sample data >>> X, _ = load_fermentation_train() >>> # Initialize PointScaler with point index >>> scaler = PointScaler(point=10) PointScaler(point=10, wavenumbers=None) >>> # Fit and transform the data >>> X_scaled = scaler.fit_transform(X)
- fit(X: ndarray, y=None) PointScaler[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 to align with API.
- Returns:
self – The fitted transformer.
- Return type:
PointScaler
- transform(X: ndarray, y=None) ndarray[source]
Transform the input data by scaling by the value at a given Point.
- Parameters:
X (np.ndarray of shape (n_samples, n_features)) – The input data to transform.
y (None) – Ignored to align with API.
- Returns:
X_transformed – The transformed data.
- Return type:
np.ndarray of shape (n_samples, n_features)