spectrochempy.MSCTransformerο
- class MSCTransformer(reference=None, dim='y')[source]ο
Multiplicative Scatter Correction (MSC) transformer.
Learns a reusable reference spectrum during
fit(). Duringtransform(), each observation in the dataset being transformed is locally regressed against that reference and corrected with \((x - a) / b\).inverse_transform()is not supported. The regression coefficients are local to each transformed dataset and are not safe reusable state.- Parameters:
- a_[source]ο
Intercepts of the per-observation regressions for the dataset passed to
fit(). These are diagnostics, not reusable transform state.- Type:
- b_[source]ο
Slopes of the per-observation regressions for the dataset passed to
fit(). These are diagnostics, not reusable transform state.- Type:
- Raises:
SpectroChemPyError β If the dataset is not 2-D, the reference or transform spectral geometry is incompatible, a spectrum has too few valid paired points, the effective reference is constant, the local slope is zero, or
inverse_transform()is requested.
Examples
>>> scaler = scp.MSCTransformer() >>> scaler.fit(train) >>> test_msc = scaler.transform(test)
See also
mscProcedural MSC function.
Methods Summary
fit(dataset)Learn parameters from dataset.
fit_transform(dataset)Fit to dataset, then transform it.
get_params([deep])Get the constructor parameters of this transformer.
inverse_transform(dataset)Reverse the learned transformation on dataset.
set_params(**params)Set constructor parameters on this transformer.
transform(dataset)Apply the learned transformation to dataset.
Methods Documentation
- fit(dataset)[source]ο
Learn parameters from dataset.
- Parameters:
dataset (
NDDataset) β Training data.- Returns:
self β The fitted instance.
- fit_transform(dataset)[source]ο
Fit to dataset, then transform it.
Equivalent to
self.fit(dataset).transform(dataset)but avoids an intermediate copy when possible.
- get_params(deep=True)[source]ο
Get the constructor parameters of this transformer.
- Parameters:
deep (
bool, optional, default:True) β Ignored. Present for compatibility with scikit-learn conventions.- Returns:
dictβ Mapping of parameter name -> current value.
Examples
>>> scaler = scp.AutoscaleTransformer(dim="y") >>> scaler.get_params() {'dim': 'y'}
- set_params(**params)[source]ο
Set constructor parameters on this transformer.
Returns
selfso that calls can be chained.- Parameters:
**params β Parameter names and values to update.
- Returns:
self
- Raises:
SpectroChemPyError β If a parameter name does not correspond to a constructor argument.
Examples
>>> scaler = scp.AutoscaleTransformer(dim="y") >>> scaler.set_params(dim="x") AutoscaleTransformer(dim='x')
Examples using spectrochempy.MSCTransformer