Python Forum

Full Version: Scaling elements of marix.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Could you show example of input and output that you'd like to achieve using some random 4x2 array?