How do I transform a “SciPy sparse matrix” to a “NumPy matrix”?

The scipy.sparse.*_matrix has several useful methods, for example, if a is e.g. scipy.sparse.csr_matrix:

  • a.toarray() or a.A – Return a dense ndarray representation of this matrix. (numpy.array, recommended)
  • a.todense() or a.M – Return a dense matrix representation of this matrix. (numpy.matrix)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)