spectrochempy.SNVTransformer

class SNVTransformer[source]

Standard Normal Variate (SNV) transformer.

Equivalent to AutoscaleTransformer with dim='x'. Each observation (spectrum) is mean-centered and scaled to unit variance individually.

This is a thin wrapper that hard-codes dim='x' and provides a more descriptive name for the common NIR preprocessing step.

Examples

>>> scaler = scp.SNVTransformer()
>>> scaler.fit(train)
>>> test_snv = scaler.transform(test)

See also

snv

Procedural SNV function.

AutoscaleTransformer

General autoscaling transformer.

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.

Parameters

dataset (NDDataset) – Training data.

Returns

NDDataset – Transformed dataset.

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'}
inverse_transform(dataset)[source]

Reverse the learned transformation on dataset.

Parameters

dataset (NDDataset) – Data to invert.

Returns

NDDataset – Dataset in the original space.

Raises

SpectroChemPyError – If fit() has not been called first.

set_params(**params)[source]

Set constructor parameters on this transformer.

Returns self so 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')
transform(dataset)[source]

Apply the learned transformation to dataset.

Parameters

dataset (NDDataset) – Data to transform.

Returns

NDDataset – Transformed dataset.

Raises

SpectroChemPyError – If fit() has not been called first.

Examples using spectrochempy.SNVTransformer