Dictionary of Applied Machine Learning: 151 machine-learning terms, each with a definition, a figure, citations and a Python demo · All terms · Demos · Start here

robust principal component analysis (robust PCA)

Updated on 2026-11-20

Readiness 90/100

▶ Run the Python demo Open in Colab Typeset PDF LaTeX source Markdown Cite this entry

See also principal component analysis probabilistic principal component analysis singular value decomposition regularization outlier empirical risk minimization hypothesis space squared error loss

Robust principal component analysis (robust PCA) decomposes a feature matrix into a low-rank matrix, whose rows lie in a subspace of small dimension, and a sparse matrix that carries a few corrupted feature values. Unlike principal component analysis (PCA), it does not compute the low-rank matrix from the recorded values, so a large fault lands in the sparse matrix instead of turning the subspace. One approach states robust PCA as a convex optimization problem, referred to as principal component pursuit. Convex optimization methods solve it, among them the alternating direction method of multipliers (ADMM). The resulting method delivers estimates for the principal directions that span the subspace, and for the corrupted entries in the features of each data point.

Figure produced by the Python demo of the entry robust principal component analysis (robust PCA)
Figure written by the entry's Python demo rpca.py, which recomputes what the entry states: the script block by block · open in Colab

Definition

The weather station Krems an der Donau records the air temperature every hour, so ten days of 2024 give ten rows of $24$ values (Fig. 1). Stacking the $24$ values of one day gives the feature vector ${\mathbf x} \in \mathbb{R}^{d}$, with $d = 24$, of the corresponding data point. Stacking the $m = 10$ feature vectors row-wise gives the $m \times d$ feature matrix ${\mathbf X}$. Each feature vector is centered by subtracting the average of the $m$ feature vectors, so that this average is the zero vector.

