Man*_*noj 2 python scipy sparse-matrix
我想知道检查scipy稀疏矩阵的最佳方法,如果是CSC或CSR.现在我正在使用.
rows, cols = X.shape()
indptr = X.indptr()
if len(indptr) == cols + 1:
print "csc"
else:
print "csr"
Run Code Online (Sandbox Code Playgroud)
谢谢.
看起来你可以使用这个.getformat()方法:
>>> m0 = scipy.sparse.csc_matrix([1])
>>> m0.getformat()
'csc'
>>> m1 = scipy.sparse.csr_matrix([1])
>>> m1.getformat()
'csr'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
928 次 |
| 最近记录: |