spectrochempy.autoscale

autoscale(dataset, dim='y', inplace=False)[source]

Mean-center and scale to unit variance along a dimension.

This is the classic autoscaling (or z-score / standard-score) operation used before PCA, PLS, and other multivariate analyses.

\[x_{ij}^\prime = \frac{x_{ij} - \bar{x}_j}{s_j}\]

where \(\bar{x}_j\) and \(s_j\) are the mean and standard deviation along the chosen dimension.

Parameters
  • dataset (NDDataset) – The input data.

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

  • inplace (bool, optional, default:False) – If True, autoscaling is performed in place.

Returns

NDDataset – The autoscaled dataset.

Examples

>>> dataset = scp.read("irdata/nh4.spg")
>>> nd = dataset.autoscale(dim="x")