I’m trying to normalize a csr_matrix:
<5400x6845 sparse matrix of type '<type 'numpy.float64'> with 91833 stored elements in Compressed Sparse Row format>
What I tried was this:
import numpy as np
from scipy import sparse
# ve is my csr_matrix
ve_sum = ve.sum(axis=1)
ve_sums = sparse.csr_matrix(np.tile(ve_sum, (1, ve.shape[1]))) # <-- here I get MemoryError
n_ve = ve/ve_sums
This is obviously not the correct way of doing this kind of easy normalization.
What is the correct way?
A quick google search reveals this also.