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