📜  制作一个 scipy csr 稀疏矩阵 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:42.399000             🧑  作者: Mango

代码示例1
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()
array([[1, 0, 2],
       [0, 0, 3],
       [4, 5, 6]])