Random Projection

Machine Learning
Introduced by
Johnson & Lindenstrauss (lemma); Achlioptas (sparse variant)
Year
1984
Type
Linear, data-oblivious dimensionality reduction
Family
Dimensionality reduction

What does it do?

Random projection reduces dimensionality by multiplying the data by a random matrix.

It relies on the Johnson-Lindenstrauss lemma (1984), which states that projecting onto enough random directions approximately preserves all pairwise distances. Unlike PCA, the projection does not analyse the data: the matrix is drawn at random and is data-oblivious. This makes the method very cheap and suited to very high-dimensional data, and to settings where the projection must be fixed in advance, such as streams.

The intuition behind the method

It seems reckless to compress data by multiplying it with random numbers, yet the Johnson-Lindenstrauss lemma says it can work: if you project points onto enough random directions, the distances between them change only slightly. A random low-dimensional projection of a high-dimensional point set can preserve its pairwise geometry with high probability. So you skip the eigen-analysis that PCA requires, draw one random matrix, and apply a single matrix multiply to obtain a smaller representation in which distance-based relationships are largely retained.

History

The Johnson-Lindenstrauss lemma (1984) established the distance-preservation result on which the method rests; it was stated for Lipschitz mappings into a Hilbert space. Achlioptas (2003) showed that sparse ±1 matrices with simple discrete entries also satisfy the guarantee, which makes the construction cheap to store and multiply.

When to use it

Use random projection when dimensionality is so high that data-dependent methods such as PCA are too slow or memory-heavy, when data arrive as a stream and the projection must be fixed in advance, or as a fast preprocessing step before clustering, nearest-neighbour search or learning on high-dimensional feature vectors such as text or image features. Do not use it when interpretability matters or when the most informative low-dimensional axes are needed; PCA is the better choice there. Avoid it when the target dimension is so small for the number of points and tolerance that the JL bound no longer gives a distance guarantee. Its distance preservation is approximate within ε, and results vary slightly with the random seed. Assumptions: the guarantee concerns Euclidean (L2) distances among a fixed, finite set of n points, with ε in (0,1) in the usual statement. The matrix must be drawn independently of the data. ε and the failure probability δ determine the target dimension. The lemma gives no guarantee for other distances or similarity measures, such as L1 or cosine.

Limitations and considerations

  • Preserves distances only approximately (within tolerance ε).
  • Does not identify meaningful/important directions like PCA — less interpretable.
  • May need more target dimensions than PCA for the same fidelity.
  • Result depends on the random seed (mildly non-deterministic).

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Extremely fast and memory-light — a single random matrix multiply, no training.
  • Theoretically grounded: the JL lemma guarantees approximate distance preservation.
  • Data-oblivious, so it works for streaming and privacy-sensitive settings.
  • Target dimension scales with the number of points, not the original dimension.

Applications

  • Dimensionality reduction of high-dimensional text or image feature vectors before downstream analysis.
  • Preprocessing before clustering or approximate nearest-neighbour search, where pairwise distance relationships need to be kept.
  • Streaming or online settings in which a fixed projection is applied to each incoming vector.
  • Reducing the computational cost of learning on data with very many features.

How it works

How it works

1

The Johnson-Lindenstrauss lemma states that n points in high dimension can be mapped to k = O(ln n / ε²) dimensions such that all pairwise Euclidean distances are preserved within a factor of 1 ± ε. The O-notation hides a constant that depends on the construction, so k should be computed from an explicit bound rather than guessed. For a Gaussian matrix W with independent standard normal entries and a fixed vector x, P(|‖(1/√k)Wx‖²/‖x‖² − 1| > ε) ≤ 2·exp(−ε²k/6) for ε in (0,3). Applying a union bound over all n(n−1)/2 pairs gives a sufficient condition for preserving every pairwise distance with probability at least 1 − δ: k ≥ 6·ln(n(n−1)/δ)/ε². The required dimension depends on the number of points, the tolerance ε and the failure probability δ, not on the original dimension.

