How to transform numpy.matrix or array to scipy sparse matrix
You can pass a numpy array or matrix as an argument when initializing a sparse matrix. For a CSR matrix, for example, you can do the following. >>> import numpy as np >>> from scipy import sparse >>> A = np.array([[1,2,0],[0,0,3],[1,0,4]]) >>> B = np.matrix([[1,2,0],[0,0,3],[1,0,4]]) >>> A array([[1, 2, 0], [0, 0, 3], [1, 0, … Read more