我有一个巨大的scipy.sparse.csr.csr_matrix
类型的稀疏矩阵,我需要估计它的秩。我发现this on scipy.org似乎非常适合这份工作,但它不支持csr_matrix
from scipy.sparse import load_npz
from scipy.linalg.interpolative import estimate_rank
X = load_npz("https://drive.google.com/uc?export=download&id=1SSR6JWEqG4DXRU9qo78682D9pGJF3Wr0")
print("Rank:", estimate_rank(X, eps=100))
TypeError:无效的输入类型(必须是数组或LinearRoperator)
稀疏矩阵有超过50K行和近40K列。首先,将其转换为numpy数组似乎毫无意义。我该怎么做才能让它工作
下面的方法也不起作用
from scipy.sparse import load_npz, linalg
from scipy.linalg.interpolative import estimate_rank
X = load_npz("https://drive.google.com/uc?export=download&id=1SSR6JWEqG4DXRU9qo78682D9pGJF3Wr0")
print("Rank:", estimate_rank(linag.aslinearoperator(X), eps=100))
ValueError回溯(最近一次调用上次) 在() 3. 4份打印件(类型(X)) ----&燃气轮机;5打印(“文件术语矩阵的秩:”,估计秩(aslinearoperator(X),eps=1))
1帧 /idd中的usr/local/lib/python3.6/dist-packages/scipy/linalg//u interpolative\u backend.py(eps、m、n、matvect) 659:rtype:int 660 """ -->;661 k,ra,ier=_id.idd_find(eps,m,n,matvect) 662如有: 663上升重新编码错误
ValueError:未能创建意图(缓存|隐藏)|可选数组--必须已定义维度,但已获取(-1216667648,)
我使用过稀疏,但没有使用
estimate_rank
。但我可以阅读错误和文档测试阵列选项:
测试线性构造器选项:
相关问题 更多 >
编程相关推荐