Formula
\Pr\!\left[\left|\dfrac{\lVert \tfrac{1}{\sqrt{k}}Wx\rVert^2}{\lVert x\rVert^2}-1\right|>\epsilon\right]\le 2e^{-\epsilon^2 k/6};\ \ k\ge \dfrac{6\ln\!\left(n(n-1)/\delta\right)}{\epsilon^2}\ \text{preserves all pairwise distances within } 1\pm\epsilon\ \text{w.p.}\ge 1-\delta
2

Construct a random k × d projection matrix R. Entries can be drawn from a standard Gaussian distribution, which is the case the bound above covers. Sparse variants, as in Achlioptas's construction with simple discrete entries, are cheaper to store and multiply and also satisfy a Johnson-Lindenstrauss guarantee. Their entry distribution fixes the correct normalisation, so use the scaling prescribed for the specific construction. The matrix is drawn once and is independent of the data.

Formula
R \in \mathbb{R}^{k\times d},\ R_{ij}\sim \mathcal{N}(0,1)\ \text{(sparse discrete entries: see Achlioptas, with matching scaling)}
3

Each data vector x is projected as x' = (1/√k)·R·x for a Gaussian R with unit-variance entries. This is a single matrix multiplication, with no fitting, no covariance estimation and no iteration. The scaling makes the expected squared norm of the projection equal to that of the original vector. Sparse constructions need the normalisation matching their entry distribution.

Formula
x' = \dfrac{1}{\sqrt{k}}\,R\,x \in \mathbb{R}^{k}\ \text{(Gaussian } R\text{)}
4

Two separate statements apply. For each fixed vector x, the expected squared norm is preserved: E[‖x'‖²] = ‖x‖². Beyond this, with probability at least 1 − δ, every pairwise distance among the n points lies within 1 ± ε of its original value, by the union bound over pairs. Distance-based tasks such as nearest-neighbour search and clustering can therefore be run in the reduced space, with distances that approximate the original ones.

Formula
\mathbb{E}\lVert x'\rVert^2=\lVert x\rVert^2;\ \ \Pr\!\left[\forall i,j:\ \lVert x'_i-x'_j\rVert \in (1\pm\epsilon)\lVert x_i-x_j\rVert\right]\ge 1-\delta

Common pitfalls

  • Choosing too small a target dimension k and breaking the distance guarantee.
  • Guessing k instead of computing it from n, ε and δ.
  • Expecting interpretable components: random axes carry no inherent meaning.
  • Using the wrong scaling for the entry distribution (for example 1/√k with a sparse matrix whose entries do not have unit variance), which distorts projected distances.
  • Assuming the guarantee covers non-Euclidean distances or point sets chosen after seeing the matrix.
  • Comparing runs across seeds without noting the inherent randomness.

Frequently asked questions

How is random projection different from PCA?

PCA finds the data-dependent directions of maximum variance via eigen-decomposition; random projection uses random, data-oblivious directions and a distance-preservation guarantee. PCA is more informative and compact per dimension but slower and memory-heavy; random projection is far cheaper and scales better, at the cost of interpretability and exactness.

How many dimensions do I need?

It scales as O(ln n / ε²), where n is the number of points and ε the allowed distortion, independent of the original dimension. For a Gaussian matrix, a sufficient choice is k ≥ 6·ln(n(n−1)/δ)/ε², where δ is the allowed failure probability. The constant depends on the construction, so compute k from n, ε and δ rather than guessing; small ε requires a large k.

Why use sparse random matrices?

Achlioptas showed that simple sparse matrices with discrete entries still satisfy the JL guarantee while being much cheaper to store and multiply. This 'database-friendly' construction makes random projection fast and practical on large, high-dimensional datasets. Use the normalisation specified for the chosen entry distribution.

Related methods

Sources

  1. Johnson, W. B., & Lindenstrauss, J. (1984). Extensions of Lipschitz mappings into a Hilbert space. Contemporary Mathematics, 26, 189–206.

    Open DOI reference
  2. Achlioptas, D. (2003). Database-friendly random projections: Johnson-Lindenstrauss with binary coins. Journal of Computer and System Sciences, 66(4), 671–687.

    Open DOI reference
  3. Understanding Machine Learning: Theory, Algorithms, p. 329