Principal component analysis (PCA) uses the feature matrix to learn a given number $d'$ of orthonormal vectors $\mathbf{u}^{(1)}, \ldots, \mathbf{u}^{(d')}$, the principal directions of ${\mathbf X}$. They span a $d'$-dimensional subspace $\mathcal{U}$ of $\mathbb{R}^{d}$ such that each feature vector ${\mathbf x}^{(r)}$, for $r = 1, \ldots, m$, can be well approximated by its projection \[ \mathbf{P} {\mathbf x}^{(r)} = \sum_{j=1}^{d'} \langle \mathbf{u}^{(j)}, {\mathbf x}^{(r)} \rangle \mathbf{u}^{(j)} \text{.}\] Here, $\mathbf{P} \in \mathbb{R}^{d \times d}$ denotes the orthogonal projection matrix on the subspace $\mathcal{U}$. It is given explicitly by $\mathbf{P}=\sum_{j=1}^{d'} \mathbf{u}^{(j)} \big( \mathbf{u}^{(j)} \big)^{\top}$ and provides a fully equivalent representation of the subspace $\mathcal{U}$ spanned by the principal directions.

The projection matrix $\mathbf{P}$ delivered by PCA decomposes each feature vector as ${\mathbf x}^{(r)} = \mathbf{P} {\mathbf x}^{(r)} + {\mathbf e}^{(r)}$, with the approximation error ${\mathbf e}^{(r)}$. These decompositions (one for each $r=1,\ldots,m$) can be expressed more compactly in terms of the feature matrix as \begin{equation} \label{equ_dict_rpca_decomp_pca} {\mathbf X} = {\mathbf L} + \mathbf{E} \text{, where } {\mathbf L} = {\mathbf X} \mathbf{P} \text{ and } \mathbf{E} = {\mathbf X} - {\mathbf L} \text{.} \end{equation} The rank of ${\mathbf L}$ is at most $d'$, since every row of ${\mathbf L}$ lies in the subspace $\mathcal{U}$. The error matrix $\mathbf{E}$ carries the ${\mathbf e}^{(r)}$ as its rows, so $\left\lVert \mathbf{E} \right\rVert_{F}^{2} = \sum_{r=1}^{m} \left\lVert {\mathbf e}^{(r)} \right\rVert_{2}^{2}$. PCA chooses $\mathbf{P}$ to make this quantity as small as possible. In this reading, PCA splits the feature matrix into a low-rank part ${\mathbf L}$ and a small remainder $\mathbf{E}$.

The decomposition \(\eqref{equ_dict_rpca_decomp_pca}\) suggests using a representation of the component $\mathbf{P} {\mathbf x}^{(r)}$ as new features. One such representation is the vector ${\mathbf z}^{(r)} = \big( \langle \mathbf{u}^{(1)}, {\mathbf x}^{(r)} \rangle, \ldots, \langle \mathbf{u}^{(d')}, {\mathbf x}^{(r)} \rangle \big)^{\top}$ whose entries are the inner products between ${\mathbf x}^{(r)}$ and the principal directions of the feature matrix ${\mathbf X}$. For $d' = 2$ the new features $z_{1}, z_{2}$ can be used as coordinates in a scatterplot, as panel (a) of Fig. 2 shows.

B-ten-daysSometimes a feature value is faulty, for example because a temperature sensor fails. The red square in Fig. 1 marks such a failure: the noon reading of day five is increased by $22$ degrees, which gives the perturbed feature vector $\widetilde{{\mathbf x}}^{(5)}$ and, in turn, the perturbed feature matrix $\widetilde{{\mathbf X}}$. Panel (b) of Fig. 2 shows the scatterplot that PCA delivers from $\widetilde{{\mathbf X}}$. The new features $z^{(5)}_{1}, z^{(5)}_{2}$ obtained for $\widetilde{{\mathbf x}}^{(5)}$ are far from those of the other days, and the second learned principal direction turns toward the axis of the perturbed feature. Thus, an isolated but large fault can substantially distort the coordinates of every data point.

B-faultsThe decomposition \(\eqref{equ_dict_rpca_decomp_pca}\) explains why. Applied to $\widetilde{{\mathbf X}}$, it has the low-rank part ${\mathbf L} = \widetilde{{\mathbf X}} \mathbf{P}$, which is computed from the recorded values, and a remainder $\mathbf{E}$ that PCA keeps small in the Frobenius norm. The $22$ degrees can therefore not be left in $\mathbf{E}$. Most of them have to appear in ${\mathbf L}$, and the only way a matrix of rank at most $d'$ can carry a large value at a single entry is for the subspace $\mathcal{U}$ to turn toward the faulty feature.

Figure 1 of the entry rpca
Figure 1: Hourly temperature recordings for ten days of 2024 at Krems an der Donau, drawn as small black dots. Each day is a data point with a $24$-dimensional feature vector $\featurevec$. The red circle marks the correct noon reading of day five, and the large red square the perturbation that replaces it, $22$ degrees higher
Robust PCA drops the constraint ${\mathbf L} = {\mathbf X} \mathbf{P}$ and adds a third summand for the faulty entries, \begin{equation} \label{equ_dict_rpca_decomp} {\mathbf X} = {\mathbf L} + \mathbf{S} + \mathbf{E} \text{.} \end{equation} The low-rank matrix ${\mathbf L}$ is now an unknown in its own right, constrained only by $\mathop{\mathrm{rank}}({\mathbf L}) \leq d'$. The sparse matrix $\mathbf{S}$ carries the faulty feature values and is zero in every other entry. The remainder $\mathbf{E}$ stays small, as in the PCA decomposition \(\eqref{equ_dict_rpca_decomp_pca}\). Row $r$ of the decomposition \(\eqref{equ_dict_rpca_decomp}\) splits the feature vector ${\mathbf x}^{(r)}$ into these three parts.

The subspace and the principal directions are computed from ${\mathbf L}$ afterwards. The rows of ${\mathbf L}$ span a subspace of dimension at most $d'$, and the principal directions $\mathbf{u}^{(1)}, \ldots, \mathbf{u}^{(d')}$ are the leading right singular vectors of ${\mathbf L}$, delivered by its singular value decomposition (SVD). The projection matrix $\mathbf{P}$ follows from them, and ${\mathbf L} = {\mathbf L} \mathbf{P}$ holds because every row of ${\mathbf L}$ already lies in the subspace that $\mathbf{P}$ projects on. Robust PCA therefore delivers the same objects as PCA, but from a matrix ${\mathbf L}$ that is free of the faulty feature values, since $\mathbf{S}$ carries them.

The goal of making $\mathbf{E}$ small while $\mathbf{S}$ carries only a few non-zero entries can be stated as an optimization problem \begin{equation} \label{equ_dict_rpca_nonconvex} \min_{{\mathbf L}, \mathbf{S} \in \mathbb{R}^{m \times d}} \left\lVert {\mathbf X} - {\mathbf L} - \mathbf{S} \right\rVert_{F} \quad \text{ subject to } \mathop{\mathrm{rank}}({\mathbf L}) \leq d', \; \left\lVert \mathbf{S} \right\rVert_{0} \leq s \text{.} \end{equation} The optimization variables are the two matrices ${\mathbf L}$ and $\mathbf{S}$, and the objective function is the Frobenius norm of the remainder $\mathbf{E} = {\mathbf X} - {\mathbf L} - \mathbf{S}$. The pseudo-norm $\left\lVert \mathbf{S} \right\rVert_{0}$ denotes the number of non-zero entries of $\mathbf{S}$, and $s$ is a given bound on the number of faulty feature values.

The optimization problem \(\eqref{equ_dict_rpca_nonconvex}\) is non-convex, since neither the rank nor the number of non-zero entries is a convex function. Principal component pursuit replaces it with the convex optimization problem \begin{equation} \label{equ_dict_rpca_pcp} \min_{{\mathbf L}, \mathbf{S} \in \mathbb{R}^{m \times d}} \left\lVert {\mathbf L} \right\rVert_{*} + \alpha \left\lVert \mathbf{S} \right\rVert_{1} \quad \text{ subject to } {\mathbf X} = {\mathbf L} + \mathbf{S} \text{,} \end{equation} with a regularization parameter $\alpha > 0$ (Candès et al., 2011). Here, $\left\lVert {\mathbf L} \right\rVert_{*}$ is the sum of the singular values of ${\mathbf L}$, and $\left\lVert \mathbf{S} \right\rVert_{1}$ the sum of the absolute values of the entries of $\mathbf{S}$. These two norms are convex, as every norm is (Boyd and Vandenberghe, 2004, Sects. 3.1.5 and A.1.6), and take the place of the rank of ${\mathbf L}$ and of the number of non-zero entries of $\mathbf{S}$. A large regularization parameter $\alpha$ makes every non-zero entry of $\mathbf{S}$ expensive, so the solution keeps $\mathbf{S}$ sparser and leaves more of ${\mathbf X}$ to ${\mathbf L}$. The rank of ${\mathbf L}$, and with it the dimension $d'$ of the subspace, then comes out larger, while a small $\alpha$ has the opposite effect.

B-pursuitPCA is an instance of empirical risk minimization (ERM) with the squared error loss. Principal component pursuit \(\eqref{equ_dict_rpca_pcp}\) changes its hypothesis space, its criterion, and its optimization method. The hypothesis space is larger: a candidate of PCA is one projection matrix $\mathbf{P}$, which already fixes ${\mathbf L} = {\mathbf X} \mathbf{P}$, whereas a candidate of robust PCA is a pair $({\mathbf L}, \mathbf{S})$, so the sparse matrix is a second unknown. The squared error loss is gone, because the constraint ${\mathbf X} = {\mathbf L} + \mathbf{S}$ leaves no remainder to measure. What principal component pursuit minimizes is therefore not a loss function. It is a convex relaxation of the rank and sparsity constraints of the non-convex optimization problem \(\eqref{equ_dict_rpca_nonconvex}\), and that relaxation is what makes the optimization problem tractable (Candès et al., 2011, Sect. 1.2). The optimization method changes with the criterion: one SVD of the feature matrix suffices for PCA, since its leading right singular vectors are the principal directions (Hastie et al., 2009, Sect. 14.5.1), whereas Algorithm 1 computes one SVD per iteration (Candès et al., 2011, Sect. 5).

B-plotRobust PCA methods differ in the optimization method used to solve principal component pursuit \(\eqref{equ_dict_rpca_pcp}\). Algorithm 1 summarizes one such method, obtained by applying the alternating direction method of multipliers (ADMM). Panel (c) of Fig. 2 shows the scatterplot that PCA delivers from the low-rank matrix ${\mathbf L}$ that Algorithm 1 recovers from the perturbed feature matrix $\widetilde{{\mathbf X}}$. The ten days are back at the coordinates of panel (a). The non-zero entries of $\mathbf{S}$ point at the faulty readings themselves, which is why robust PCA is also used for anomaly detection.

Figure 2 of the entry rpca
Figure 2: Coordinates of the same ten days given by the two features learned by (a) PCA on the clean readings, (b) PCA after one noon reading of day five is increased by $22$ degrees, and (c) PCA on the low-rank matrix $\mL$ that robust PCA recovers from the corrupted readings. A cross marks day five in every panel, a filled circle each of the other nine days. All three panels share one set of axis limits, so the point clouds can be compared directly
Algorithm 1 is a fixed-point iteration \[\big({\mathbf L}^{(t+1)}, \mathbf{S}^{(t+1)}, {\mathbf W}^{(t+1)}\big) = T\big({\mathbf L}^{(t)}, \mathbf{S}^{(t)}, {\mathbf W}^{(t)}\big) \text{,}\] whose operator $T$ chains two proximal operators with the update of the matrix ${\mathbf W}$. Shrinking the singular values of ${\mathbf B}$ by $1/\rho$ is the proximal operator of the nuclear norm (Candès et al., 2011, Eq. (5.3)), which is why that step needs the SVD. Shrinking every entry of ${\mathbf C}$ by $\alpha/\rho$ is the proximal operator of $\left\lVert \cdot \right\rVert_{1}$ (Candès et al., 2011, Eq. (5.2)), the one that solvers for the least absolute shrinkage and selection operator (Lasso) also use and the one step where $\alpha$ enters the iteration. At a fixed point of $T$ the three updates leave the iterate unchanged. A fixed point is reached precisely when ${\mathbf X} = {\mathbf L} + \mathbf{S}$ holds, $({\mathbf L}, \mathbf{S})$ solves principal component pursuit \(\eqref{equ_dict_rpca_pcp}\), and $\rho {\mathbf W}$ is a Lagrange multiplier of the constraint. The optimization problem \(\eqref{equ_dict_rpca_pcp}\) is convex, so the iteration converges for every $\rho > 0$: the residual ${\mathbf X} - {\mathbf L} - \mathbf{S}$ tends to zero and the objective function to its minimum (Boyd et al., 2011, Sect. 3.2). For the averages of the iterates over the first $T$ iterations, this convergence holds with an explicit bound (Beck, 2017, Thm. 15.4).
Algorithm 1 of the entry rpca
Algorithm 1: Principal component pursuit by ADMM (Candès et al., 2011, Sect. 5, Algorithm 1)

See also: principal component analysis, sparse principal component analysis, probabilistic principal component analysis, singular value decomposition, rank, alternating direction method of multipliers, proximal operator, fixed-point iteration, least absolute shrinkage and selection operator, regularization, outlier, anomaly detection, robustness, empirical risk minimization, hypothesis space, loss function, squared error loss.

References

  1. Candès et al. (2011). Robust Principal Component Analysis?. Journal of the ACM. doi.org/10.1145/1970392.1970395
  2. Boyd and Vandenberghe (2004). Convex Optimization. Cambridge Univ. Press. doi.org/10.1017/CBO9780511804441
  3. Hastie et al. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction. Springer Science+Business Media. doi.org/10.1007/978-0-387-84858-7
  4. Boyd et al. (2011). Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers. Found. Trends Mach. Learn.. doi.org/10.1561/2200000016
  5. Beck (2017). First-Order Methods in Optimization. SIAM-Society for Industrial and Applied Mathematics.

Cite this entry

@misc{dictml_rpca,
  author = {Jung, Alexander},
  editor = {Olioumtsevits, Konstantina and Schnoor, Ekkehard},
  title = {robust principal component analysis (robust PCA)},
  howpublished = {Dictionary of Applied Machine Learning (course edition)},
  year = {2026},
  doi = {10.5281/zenodo.21569296},
  note = {ISBN 978-952-64-3013-3, CC BY 4.0, retrieved 2026-11-26},
  url = {https://dictionaryofml.org/terms/rpca.html}
}