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

前端 未结 3 1042
情书的邮戳
情书的邮戳 2021-01-03 22:34

I am using a python function called \"incidence_matrix(G)\", which returns the incident matrix of graph. It is from Networkx package. The problem that I am facing is the ret

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-03 23:00

    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)

提交回复
热议问题