is there an easy way to shuffle a sparse matrix in python?
This is how I shuffle a non-sparse matrix:
index = np.arange(np.shape(matrix)[0])
A better way can be shuffling the index of CSR Matrix and fetching the rows of matrix as such:
from random import shuffle indices = np.arange(matrix.shape[0]) #gets the number of rows shuffle(indices) shuffled_matrix = matrix[list(indices)]