Unsupervised Learning with scikit-learn: Clustering and Dimensionality Reduction

Unsupervised Learning: Clustering and Dimensionality Reduction is an intermediate-level course of 5 lessons (about 2 h 50 min), with 11 exercises and 15 quiz questions. Prerequisites: Introduction to Machine Learning (scikit-learn). Exercises run in the browser, with nothing to install.

  • Data science
  • Intermediate
  • 5 lessons
  • 2 h 50 min
  • 11 exercises
  • Exercises run in the browser

The course in brief

This course covers unsupervised learning with scikit-learn. You learn to group observations with K-means, DBSCAN, and hierarchical clustering, to choose the number of groups, then to reduce dimensionality with PCA and visualize data with t-SNE. The course ends with a complete segmentation workflow: build, describe, name, and verify segments you can act on.

What you will be able to do

  • Apply K-means correctly (scaling, initialization) and read its results
  • Choose a number of clusters with the elbow method and the silhouette score
  • Use DBSCAN, HDBSCAN, and hierarchical clustering for complex shapes and noise
  • Reduce dimensionality with PCA and interpret the explained variance
  • Visualize high-dimensional data with PCA and t-SNE, knowing their limits
  • Profile, name, and validate the stability of segments

Syllabus: 5 lessons

  1. 01

    Group Data with K-means

    15 minFree preview
    • Explain how the K-means algorithm works
    • Apply KMeans and read labels_, cluster_centers_, and inertia_
    • Prepare data (scaling) before clustering

    ClusteringK-meansInertia

  2. 02

    Choosing the Number of Clusters: Elbow and Silhouette

    15 min
    • Plot and read the inertia curve (elbow method)
    • Compute and interpret the silhouette score
    • Combine numerical criteria and business sense to set k

    Elbow methodSilhouette scoreChoosing the number of clusters

  3. 03

    DBSCAN and Hierarchical Clustering

    15 min
    • Use DBSCAN to find groups of arbitrary shape and noise
    • Tune eps and min_samples
    • Apply agglomerative hierarchical clustering and choose the linkage

    DBSCANHierarchical clusteringDensity-based clustering

  4. 04

    Reduce Dimensionality with PCA

    15 min
    • Explain what a principal component analysis computes
    • Read the explained variance and choose the number of components
    • Use PCA in a pipeline before a model

    Principal component analysisExplained varianceDimensionality reduction

  5. 05

    Visualize and Interpret Segments

    20 min
    • Visualize high-dimensional data with PCA and t-SNE
    • Build a complete chain: standardization, reduction, clustering
    • Describe and name segments from per-cluster statistics

    t-SNECluster profilingSegmentation

Final project

Customer Segmentation for an Online Store

Use numpy to generate a realistic dataset of 2,000 customers (recency, frequency, monetary value, number of categories purchased, return rate, tenure), simulating several behavior profiles and a few unusual customers. Build a complete segmentation: preparation and standardization, PCA for exploration, a comparison of K-means (several k) and a density-based method, a reasoned choice of the number of segments, a profile and a name for each segment, a stability test, and a recommended action for each segment.

Deliverables

  • The data generation script and the reproducible segmentation pipeline
  • The plots for choosing k (inertia and silhouette) and a 2D projection of the segments
  • A segment profile table (sizes, medians, standardized deviations) with a name for each segment
  • A summary note presenting the segments, their stability, and the recommended actions

Assessment criteria

  • Correct data preparation (standardization, handling of unusual points)
  • Choice of the number of segments justified by several criteria and by business sense
  • Clear, quantified, and interpretable segment profiles
  • Verification of the stability of the segmentation
  • Cautious reading of the visualizations (limits of t-SNE)

Frequently asked questions

What is unsupervised learning used for?

It is used to discover structure in data without a target variable: grouping similar customers, detecting unusual behavior, summarizing many variables into a few axes, or visualizing high-dimensional data.

How do I choose the number of clusters?

You combine numerical criteria, such as the elbow method on inertia and the silhouette score, with how interpretable the groups are. The course shows how to compare several values of k, then describe the candidate segments.

What is the difference between PCA and t-SNE?

PCA is a linear projection that preserves variance and can transform new data; it is used to compress or preprocess. t-SNE is a nonlinear visualization method that preserves local neighborhoods, but its global distances cannot be interpreted and it cannot transform new data.

Do I need to standardize data before clustering?

Yes, whenever variables have different units or scales. K-means, DBSCAN, hierarchical clustering, and PCA rely on distances or variances, which would otherwise be dominated by large-scale variables.

This course, told for your job

Say what you want to be able to do: “Unsupervised Learning: Clustering and Dimensionality Reduction” takes its place in your path, with examples from your field. The concepts stay those of the course.

The preview is free, and you can take the courses one at a time without paying. The path only contains lessons from the catalogue.