Back to Evaluation, Leakage, and Unsupervised

Clustering and Dimensionality Reduction

Unsupervised: find structure without labels. The four most-used techniques. FIND_VIDEO: search 'k-means hierarchical PCA UMAP' — recommended channel: StatQuest. Aim for 11 min or under.

9 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. Introduction to K-meansK-means clustering is introduced as a method to group samples based on similarity.
  2. Steps 1-2: InitializationThe process begins by selecting K (number of clusters) and randomly selecting K initial data points.
  3. Steps 3-4: AssignmentEach point is assigned to the nearest cluster center by measuring the distance to all initial clusters.
  4. Step 5: RecalculationThe mean of each newly formed cluster is calculated, and points are reassigned based on these new means.
  5. Handling Suboptimal RunsThe algorithm repeats the clustering process with different starting points to find the lowest total variation.
  6. Selecting K: Elbow PlotThe total variation is plotted against K values, and the optimal K is chosen at the 'elbow' where variance reduction slows.
  7. K-means vs HierarchicalK-means requires a specified number of clusters, unlike hierarchical clustering which focuses on pair-wise similarity.
  8. Multi-Dimensional DataK-means works in multiple dimensions by using Euclidean distance, which is equivalent to the Pythagorean theorem.
  9. Clustering HeatmapsHeatmap data can be clustered by treating samples as axes and calculating N-dimensional Euclidean distance between points.
PDF notes

Frequently asked questions

How do you figure out what value to use for K?

Try different values for K and plot the reduction in total variation (the elbow plot). Select the K where the reduction in variation significantly slows down.

Why does K-means run multiple times?

K-means starts with random initial clusters, which can lead to suboptimal results. Running it multiple times allows the algorithm to find the clustering with the lowest total variation.

How is K-means different from hierarchical clustering?

K-means forces the data into a specific number (K) of clusters, while hierarchical clustering simply identifies which two things are most similar pair-wise.

Can K-means cluster data that isn't on a simple line or XY graph?

Yes, K-means uses Euclidean distance, which can be calculated for any number of dimensions (samples or axes).