SAMPLE CODE

We provide MATLAB packages to solve the RPCA optimization problem by different methods. All of our code below is Copyright 2009 Perception and Decision Lab, University of Illinois at Urbana-Champaign, and Microsoft Research Asia, Beijing. We also provide links to some publicly available packages to solve the RPCA problem. Please contact John Wright or Arvind Ganesh if you have any questions or comments. If you are looking for the code to our RASL and TILT algorithms, please refer to the applications section.

*Note:* If the code package contains a 'PROPACK' folder, please ensure that it is added in the MATLAB path before using the code.

We provide below links to publicly available code and references to solve the matrix completion problem faster than conventional algorithms.

We provide a simple comparison of the speed and accuracy of various RPCA algorithms. Each algorithm was tested on a rank-20 matrix of size 400 x 400 with 5% of its entries corrupted by large errors. The low-rank matrix A is generated as the product LR^{T}, where L and R are 400 x 20 matrices whose entries are i.i.d. according to the standard Gaussian distribution. The error matrix E is a sparse matrix whose support is chosen uniformly at random and whose non-zero entries are independent and uniformly distributed in the range [-50,50]. The value of λ was fixed as 0.05. The accuracy of the solution is indicated by the rank of the estimated low-rank matrix A and its relative error (in Frobenius norm) with respect to the true solution. All simulations were carried out on a Macbook Pro with a 2.8 GHz processor, two cores, and 4 GB memory.

Please note that the following tables represent typical performance, using default parameters, on random matrices drawn according to the distribution specified earlier. The performance could vary when dealing with matrices drawn from other distributions or with real data.

*Robust PCA Algorithm Comparison*

If you would like to list your code related to this topic on this website, please contact the webmaster Kerui Min.

Robust PCA |
Matrix Completion |
Comparison of Algorithms |

Robust PCA

We provide MATLAB packages to solve the RPCA optimization problem by different methods. All of our code below is Copyright 2009 Perception and Decision Lab, University of Illinois at Urbana-Champaign, and Microsoft Research Asia, Beijing. We also provide links to some publicly available packages to solve the RPCA problem. Please contact John Wright or Arvind Ganesh if you have any questions or comments. If you are looking for the code to our RASL and TILT algorithms, please refer to the applications section.

- Augmented Lagrange Multiplier (ALM) Method [exact ALM - MATLAB zip] [inexact ALM - MATLAB zip]

Usage - The most basic form of the exact ALM function is [A, E] = exact_alm_rpca(D, λ), and that of the inexact ALM function is [A, E] = inexact_alm_rpca(D, λ), where D is a real matrix and λ is a positive real number. We solve the RPCA problem using the method of augmented Lagrange multipliers. The method converges Q-linearly to the optimal solution. The exact ALM algorithm is simple to implement, each iteration involves computing a partial SVD of a matrix the size of D, and converges to the true solution in a small number of iterations. The algorithm can be further speeded up by using a fast continuation technique, thereby yielding the inexact ALM algorithm.

Reference - The Augmented Lagrange Multiplier Method for Exact Recovery of Corrupted Low-Rank Matrices, Z. Lin, M. Chen, L. Wu, and Y. Ma (UIUC Technical Report UILU-ENG-09-2215, November 2009). - Accelerated
Proximal Gradient [full SVD version - MATLAB zip] [partial SVD version - MATLAB zip]

Usage - The most basic form of the full SVD version of the function is [A, E] = proximal_gradient_rpca(D, λ), where D is a real matrix and λ is a positive real number. We consider a slightly different version of the original RPCA problem by relaxing the equality constraint. The algorithm is simple to implement, each iteration involves computing the SVD of a matrix the size of D, and converges to the true solution in a small number of iterations. The algorithm can be further speeded up by computing partial SVDs at each iteration. The most basic form of the partial SVD version of the function is [A, E] = partial_proximal_gradient_rpca(D, λ), where D is a real matrix and λ is a positive real number.

Reference - Fast Convex Optimization Algorithms for Exact Recovery of a Corrupted Low-Rank Matrix, Z. Lin, A. Ganesh, J. Wright, L. Wu, M. Chen, and Y. Ma (UIUC Technical Report UILU-ENG-09-2214, August 2009). - Dual
Method [MATLAB zip]

