CubicSplineCorrection#
- class chemotools.baseline.CubicSplineCorrection(indices: list | None = None)[source]
Bases:
TransformerMixin,OneToOneFeatureMixin,BaseEstimatorA transformer that corrects a baseline by subtracting a cubic spline through the points defined by the indices.
- Parameters:
indices (list, optional, default=None) – The indices of the features to use for the baseline correction. If None, the first and last indices will be used.
- Variables:
Examples
>>> from chemotools.baseline import CubicSplineCorrection >>> from chemotools.datasets import load_fermentation_train >>> # Load sample data >>> X, _ = load_fermentation_train() >>> # Instantiate the transformer >>> transformer = CubicSplineCorrection(indices=[0, 100, 200, 300, 400, 500]) CubicSplineCorrection(indices) >>> transformer.fit(X) >>> # Generate baseline-corrected data >>> X_corrected = transformer.transform(X)
- fit(X: ndarray, y=None) CubicSplineCorrection[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:
ConstantBaselineCorrection
- transform(X: ndarray, y=None) ndarray[source]
Transform the input data by subtracting the baseline.
- 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)