spectrochempy.AutoscaleTransformer

class AutoscaleTransformer(dim='y')[source]

Autoscaling (z-score) transformer.

Learns the mean and standard deviation along a dimension during fit() and applies \((x - \bar{x}) / s\) during transform().

Parameters:

dim (str or int, optional, default:’y’) – Dimension along which the mean and standard deviation are computed.

mean_[source]

Learned mean.

Type:

ndarray

std_[source]

Learned standard deviation.

Type:

ndarray

Examples

>>> scaler = scp.AutoscaleTransformer(dim="y")
>>> scaler.fit(train)
>>> test_scaled = scaler.transform(test)
>>> train_restored = scaler.inverse_transform(test_scaled)

See also

autoscale

Procedural autoscaling function.

Methods Summary

fit(dataset)

Learn parameters from dataset.

fit_transform(dataset)

Fit to dataset, then transform it.

inverse_transform(dataset)

Reverse the learned transformation on dataset.

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.

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.

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.AutoscaleTransformer