无法在 scipy 中创建非空 csr.matrix()
Cannot create non-empty csr.matrix() in scipy
我需要稀疏矩阵来解决问题,根据 scipy http://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html#scipy.sparse.csr_matrix 中 scr.matrix() 的描述,它非常适合我的问题。
但是我什至无法初始化它。
当我使用此文档 http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.sparse.csr_matrix.html 中的空矩阵示例时,它工作正常,与文档
中的完全一样
>>> import numpy as np
>>> from scipy.sparse import csr_matrix
>>> csr_matrix((3, 4), dtype=np.int8).toarray()
array([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]], dtype=int8)
但是当我使用非空矩阵的示例或尝试用我自己的数据填充它时
>>> row = np.array([0, 0, 1, 2, 2, 2])
>>> col = np.array([0, 2, 2, 0, 1, 2])
>>> data = np.array([1, 2, 3, 4, 5, 6])
>>> csr_matrix((data, (row, col)), shape=(3, 3)).toarray()
我总是收到这条消息
/Library/Python/2.7/site-packages/numpy-1.9.2-py2.7-macosx-10.10-
intel.egg/numpy/core/fromnumeric.py:2507: VisibleDeprecationWarning:
`rank` is deprecated; use the `ndim` attribute or function instead.
To find the rank of a matrix see `numpy.linalg.matrix_rank`.
VisibleDeprecationWarning)
这是什么意思?我完全卡住了。对不起,我是 scipy 的新手,需要帮助。
这只是一个警告,我希望创建您的矩阵。
Scipy 正在调用旧的 numpy 函数。它已于 2014 年 4 月在 scipy.
中修复
Scipy 更改为:
https://github.com/scipy/scipy/commit/fa1782e04fdab91f672ccf7a4ebfb887de50f01c
我需要稀疏矩阵来解决问题,根据 scipy http://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html#scipy.sparse.csr_matrix 中 scr.matrix() 的描述,它非常适合我的问题。 但是我什至无法初始化它。 当我使用此文档 http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.sparse.csr_matrix.html 中的空矩阵示例时,它工作正常,与文档
中的完全一样>>> import numpy as np
>>> from scipy.sparse import csr_matrix
>>> csr_matrix((3, 4), dtype=np.int8).toarray()
array([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]], dtype=int8)
但是当我使用非空矩阵的示例或尝试用我自己的数据填充它时
>>> row = np.array([0, 0, 1, 2, 2, 2])
>>> col = np.array([0, 2, 2, 0, 1, 2])
>>> data = np.array([1, 2, 3, 4, 5, 6])
>>> csr_matrix((data, (row, col)), shape=(3, 3)).toarray()
我总是收到这条消息
/Library/Python/2.7/site-packages/numpy-1.9.2-py2.7-macosx-10.10-
intel.egg/numpy/core/fromnumeric.py:2507: VisibleDeprecationWarning:
`rank` is deprecated; use the `ndim` attribute or function instead.
To find the rank of a matrix see `numpy.linalg.matrix_rank`.
VisibleDeprecationWarning)
这是什么意思?我完全卡住了。对不起,我是 scipy 的新手,需要帮助。
这只是一个警告,我希望创建您的矩阵。 Scipy 正在调用旧的 numpy 函数。它已于 2014 年 4 月在 scipy.
中修复Scipy 更改为: https://github.com/scipy/scipy/commit/fa1782e04fdab91f672ccf7a4ebfb887de50f01c