skip to content

Clustering and Dimensionality Reduction

You will learn how to find structure without labels — partitioning, density, and mixture views of clustering — and how PCA compresses features while keeping variance. Interviewers probe k-means assumptions, how you pick k, and when PCA helps versus when it destroys interpretability.

on this pageshow

explore

questions

page 2 of 2

Your k-means inertia curve on a 1.2M-row call-detail table bends nowhere - what do you conclude?

level: seniorimportance: should knowfreq 44%

basics

~20 s

A smoothly falling inertia curve with no bend usually means the data is a continuum with no separated groups at any k. Confirm it with the gap statistic, which compares the curve against clusterings of a structureless reference sample and can return k=1.

open as a page

In random projection, what sets the target dimension for a 100,000-column feature matrix?

level: seniorimportance: should knowfreq 33%

basics

~20 s

The Johnson-Lindenstrauss bound sets it from the number of points and the distortion you accept, roughly log(n) divided by epsilon squared. The original 100,000 columns do not appear in the bound at all, and the bound itself is conservative.

open as a page

How would you use resampling to test whether a k=4 clustering reflects real structure?

level: seniorimportance: should knowfreq 37%

basics

~20 s

Re-cluster many random subsamples of the data and measure how much the resulting partitions agree with each other, usually as the mean pairwise adjusted Rand index over the points any two subsamples share. Tight, high agreement suggests reproducible structure.

open as a page

How do BIC and AIC choose the number of components for a Gaussian mixture?

level: seniorimportance: should knowfreq 44%

basics

~10 s

Fit a mixture for each candidate component count and score it by a penalised log-likelihood: AIC charges 2 per free parameter, BIC charges log(n). Lower wins, so BIC selects fewer components than AIC.

open as a page

Why does average silhouette rank a round four-way split of two interleaved spirals above the correct partition?

level: seniorimportance: should knowfreq 43%

basics

~20 s

Silhouette rewards points near their own cluster mates and far from the nearest other cluster. Along a spiral the far end of your own arm is distant while a neighbouring arm is close, so compact round chunks win.

open as a page

On a silhouette plot the average is 0.42 but one cluster's bars are negative and another's are all short — what does that tell you?

level: seniorimportance: should knowfreq 46%

basics

~20 s

The negative-bar cluster holds points that are on average closer to another cluster, so it overlaps a neighbour. The short-bar cluster sits on a boundary with no space of its own. A respectable-looking average of 0.42 is being carried by the healthy clusters.

open as a page

Why does k-means cut one elongated band of points into three round clusters?

level: seniorimportance: should knowfreq 50%

basics

~10 s

k-means minimises total squared distance to cluster centres, so it rewards compact, roughly round groups. An elongated band has large spread along its long axis, so slicing it crosswise lowers that objective.

open as a page

When is mini-batch k-means the right call on a 50M-row clickstream, and what does it cost you?

level: seniorimportance: should knowfreq 38%

basics

~20 s

Mini-batch k-means earns its place when the data will not fit in memory or a full pass per iteration is too slow: it updates centres from small random batches. You pay with a slightly worse, noisier solution.

open as a page

Why does agglomerative clustering fail on 200,000 rows, and what would you do instead?

level: seniorimportance: should knowfreq 42%

basics

~20 s

Agglomerative clustering needs distances between all pairs: 200,000 rows means about 20 billion pairs, roughly 160 GB at 8 bytes each. Practical routes are subsampling and assigning the rest, clustering micro-cluster centroids, or restricting merges to a neighbour graph.

open as a page

Why would a classifier get worse after PCA retained 95% of the input variance?

level: seniorimportance: should knowfreq 46%

basics

~20 s

PCA ranks directions by how much the inputs vary, never by how much they predict the label. A discriminative direction with small variance can sit entirely in the discarded 5%, so retained variance and retained signal are different quantities.

open as a page

You re-run a customer segmentation quarterly and 30% of customers changed segment - is that a problem?

level: seniorimportance: should knowfreq 44%

basics

~20 s

Not by itself. Customers moving between segments is the segmentation working, as long as the segment definitions were held fixed. The expensive problem is re-fitting definitions each run, so every segment name silently changes meaning.

open as a page

A topic model's coherence peaks at 18 topics while held-out perplexity keeps improving — how do you choose K?

level: seniorimportance: should knowfreq 42%

basics

~20 s

The two metrics answer different questions. Perplexity measures held-out predictive fit and usually keeps improving as topics multiply; coherence measures whether a topic's top words really co-occur. If humans read the topics, follow coherence and inspect the top words yourself.

open as a page

Can new rows be dropped onto an existing t-SNE map, or must it be refit?

level: seniorimportance: should knowfreq 40%

basics

~20 s

t-SNE has no mapping from feature space to map space: it optimises the coordinates of the rows it was given, so new rows force a full refit and a different layout. UMAP can place new rows into a frozen existing embedding.

open as a page

Extract 100 projected components or select 100 of 1,000 original columns for a latency budget?

level: principalimportance: should knowfreq 40%

