Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Rohit-bhat
Newbie

How to normalize an array in NumPy?

I would like to have the norm of one NumPy array. More specifically, I am looking for an equivalent version of this function

def normalize(v): 

norm = np.linalg.norm(v) 

if norm == 0: 

return v 

return v / norm

Is there something like that in sklearn or NumPy?

This function works in a situation where v is the 0 vector.

The normalization of data is important for the fast and smooth training of our machine learning models. Scikit learns, a library of python has sklearn.preprocessing.normalize, which helps to normalize the data easily.

0 Kudos