Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I have the following numpy array:

from sklearn.decomposition import PCA

from sklearn.preprocessing import normalize

import numpy as np

# Tracking 4 associate metrics

# Open TA's, Open SR's, Open SE's

associateMetrics = np.array([[111,  28,  21],

   [ 27,  17,  20],

   [ 79,  23,  17],

   [185, 125,  50],

   [155,  76,  32],

   [ 82,  24,  17],

   [127,  63,  33],

   [193,  91,  63],

   [107,  24,  17]])

Now, I want to normalize every 'column' so that the values are between 0 and 1. What I mean is that the values in the 1st column for example should be between 0 and 1.

How do i do this?

normed_matrix = normalize(associateMetrics, axis=1, norm='l1')

the above gives me rowwise normalization

1 Answer

0 votes
by (41.4k points)

You can do column-wise normalization by doing this:

normalized_metrics = normalize(associateMetrics, axis=0, norm='l1'

If you wish to know about Python then visit this Python Course.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
4 answers
0 votes
2 answers

Browse Categories

...