basics

~20 s

Selection cuts what you must collect and keeps every input explainable; extraction keeps signal spread thinly across all 1,000 columns but still requires computing every one of them at serving time. If the latency is upstream, only selection helps.

open as a page

When does kernel PCA find structure that ordinary linear PCA cannot?

level: middleimportance: nice to knowfreq 24%

basics

~20 s

When the structure is curved. Linear PCA can only rotate axes and drop some, so a manifold that folds back on itself is flattened into an overlapping smear. Kernel PCA works from pairwise similarities, so its components can bend.

open as a page

What do the Davies-Bouldin and Calinski-Harabasz indices measure, and why can they rank two partitions oppositely?

level: middleimportance: nice to knowfreq 31%

basics

~20 s

Davies-Bouldin averages, over clusters, the worst ratio of two clusters' spreads to the distance between their centroids, and lower is better. Calinski-Harabasz is a between-cluster over within-cluster dispersion ratio, and higher is better. Different aggregations can rank partitions oppositely.

open as a page

In fuzzy c-means, what do the membership values and the fuzzifier m control?

level: middleimportance: nice to knowfreq 20%

basics

~20 s

Fuzzy c-means gives every point a membership in every cluster, non-negative and summing to one, so a borderline point reads 0.55/0.45 instead of being forced into one group. The fuzzifier m sets how soft those memberships are.

open as a page

A dense core and a diffuse halo break DBSCAN's single eps — how does HDBSCAN fix that?

level: seniorimportance: nice to knowfreq 34%

basics

~20 s

One global eps encodes a single notion of dense, so it cannot be tight enough for a core and loose enough for a halo. HDBSCAN sweeps all radii instead and keeps the clusters that persist longest.

open as a page

Why can a Gaussian mixture's log-likelihood run to infinity during EM, and how do you stop it?

level: seniorimportance: nice to knowfreq 34%

basics

~20 s

A component can centre on a few near-identical rows and shrink its covariance toward zero, so their density diverges and the likelihood is unbounded above. Fix it with a covariance floor or a restricted covariance form.

open as a page

What is cophenetic correlation, and how would you use it to compare two linkage methods?

level: seniorimportance: nice to knowfreq 24%

basics

~20 s

The cophenetic distance between two observations is the height at which they first join in the tree. Cophenetic correlation is the correlation between those tree distances and the original pairwise distances; the higher-scoring tree distorts the input geometry less.

open as a page

One of your six customer segments holds 37 of 400,000 customers - what do you do with it?

level: seniorimportance: nice to knowfreq 33%

basics

~20 s

Inspect those 37 records individually first - a group that small is usually outliers, test accounts or a data fault. Either way, no campaign can economically address 37 people, so absorb them into the nearest segment or document them as exclusions.

open as a page

Should 2-D t-SNE or UMAP coordinates be used as features for a downstream model?

level: seniorimportance: nice to knowfreq 26%

basics

~20 s

For t-SNE, no: it produces no reusable mapping, its layout changes run to run, and two coordinates discard almost everything. A frozen UMAP embedding fit only on training folds can be defensible; treat it as a modelling choice.

open as a page

How do you decide an unsupervised anomaly detector is good enough to send alerts to analysts?

level: principalimportance: nice to knowfreq 38%

basics

~20 s

Judge the top of the ranking, not the whole model. Have experts review the highest-scored items, measure precision at that k, check the ranking is stable across refits, and accept that recall stays unknown until labels accumulate.

open as a page

A clustering sweep suggests k=9 but operations can staff only 4 playbooks - how do you set k?

level: principalimportance: nice to knowfreq 31%

basics

~20 s

The staffing ceiling is a hard constraint and the sweep is advisory, so k is a design decision. Usually the best move is to cluster at the finer k and define a many-to-one mapping from those groups onto the four playbooks, keeping the structure while satisfying operations.

open as a page

A clustering of 8,000 merchants scores ARI 0.18 against merchant-category codes yet is stable under resampling — how do you judge it?

level: principalimportance: nice to knowfreq 26%

basics

~20 s

The two numbers answer different questions. Stability says the structure reproduces; a low adjusted Rand index says it does not reproduce that particular taxonomy. Neither is a verdict — the verdict comes from what the clustering was built to support.

open as a page

How do you justify a PCA-based credit score to a regulator asking which ratio drove it?

level: principalimportance: nice to knowfreq 30%

basics

~20 s

Each principal component is a weighted blend of every input ratio, so per-component reasons are useless to an applicant. If the model on top is linear, compose the loadings with its coefficients to recover one exact weight per ratio.

open as a page

Every retrain of a production topic model returns different topics — how do you deliver something stakeholders can trust?

level: principalimportance: nice to knowfreq 28%

basics

~20 s

Topic models are not identifiable: random initialisation, a chosen topic count and shifting text mean each refit gives different, differently numbered topics. Freeze one fitted model as the published taxonomy, refit on a deliberate schedule, and review changes with humans.

open as a page

showing 31–57 of 57