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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM