Six Dimensions Down to Three

Dimensionality Reduction & EmbeddingsEasy+10 XP+10

Six Dimensions Down to Three

PCA has to build the covariance matrix and find its eigenvectors before it can shrink anything. A much cheaper alternative is a random projection: multiply every point by a matrix of random numbers and keep the result. It makes no attempt to find the best directions, yet distances between points often come out nearly unchanged.

Here is a small version. Two customers are described by 6 features each:

xA=(5, 1, 3, 0, 4, 2),xB=(1, 3, 1, 2, 2, 0)\mathbf{x}_A = (5,\ 1,\ 3,\ 0,\ 4,\ 2), \qquad \mathbf{x}_B = (1,\ 3,\ 1,\ 2,\ 2,\ 0)xA​=(5, 1, 3, 0, 4, 2),xB​=(1, 3, 1, 2, 2, 0)

A 3×63 \times 63×6 matrix RRR was filled with random numbers, drawn from a bell curve centred at 0 with spread 1:

R=[−0.1−0.3−0.8−0.5−0.50.9−1.01.51.1−0.7−0.8−1.80.90.71.70.30.4−0.3]R = \begin{bmatrix} -0.1 & -0.3 & -0.8 & -0.5 & -0.5 & 0.9 \\ -1.0 & 1.5 & 1.1 & -0.7 & -0.8 & -1.8 \\ 0.9 & 0.7 & 1.7 & 0.3 & 0.4 & -0.3 \end{bmatrix}R=​−0.1−1.00.9​−0.31.50.7​−0.81.11.7​−0.5−0.70.3​−0.5−0.80.4​0.9−1.8−0.3​​

Each point is squeezed from 6 dimensions down to 3 by

z=13 R x\mathbf{z} = \frac{1}{\sqrt{3}}\, R\,\mathbf{x}z=3​1​Rx

The factor 1/31/\sqrt{3}1/3​, one over the square root of the number of rows, keeps lengths on the same scale on average.

How well did this projection keep the distance between the two customers? Compute

∥zA−zB∥∥xA−xB∥\frac{\lVert \mathbf{z}_A - \mathbf{z}_B \rVert}{\lVert \mathbf{x}_A - \mathbf{x}_B \rVert}∥xA​−xB​∥∥zA​−zB​∥​

using ordinary Euclidean distance, and round to 3 decimal places.

Hints

Solve it to unlock the solution

Once you get it right, the reasoning behind the answer shows up here.