# What does it mean to normalize an array ?

`from sklearn import preprocessingimport numpy as npX = [[ 1., -1.,  2.],     [ 2.,  0.,  0.],     [ 0.,  1., -1.]]X_l1 = preprocessing.normalize(X, norm='l1')X_l1# array([[ 0.25, -0.25,  0.5 ],#        [ 1.  ,  0.  ,  0.  ],#        [ 0.  ,  0.5 , -0.5 ]])`
`X_l2 = preprocessing.normalize(X, norm='l2')X_l2# array([[ 0.40824829, -0.40824829,  0.81649658],#        [ 1.        ,  0.        ,  0.        ],#        [ 0.        ,  0.70710678, -0.70710678]])np.sqrt(np.sum(X_l2**2, axis=1)) # verify that L2-norm is indeed 1# array([ 1.,  1.,  1.])`

# Normalizing a Vector

## V/|V| = (x/|V|, y/|V|, z/|V|).

`| V/|V| | = sqrt((x/|V|)*(x/|V|) + (y/|V|)*(y/|V|) + (z/|V|)*(z/|V|))          = sqrt(x*x + y*y + z*z) / |V|          = |V| / |V|          = 1`

# Differences between Norm of a Vector and distance between two points

## That means Euclidean Distance between 2 points x1 and x2 is nothing but the L2 norm of vector (x1 — x2)

DataScience | ML | 2x Kaggle Expert. Ex Fullstack Engineer and Ex International Financial Analyst. https://www.linkedin.com/in/rohan-paul-b27285129/

## More from Rohan Paul

DataScience | ML | 2x Kaggle Expert. Ex Fullstack Engineer and Ex International Financial Analyst. https://www.linkedin.com/in/rohan-paul-b27285129/