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 pageshowhide
explore
- Partitioning and Choosing k11 questions
- k-Means and Lloyd's Algorithm3 questions
- Choosing the Cluster Count4 questions
- k-Means Variants4 questions
- Density, Hierarchy and Mixtures17 questions
- DBSCAN and HDBSCAN3 questions
- Linkage and Dendrograms5 questions
- Gaussian Mixtures and EM5 questions
- Unsupervised Anomaly Detection4 questions
- Cluster Validity13 questions
- Silhouette and Internal Indices5 questions
- External Agreement and Stability4 questions
- Segmentation and Profiling4 questions
- Linear and Manifold Projections16 questions
- PCA and Explained Variance4 questions
- t-SNE and UMAP4 questions
- Discriminant and Random Projections4 questions
- Topic Models and NMF4 questions
questions
page 2 of 2Your k-means inertia curve on a 1.2M-row call-detail table bends nowhere - what do you conclude?
basics
~20 sA 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.
In random projection, what sets the target dimension for a 100,000-column feature matrix?
basics
~20 sThe 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.
How would you use resampling to test whether a k=4 clustering reflects real structure?
basics
~20 sRe-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.
How do BIC and AIC choose the number of components for a Gaussian mixture?
basics
~10 sFit 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.
Why does average silhouette rank a round four-way split of two interleaved spirals above the correct partition?
basics
~20 sSilhouette 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.
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?
basics
~20 sThe 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.
Why does k-means cut one elongated band of points into three round clusters?
basics
~10 sk-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.
When is mini-batch k-means the right call on a 50M-row clickstream, and what does it cost you?
basics
~20 sMini-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.
Why does agglomerative clustering fail on 200,000 rows, and what would you do instead?
basics
~20 sAgglomerative 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.
Why would a classifier get worse after PCA retained 95% of the input variance?
basics
~20 sPCA 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.
You re-run a customer segmentation quarterly and 30% of customers changed segment - is that a problem?
basics
~20 sNot 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.
A topic model's coherence peaks at 18 topics while held-out perplexity keeps improving — how do you choose K?
basics
~20 sThe 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.
Can new rows be dropped onto an existing t-SNE map, or must it be refit?
basics
~20 st-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.
Extract 100 projected components or select 100 of 1,000 original columns for a latency budget?
basics
~20 sSelection 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.
When does kernel PCA find structure that ordinary linear PCA cannot?
basics
~20 sWhen 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.
What do the Davies-Bouldin and Calinski-Harabasz indices measure, and why can they rank two partitions oppositely?
basics
~20 sDavies-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.
In fuzzy c-means, what do the membership values and the fuzzifier m control?
basics
~20 sFuzzy 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.
A dense core and a diffuse halo break DBSCAN's single eps — how does HDBSCAN fix that?
basics
~20 sOne 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.
Why can a Gaussian mixture's log-likelihood run to infinity during EM, and how do you stop it?
basics
~20 sA 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.
What is cophenetic correlation, and how would you use it to compare two linkage methods?
basics
~20 sThe 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.
One of your six customer segments holds 37 of 400,000 customers - what do you do with it?
basics
~20 sInspect 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.
Should 2-D t-SNE or UMAP coordinates be used as features for a downstream model?
basics
~20 sFor 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.
How do you decide an unsupervised anomaly detector is good enough to send alerts to analysts?
basics
~20 sJudge 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.
A clustering sweep suggests k=9 but operations can staff only 4 playbooks - how do you set k?
basics
~20 sThe 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.
A clustering of 8,000 merchants scores ARI 0.18 against merchant-category codes yet is stable under resampling — how do you judge it?
basics
~20 sThe 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.
How do you justify a PCA-based credit score to a regulator asking which ratio drove it?
basics
~20 sEach 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.
Every retrain of a production topic model returns different topics — how do you deliver something stakeholders can trust?
basics
~20 sTopic 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.
showing 31–57 of 57