Replace np.asarray(result_matrix.todense()) with result_matrix.toarray()