Why this session exists
Every clustering scatter in this course has quietly used a trick: our customers live in three dimensions (R, F, M), and your screen has two. Something has been deciding which two directions you get to see - and that something is PCA, running for real in the lab since session 3. Trusting a tool you have not inspected is exactly the habit this course exists to break. Today: the machine that made your axes, when compression helps beyond plotting, and the two prettier cousins that make bigger pictures and bigger lies.
PCA: the best flat shadow 8 min live
Hold a 3D object over a table and it casts a 2D shadow - and DIFFERENT shadows depending on how you turn it. Some shadows are informative (a mug in profile: handle visible), some are useless (the mug from directly above: a circle). PCA finds the turning that casts the most informative flat shadow - the projection that preserves the most spread (variance) in the data. Spread is where the differences between customers live; a projection that keeps spread keeps distinctions.
LiveComponents, in plain words4 min▶
PCA hands back new axes called principal components, with three properties worth saying plainly:
- Each component is a DIRECTION through the original features - a weighted recipe: so much frequency, so much monetary, minus so much recency. Those recipe weights are the loadings, and reading them tells you what the axis means in business terms.
- Components are orthogonal - each new axis is at right angles to all previous ones, so no component repeats information another already captured.
- They arrive ordered by variance explained - PC1 carries the most spread, PC2 the most of what remains, and so on. Compression is just "keep the first few, drop the rest."
On our pile, read the PC1 loadings and a story appears: frequency and monetary point one way, recency points the other. PC1 is roughly an "engagement/value" direction - VIP regulars at one end, lapsed and one-time customers at the other. The axis you have been squinting at since session 3 had a meaning all along.
LiveThe caution: PCA centers, but does NOT scale3 min▶
PCA chases variance - so whichever column has the biggest raw variance owns PC1. Sound familiar? It should: this is session 2's cents disaster wearing a different hat. scikit-learn's PCA automatically centers the data (subtracts each column's mean) but does NOT scale it. Centering is free; scaling is YOUR job, before fit.
Skip it on our pile and the monetary column - thousands of cents against tens of days and orders - dwarfs everything. PC1 becomes "basically the cents column", the variance table declares near-total victory for one component, and the beautiful 2D picture is a picture of a unit choice. Scale first (z-scores, session 2), and the three features compete fairly for the components.
Self-studyWhat PCA never sees2 min▶
Worth saying once, clearly: PCA is fully unsupervised. It never sees cluster labels, planted truth, or business meaning - it sees a cloud of scaled numbers and chases spread. When our five segments come out visibly separate on PC1/PC2, that is not PCA being clever about segments; it is the segments being different ENOUGH, in the scaled features, that the directions of biggest spread happen to run between them. If segments ever looked well-mixed in a PCA view, that would not prove they are fake - it would only mean their differences live in the directions PCA threw away. One more reason the variance receipt matters: it tells you how much room "hidden in the discarded 14%" actually has.
When to compress 6 min live
Three features barely need compressing - our case uses PCA mostly to SEE. But real customer tables have dozens or hundreds of columns, and there compression stops being a plotting convenience and becomes engineering.
LiveThe three jobs, and the price tag6 min▶
Compression earns its place three ways:
- Before clustering: fewer, decorrelated dimensions. Distance-based algorithms like k-means behave better when redundant, correlated columns are not double-counting the same behavior - PCA hands you axes with the redundancy squeezed out.
- Visualization: what we have been doing all course. High-dimensional pile, two-dimensional screen; PCA picks the least-lossy flat view.
- Noise reduction: the last components often carry measurement jitter rather than structure. Dropping them can clean the signal - compression as a filter.
How many components to keep? The working rule of thumb: keep components until the cumulative variance explained is enough for your purpose. On our pile PC1+PC2 = 86% - comfortably enough to see five segments, as the lab will show.
And the price, stated honestly: we left 14% of the story on the floor - real differences between customers that the flat picture cannot show. And we traded interpretability: a principal component is a MIX of features, not a feature. "Days since last order" is a column you can point at; "a weighted blend of F and M minus some R" needs a paragraph. Compression is a purchase, and the variance table is the receipt.
Self-studyReading the receipt in the wild2 min▶
"Enough" cumulative variance is a purpose question, not a universal threshold. For a projector slide meant to show rough structure, a lower share can serve; for feeding a clustering pipeline whose output ships to marketing, you want the receipt high enough that you can defend what was discarded. Two habits transfer to any dataset: first, always look at how the percentages DECAY - a steep drop after a few components means the data is internally redundant and compresses gracefully, while a flat, even spread means every component carries real story and compression will be bloody. Second, say the discarded share out loud in reviews ("this view drops 14% of the variance") - the sentence costs nothing and inoculates the room against treating the picture as the whole truth.
t-SNE and UMAP: beautiful, useful, not to be trusted literally 6 min live
PCA's shadows are honest but stiff - straight-line projections only. t-SNE and UMAP are nonlinear embeddings that bend space to keep neighbors together, producing the gorgeous cluster islands you see in every ML blog post. They exist for one purpose: visualization of high-dimensional data, period. The danger is that the pictures are so vivid that people read them as maps. They are not maps.
LiveThe verified honesty list4 min▶
None of this is folklore - it comes from the sources closest to the tools:
- t-SNE cluster SIZES are meaningless. The algorithm equalizes density, so a huge diffuse group and a tiny tight one can render as similar-sized islands. Distill's "How to Use t-SNE Effectively" demonstrates this interactively.
- t-SNE inter-cluster DISTANCES may mean nothing. Two islands far apart in the plot are not necessarily far apart in reality - same Distill source, same interactive proof.
- Low perplexity makes pure noise look clustered. Turn the perplexity knob down and random uniform points sprout convincing clumps - the algorithm's most dangerous party trick, and session 9's theme in miniature.
- UMAP's own FAQ blesses clustering on UMAP output only "yes, with care" - and the care is specific: use a density-based method like HDBSCAN, NOT k-means, because UMAP does not preserve density. When a tool's own authors put a warning label on a use case, the warning is the documentation.
The working rule, on one line: PCA to compress and feed algorithms; t-SNE/UMAP to LOOK; never read embedding distances or sizes as facts.
| Tool | What it preserves | Use it to |
|---|---|---|
| PCA | straight-line projection of global spread - honestly lossy, receipt attached | compress, decorrelate, and feed algorithms |
| t-SNE | local neighborhoods; sizes equalized, gaps distorted | look at high-D data and form hypotheses |
| UMAP | local structure; density NOT preserved | look; cluster only "with care" - HDBSCAN, not k-means |
Self-studyWhy we still love them2 min▶
After all those warnings, the honest counterweight: for LOOKING at genuinely high-dimensional data - text embeddings, image features, hundreds of behavioral columns - nonlinear embeddings routinely reveal neighborhood structure that PCA's flat shadow smears together. The pros' posture is not "never use t-SNE"; it is "use it to generate hypotheses, then verify every hypothesis in the original features." The plot is the question, never the answer. StatQuest's t-SNE and UMAP videos are a gentle next step if you want the mechanics.
The projection lab 🥭 ★ 18 min · meet your own axes
The lab below runs REAL PCA on the scaled 300-customer sample - the exact computation that has been drawing your axes since session 3. Today you finally read its receipt.
Look at the scatter - it IS the projection. Three scaled features (R, F, M) flattened onto two principal components. The colors are the PLANTED truth, shown so you can judge what survived the flattening. Real projects get these dots in one anonymous color.
Read the variance table. PC1 50%, PC2 37%, PC3 14% - so PC1+PC2 carry 86% of the pile's total spread. That one row is the entire justification for trusting a 2D picture of 3D customers.
Count what compression kept. Three features became two axes, and the five planted segments are still visibly separate blobs. That is compression WORKING: 86% of the variance turned out to be enough to preserve the structure we care about.
Note what died. 14% of the variance is simply gone from this picture - and so is the ability to point at an axis and say "that is frequency." Every axis is now a mix. The plot got possible; the axes got abstract. That trade is permanent.
Connect backwards. Every clustering scatter since session 3 was THIS projection - same PCA, same axes, same 86%. You have been trusting it all along without knowing why; now you have seen the receipt, you know it earned that trust.
Homework 📝 ◐ 20 minutes
- Explain PCA-as-shadow to a colleague - the mug and its shadows, why the most-spread shadow is the most informative, and what "PC1+PC2 = 86%" means on our pile. If they can explain why you scale FIRST, you taught it well.
- Find a t-SNE or UMAP plot in the wild - a paper, a blog post, a vendor deck - and check the caption against the do/do-not card: does it read cluster sizes or inter-cluster distances as facts? You will be surprised how often the answer is yes.
- Compute the receipt for your own data: take a dataset you know and work out (or estimate) how many principal components it would need to keep 80% of the variance. Two? Ten? The answer tells you how compressible - how internally redundant - your data really is.
Three questions before you go 🎯 ◐ 90 seconds
1 · PCA chooses its first component as the direction that...
Variance is the whole objective: spread is where distinctions between customers live, so the max-variance shadow is the least-lossy one. PCA never sees labels (it is unsupervised), and B describes what people WISH it did. C is what happens when you forget to scale - a bug, not the design.
2 · You run sklearn's PCA on the raw Mango Lane table, monetary still in cents. What happens?
Centering is automatic; scaling is on you. Nothing errors, the variance table looks crisp, and PC1 is basically the cents column - session 2's disaster reborn. Scale first, always.
3 · Which claims can a t-SNE plot NOT support?
t-SNE equalizes density (sizes meaningless) and distorts global geometry (inter-cluster distances may mean nothing) - both demonstrated interactively in Distill's "How to Use t-SNE Effectively". Neighborhoods and hypotheses: yes. Measurements: never.
What this session covered from the official universe
Certificates, videos, and graded assessments stay with the official providers - this course teaches the working core with a live in-browser lab.