Principal component analysis
Find orthogonal directions that explain the greatest variance in centred data.
The observations vary mainly along a diagonal direction.
Centring makes the mean the origin for the covariance calculation.
The mint axis is computed from the covariance matrix. Projection removes each point’s perpendicular component.
Two-dimensional observations become one scalar per sample. Variation perpendicular to the chosen axis is discarded.
Project samples onto the retained directions.
Mean, covariance direction and projections are computed from the displayed samples.
Try it on an image
Experiment at pixel level
Project BGR colour vectors into fewer principal components, then reconstruct the image. Components are learned from this image’s colour distribution.
The engine loads on your first run. Your images stay in this browser.
Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.
Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Select a pixel
Select a pixel
When to use it
Reduce descriptor dimensionality, compress correlated features or visualize a dataset.
How it works
- 01Subtract the training mean.
- 02Find covariance eigenvectors ordered by explained variance.
- 03Project samples onto the retained directions.
projection = (sample − mean) · retained basis
What to tune
maxComponents or retainedVariance selects dimensionality. Scale heterogeneous features before fitting when units differ.
Where it breaks down
Large variance is not always task-relevant information. Use the training mean and basis consistently on later data.
TypeScript API
Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.
All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.
Related methods
K-means clustering
Partition feature vectors around a fixed number of learned centres.
Support vector machines
Learn a decision boundary that balances class separation against margin violations.
K-nearest-neighbour classification
Predict a sample from the labels or values of nearby training examples.
Random forests
Combine decisions from trees that split feature space into regions.