Description Usage Arguments Details Value Author(s) References Examples
Robust principal components analysis separates a matrix into a low-rank plus sparse component.
1 2 3 4 5 6 7 8 9 10 |
A |
array_like; |
lambda |
scalar, optional; |
maxiter |
integer, optional; |
tol |
scalar, optional; |
p |
integer, optional; |
q |
integer, optional; |
trace |
bool, optional; |
rand |
bool, optional; |
Robust principal component analysis (RPCA) is a method for the robust seperation of a a rectangular (m,n) matrix A into a low-rank component L and a sparse comonent S:
A = L + S
To decompose the matrix, we use the inexact augmented Lagrange multiplier method (IALM). The algorithm can be used in combination with either the randomized or deterministic SVD.
rrpca
returns a list containing the following components:
array_like;
low-rank component; (m, n) dimensional array.
array_like
sparse component; (m, n) dimensional array.
N. Benjamin Erichson, erichson@berkeley.edu
[1] N. B. Erichson, S. Voronin, S. L. Brunton and J. N. Kutz. 2019. Randomized Matrix Decompositions Using R. Journal of Statistical Software, 89(11), 1-48. doi: 10.18637/jss.v089.i11.
[2] Lin, Zhouchen, Minming Chen, and Yi Ma. "The augmented lagrange multiplier method for exact recovery of corrupted low-rank matrices." (2010). (available at arXiv https://arxiv.org/abs/1009.5055).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | library('rsvd')
# Create toy video
# background frame
xy <- seq(-50, 50, length.out=100)
mgrid <- list( x=outer(xy*0,xy,FUN="+"), y=outer(xy,xy*0,FUN="+") )
bg <- 0.1*exp(sin(-mgrid$x**2-mgrid$y**2))
toyVideo <- matrix(rep(c(bg), 100), 100*100, 100)
# add moving object
for(i in 1:90) {
mobject <- matrix(0, 100, 100)
mobject[i:(10+i), 45:55] <- 0.2
toyVideo[,i] = toyVideo[,i] + c( mobject )
}
# Foreground/Background separation
out <- rrpca(toyVideo, trace=TRUE)
# Display results of the seperation for the 10th frame
par(mfrow=c(1,4))
image(matrix(bg, ncol=100, nrow=100)) #true background
image(matrix(toyVideo[,10], ncol=100, nrow=100)) # frame
image(matrix(out$L[,10], ncol=100, nrow=100)) # seperated background
image(matrix(out$S[,10], ncol=100, nrow=100)) #seperated foreground
|
Iteration: 1 k = 2 Fro. error = 0.737746365366033
Iteration: 2 k = 2 Fro. error = 0.192062179612869
Iteration: 3 k = 3 Fro. error = 0.202330435689014
Iteration: 4 k = 3 Fro. error = 0.285855997379785
Iteration: 5 k = 3 Fro. error = 0.151270122099391
Iteration: 6 k = 2 Fro. error = 0.0608696315891474
Iteration: 7 k = 2 Fro. error = 0.0153711242624809
Iteration: 8 k = 2 Fro. error = 0.0028854840421088
Iteration: 9 k = 3 Fro. error = 0.00861708222513708
Iteration: 10 k = 2 Fro. error = 0.00656480391276222
Iteration: 11 k = 2 Fro. error = 0.00157598928211446
Iteration: 12 k = 3 Fro. error = 0.00133994636922928
Iteration: 13 k = 2 Fro. error = 0.000605321450071603
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.