Clustering and dimensionality reduction
Explore unlabeled data with distance, density and projections.
Cluster customer embeddings after choosing a meaningful scaling and distance.
Interview questions
Choose a question to reveal its answer.
01EasyCoreVisualHow does K-means optimize its objective?
Answer
How does K-means optimize its objective?
Partitions observations into k groups to minimize within-cluster squared distances.
Assign points to centroids and update centroids iteratively.
from sklearn.cluster import KMeans
X = [[0,0], [0,1], [8,8], [9,8]]
m = KMeans(n_clusters=2, n_init=10, random_state=42).fit(X)
print(m.cluster_centers_)Cluster labels themselves are arbitrary.
02EasyCoreHow is a K-means centroid updated?
Answer
How is a K-means centroid updated?
Arithmetic mean of points assigned to a cluster in K-means.
Recompute a cluster center after assignment.
03EasyCoreWhen is DBSCAN preferable to K-means?
Answer
When is DBSCAN preferable to K-means?
Density-based clustering that identifies dense regions and can label noise.
Find irregularly shaped clusters without fixing the number beforehand.
04MediumHigh priorityWhat is epsilon in DBSCAN?
Answer
What is epsilon in DBSCAN?
DBSCAN neighborhood radius used in density calculations.
Increase the radius used to consider nearby points.
05MediumHigh priorityWhat is a core point in DBSCAN?
Answer
What is a core point in DBSCAN?
DBSCAN parameter specifying the neighborhood count required for a core point.
Demand stronger local density before declaring a core point.
06MediumHow does hierarchical clustering work?
Answer
How does hierarchical clustering work?
Builds nested cluster relationships, commonly by progressively merging groups.
Inspect a dendrogram to choose a grouping level.
07MediumHow do you interpret a silhouette score?
Answer
How do you interpret a silhouette score?
Compares within-cluster cohesion with nearest-other-cluster separation; values range from minus one to one.
Evaluate whether assigned clusters are compact and separated.
08MediumHow does PCA reduce dimensionality?
Answer
How does PCA reduce dimensionality?
Linear projection onto orthogonal directions of greatest variance.
Compress correlated features while retaining major variation.
09HardHow do you choose the number of PCA components?
Answer
How do you choose the number of PCA components?
Fraction of total variance explained by a principal component.
Choose how many PCA dimensions to retain.
10HardWhy does scaling matter for distance-based clustering?
Answer
Why does scaling matter for distance-based clustering?
Transforms feature magnitudes so units do not dominate distances.
Put height and salary on comparable scales before K-means.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.