normalize#

class usencrypt.ai.preprocessing.normalize(X, norm='l2', axis=- 1, return_norm=False)#

Scales input vectors individually to the unit norm.

Parameters
  • X (list or numpy.ndarray) – The input data to normalize.

  • norm – Specifies the normalization method to use on each non zero value. Defaults to 'l2'.

  • axis (int) – Specifies the axis of X along which to compute the vector norms. Defaults to -1.

  • return_norm (bool) – Specifies whether to return the computed norms. Defaults to False.

Returns

The normalized 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([ 3.51138926  0.72614652 -4.96862738 -4.75125604  0.76737579
       -1.19107509  -1.76690618  4.56655763 -1.33681224  1.53939143])
>>> norm = ue.ai.preprocessing.normalize(x, norm='l2')
>>> norm
array([ 0.3696024   0.07643285 -0.52298861 -0.5001085   0.08077257
       -0.12537038  -0.1859813   0.48066748 -0.14071041  0.16203352])