Python Forum
Scaling elements of marix. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Scaling elements of marix. (/thread-18421.html)



Scaling elements of marix. - pawlo392 - May-16-2019

I have a matrix 682x10 and I have problem with one task. I want to do for each j-column Xj=(Xj-min(Xj))/(max(Xj)-min(Xj)). Of course, I know how to do this with for. But I have to use numpy library.I tried it this way:
X[0:] = (X[0:] - np.min(X[0:])) / (np.max(X[0:]) - np.min(X[0:]))
But:
Error:
NotImplementedError: subtracting a nonzero scalar from a sparse matrix is not supported



RE: Scaling elements of marix. - michalmonday - May-16-2019

Could you show example of input and output that you'd like to achieve using some random 4x2 array?