Skip to content

Keep the direction that carries the variation.

Move a three-dimensional point cloud onto its first principal component and inspect the lost directions.

Preparing the 3D view…

Find the long direction

The centered synthetic cloud is built from independent, symmetric offsets along three orthogonal axes. Its largest variance is along u = (1,1,0)/√2, shown in green.

Project onto one component

Move the control to one to replace each point with u(uᵀx). Faint segments connect the original points to their projections. Intermediate values animate this geometric transition; they are not alternate fitted PCA models.

Understand what is discarded

PCA preserves variance, not class labels or task relevance. The principal axis is exact for this authored dataset. This example does not estimate components from an uploaded dataset or demonstrate a downstream quality improvement.

The equation behind the motion

u = (1,1,0)/√2; x̂ = u(uᵀx)

Synthetic inputs with explicit geometric assumptions. Rotate the view and inspect the model above.

Read the primary source

Rotate the projection. Measure what survives.

Project a centered cloud onto a line. The principal direction preserves the most squared distance from the mean.

1 of 4

Reduced motion is on. Use Previous and Next to inspect each state.

Choose a projection directionProject eight centered points onto a horizontal line. Violet points are data; green points are reconstructions. 0° · 50.0% variance retainedDataReconstructionMean squared error1.311

x̂ = u(uᵀx)

0° · 50.0% variance retained

Choose a projection direction

Project eight centered points onto a horizontal line. Violet points are data; green points are reconstructions.

Explore the inputs and calculations
x₀x₁
Variance retained 95.3%Mean squared reconstruction error: 0.123

Violet dots are original points. Green dots are reconstructions. The connecting segments are discarded components, perpendicular to the line.

Inspect the projection

u = [0.707, 0.707]. Each reconstruction is u(uᵀx). The mean is zero, so total squared length splits into retained length and reconstruction error.

Original points
-1.167-1.662
-1.662-1.167
-0.46-0.955
-0.955-0.46
0.9550.46
0.460.955
1.6621.167
1.1671.662
Reconstructed points
-1.414-1.414
-1.414-1.414
-0.707-0.707
-0.707-0.707
0.7070.707
0.7070.707
1.4141.414
1.4141.414
Why is the direction at 225° just as good as 45°?

A principal component’s sign is arbitrary. Replacing u with −u leaves uuᵀx unchanged, so reconstruction and retained variance are identical.

Eight symmetric, centered points with a known covariance. This is orthogonal projection without whitening or feature standardization. The line at 45° is the first principal direction for this dataset only.

scikit-learn PCA guideRead the full explanation