csr_matrix用法

1 csr_matrix默认对未填充的位置置为0,

row = [0, 0, 0, 1, 1, 1, 2, 2, 2]    # 行指标
col = [0, 1, 2, 0, 1, 2, 0, 1, 2]    # 列指标
data = [1, 0, 1, 0, 1, 1, 1, 1, 0]   # 在行指标列指标下的数字
team = csr_matrix((data, (row, col)), shape=(3, 3))
print(team)
print(team.todense())                #todense()与toarray()的效果一样,都是将矩阵输出.
print(team.toarray())

https://blog.csdn.net/chao2016/article/details/80344828

原文地址:https://www.cnblogs.com/xxswkl/p/11039126.html