Project 04 · Clustering

Exploring customer segments

Using scaling, PCA, and K-means to explore patterns in customer purchasing and campaign-response data.

Download notebook ↓ · All projects

Data: 2,240 customer rows · 29 fields before preprocessing
Period: Dataset snapshot
Tools: Python, pandas, scikit-learn, SciPy, Seaborn, Matplotlib

Question

Can purchasing and engagement patterns be grouped into a small number of customer segments?

Approach

The notebook removes Education and Marital_Status, standardizes numeric columns, uses PCA and an elbow/silhouette review to explore cluster counts, then fits K-means with three clusters.

  1. Prepare numeric features

    The notebook removes two categorical fields, checks missingness, standardizes numeric columns, and excludes incomplete rows before PCA and clustering.

  2. Explore the structure

    A three-component PCA view and elbow/silhouette diagnostics are used to examine candidate groupings.

  3. Inspect the segments

    K-means with three clusters yields groups of 1,040, 635, and 541 records, then boxplots compare standardized features.

Findings and limitations

Observed finding

After rows with missing values are dropped, 2,216 records remain. The selected three-cluster run contains groups of 1,040, 635, and 541 records. Correlation and cluster-profile plots help inspect patterns; the notebook does not establish a validated customer strategy.

What to keep in mind

The analysis omits two categorical fields, includes ID among standardized numeric features, and drops 24 rows with missing values. Those choices can affect distance-based clusters. The three groups need further validation and substantive interpretation before being used for business decisions.

Next iteration: I would exclude identifier columns, encode categorical variables deliberately, compare cluster stability across seeds, and validate any proposed segment against outcomes not used to create it.

Selected figures

Correlation heatmap of the numeric customer data used in the notebook.
Correlations offer a first look at relationships among numeric features.
K-means inertia by cluster count, used as an elbow-method diagnostic.
The elbow curve informed the notebook’s choice to inspect three clusters.
Silhouette scores across candidate cluster counts.
Silhouette scores provide another diagnostic for cluster separation.
Boxplots comparing standardized purchasing and engagement features across the three clusters.
Feature profiles help compare the clusters, but interpretation requires validation.

Notebook and source data

The notebook preserves the analysis code with saved outputs removed and data paths normalized to a local data folder. Dataset files are not bundled; consult the notebook README and obtain appropriately licensed source data before running it.

Download notebook · Notebook README