Usage - The most basic form of the function is [A, E] = dual_rpca(D, λ), where D is a real matrix and λ is a positive real number. We solve the convex dual of the RPCA problem, and retrieve the low-rank and sparse error matrices from the dual optimal solution. The algorithm computes only a partial SVD in each iteration and hence, scales well with the size of the matrix D.

Reference - Fast Convex Optimization Algorithms for Exact Recovery of a Corrupted Low-Rank Matrix, Z. Lin, A. Ganesh, J. Wright, L. Wu, M. Chen, and Y. Ma (UIUC Technical Report UILU-ENG-09-2214, August 2009). - Singular
Value Thresholding [MATLAB zip]

Usage - The most basic form of the function is [A, E] = singular_value_rpca(D, λ), where D is a real matrix and λ is a positive real number. Here again, we solve a relaxation of the original RPCA problem, albeit different from the one solved by the Accelerated Proximal Gradient (APG) method. The algorithm is extremely simple to implement, and the computational complexity of each iteration is about the same as that of the APG method. However, the number of iterations to convergence is typically quite large.

Reference - A Singular Value Thresholding Algorithm for Matrix Completion,

J. -F. Cai, E. J. Candès, and Z. Shen (2008). - Alternating Direction Method [MATLAB zip]

Reference - Sparse and Low-Rank Matrix Decomposition via Alternating Direction Methods, X. Yuan, and J. Yang (2009).

Matrix
Completion

We provide below links to publicly available code and references to solve the matrix completion problem faster than conventional algorithms.

- Augmented Lagrange Multiplier (ALM) Method [inexact ALM - MATLAB zip]

Usage - The most basic form of the inexact ALM function is A = inexact_alm_mc(D), where D is the incomplete matrix defined in the MATLAB sparse matrix format and the output A is a structure with two components - A.U and A.V (the left and right singular vectors scaled respectively by the square root of the corresponding non-zero singular values). Please refer to the file test_alm_mc.m for details on defining D appropriately. The algorithm is identical to the inexact ALM method described above to solve the RPCA prblem, and enjoys the same convergence properties.

Reference - The Augmented Lagrange Multiplier Method for Exact Recovery of Corrupted Low-Rank Matrices, Z. Lin, M. Chen, L. Wu, and Y. Ma (UIUC Technical Report UILU-ENG-09-2215, November 2009). - Singular
Value Thresholding

Reference - A Singular Value Thresholding Algorithm for Matrix Completion, J. -F. Cai, E. J. Candès, and Z. Shen (2008). - OptSpace

Reference - Matrix Completion from a Few Entries, R.H. Keshavan, A. Montanari, and S. Oh (2009). - Accelerated
Proximal Gradient

Reference - An Accelerated Proximal Gradient Algorithm for Nuclear Norm Regularized Least Squares Problems, K. -C. Toh, and S. Yun (2009). - Subspace Evolution and Transfer (SET) [MATLAB zip]

Reference - SET: An Algorithm for Consistent Matrix Completion, W. Dai, and O. Milenkovic (2009). - GROUSE: Grassmann Rank-One Update Subspace Estimation

Reference - Online Identification and Tracking of Subspaces from Highly Incomplete Information, L. Balzano, R. Nowak, and B. Recht (2010).

Comparison of Algorithms

We provide a simple comparison of the speed and accuracy of various RPCA algorithms. Each algorithm was tested on a rank-20 matrix of size 400 x 400 with 5% of its entries corrupted by large errors. The low-rank matrix A is generated as the product LR

Please note that the following tables represent typical performance, using default parameters, on random matrices drawn according to the distribution specified earlier. The performance could vary when dealing with matrices drawn from other distributions or with real data.

Algorithm |
Rank of estimate |
Relative error in estimate of A |
Time (s) |

Singular Value Thresholding | 20 | 3.4 x 10^{-4} |
877 |

Accelerated Proximal Gradient | 20 | 2.0 x 10^{-5} |
43 |

Accelerated Proximal Gradient (with partial SVDs) |
20 | 1.8 x 10^{-5} |
8 |

Dual Method | 20 | 1.6 x 10^{-5} |
177 |

Exact ALM | 20 | 7.6 x 10^{-8} |
4 |

Inexact ALM | 20 | 4.3 x 10^{-8} |
2 |

Alternating Direction Methods | 20 | 2.2 x 10^{-5} |
5 |

If you would like to list your code related to this topic on this website, please contact the webmaster Kerui Min.