scale#

class usencrypt.ai.preprocessing.scale(X, axis=0, with_mean=True, with_std=True)#

Scales the input around a mean and unit standard deviation.

Given some input data \(x\), mean \(\mu\), and standard deviation \(\sigma\), this is defined as:

\[z = \frac{(x - \mu)}{\sigma}\]
Parameters
  • X (list or numpy.ndarray) – The input data to scale.

  • axis (int) – Specifies the axis of X along which to compute the vector scaling. Defaults to 0.

  • with_mean (bool) – Determines whether or not to center the data before scaling. If True, the centering is done. Defaults to True.

  • with_std (bool) – Determines whether or not to scale the data to the unit variance. If True, the scaling is done. Defaults to False.

Returns

The scaled input.

Return type

numpy.ndarray

Examples
>>> import numpy as np
>>> import usencrypt as ue
>>> x = 10 * np.random.random_sample(size=(10)) - 5
>>> x
array([ 1.87423786, -3.50295575, -3.72622196, -3.41901215, -1.01113287,
        2.51600148, -0.34614213,  2.55527736, -3.06706597, -3.14982435])
>>> scaled = ue.ai.preprocessing.scale(x)
>>> scaled
array([ 1.20587962, -0.95415279, -1.0438394 , -0.92043243,  0.04681883,
        1.46367771,  0.3139473 ,  1.47945493, -0.77905475, -0.81229901])