我在R中有一個稀疏的Matrix
,它對我來說運行as.matrix()
顯然太大了(儘管它也不是超級巨大的)。有問題的as.matrix()
調用在svd()
函數中,所以我想知道是否有人知道不需要先轉換爲密集矩陣的SVD的不同實現。用於R中稀疏矩陣的SVD
回答
的irlba包具有非常快的SVD實現稀疏矩陣。
這就是我最終做的。這是比較簡單的編寫轉儲稀疏矩陣(類dgCMatrix
)在SVDLIBC的「疏文本」格式的文本文件的程序,然後調用svd
可執行文件,並閱讀這三個結果的文本文件放回R.
的趕上它是相當低效的 - 我需要大約10秒才能讀取&寫入文件,但實際的SVD計算僅需要大約0.2秒左右。儘管如此,這當然比不能完成計算要好得多,所以我很高興。 =)
後續問題張貼在http://stackoverflow.com/questions/5009026/extract-long-from-r-object。 – 2011-02-15 21:11:45
在不提供任何示例數據或解決方案代碼的情況下給自己一個複選標記似乎與SO的原理相悖。 – 2012-09-29 15:29:49
可以使用隨機投影做稀疏SVD的非常可觀的位中的R爲在http://arxiv.org/abs/0909.4061
這裏描述是一些示例代碼:
# computes first k singular values of A with corresponding singular vectors
incore_stoch_svd = function(A, k) {
p = 10 # may need a larger value here
n = dim(A)[1]
m = dim(A)[2]
# random projection of A
Y = (A %*% matrix(rnorm((k+p) * m), ncol=k+p))
# the left part of the decomposition works for A (approximately)
Q = qr.Q(qr(Y))
# taking that off gives us something small to decompose
B = t(Q) %*% A
# decomposing B gives us singular values and right vectors for A
s = svd(B)
U = Q %*% s$u
# and then we can put it all together for a complete result
return (list(u=U, v=s$v, d=s$d))
}
rARPACK是您需要的軟件包。像魅力一樣工作,超快,因爲它通過C和C++並行化。
- 1. python中的稀疏矩陣svd
- 2. R稀疏矩陣電源
- 3. R:在稀疏矩陣
- 4. R:稀疏矩陣轉換
- 5. [R構建稀疏矩陣
- 6. R矩陣包:Demean稀疏矩陣
- 7. 稀疏矩陣
- 8. 子集的稀疏矩陣data.table R中
- 9. 類似於R矩陣庫的Csharp稀疏矩陣庫?
- 10. 稀疏矩陣和矩陣
- 11. 使用R創建稀疏矩陣
- 12. R最成熟的稀疏矩陣包?
- 13. R heatmap稀疏多樣的矩陣
- 14. Numba中的稀疏矩陣
- 15. 以稀疏矩陣
- 16. 50Kx50K稀疏矩陣
- 17. 用於Ruby的稀疏矩陣庫
- 18. 稀疏三元組稀疏矩陣matlab
- 19. 確定稀疏矩陣的稀疏性(Lil矩陣)
- 20. svd的一個非常大的稀疏矩陣
- 21. R稀疏矩陣支持quantreg
- 22. R - Logistic迴歸 - 稀疏矩陣
- 23. 大型稀疏矩陣的全SVD(只需要特徵值)
- 24. 通用稀疏矩陣加
- 25. sklearn tsne用稀疏矩陣
- 26. python稀疏矩陣的矩陣功率
- 27. 98%稀疏矩陣的矩陣完成
- 28. Matlab的稀疏svd函數
- 29. 關於稀疏矩陣的Matlab問題
- 30. 稀疏矩陣的劃分
R找不到任何東西。C,Fortran,Python等有很多東西。 – 2011-02-09 22:38:42
也許我會試用SVDLIBC。它構建爲一個C庫,所以如果它運行良好,我將來可以將它作爲一個模塊來包裝(儘管我的雄心可能不會持續那麼久,如果歷史是任何指導的話)。 – 2011-02-10 17:32:25
這個http://cran.r-project.org/web/packages/irlba/如何計算一個快速和有效的記憶方法來計算一些近似奇異值和大矩陣的奇異向量。 – 2012-02-23 08:29:31