spectrochempy.LogTransformer#
- class LogTransformer(method='log1p', eps=1e-10)[source]#
Logarithmic transform.
This is a stateless transformer:
fit()is a no-op and the same transform is applied regardless of the input data. It is provided for API uniformity so that all preprocessing steps can be expressed as transformer objects.- Parameters:
method (
str, optional, default:’log1p’) – Transform to apply:'log1p'— computelog(1 + x)(stable for small or zero values).'log'— computelog(x). If the data contain values \(\le 0\), a small offsetepsis added automatically.
eps (
float, optional, default:1e-10) – Offset added whenmethod='log'and non-positive values are present.
Examples
>>> transformer = scp.LogTransformer(method="log1p") >>> nd = transformer.fit_transform(dataset)
See also
log_transformProcedural log transform 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.LogTransformer