梨树
RPCA 的 Python 实现
用法
import numpy as np
import pyrpca
n = 50
r = 2
np.random.seed(123)
base = 100 + np.cumsum(np.random.randn(n,r),axis=0)
scales = np.abs(np.random.randn(n,r))
L = np.dot(base,scales.T)
S = np.round(0.25 * np.random.randn(n,n))
M = L + S
L_hat,S_hat,niter = pyrpca.rpca_alm(M)
np.max(np.abs(S-S_hat))
np.max(np.abs(L-L_hat))
_,s,_ = np.linalg.svd(L,full_matrices=False)
print s[s
2021-11-17 22:35:55
4.1MB
Python
1