← Back to selected work

Customer Segmentation Using Cluster Analysis

View on GitHub

Segments a 286,000-record Amazon sales dataset by demographic, geographic, and behavioral attributes, comparing five clustering techniques including K-Means, K-Modes, K-Prototype, Gaussian Mixture, and Agglomerative clustering to handle mixed numeric and categorical features.

PythonScikit-learnClustering
The problem

A large e-commerce dataset of transaction and demographic records mixes numeric and categorical attributes, which most clustering algorithms cannot handle directly. The goal was to segment customers by demographic, geographic, and behavioral similarity in a way that respects that mix, using a real 286,000-record Amazon sales dataset rather than a synthetic one.

The approach

Five clustering techniques were applied to the same preprocessed dataset and compared directly against each other. K-Means, Agglomerative clustering, and Gaussian Mixture handled the numeric feature set, while K-Modes and K-Prototype specifically targeted the categorical and mixed-type attributes that the numeric-only methods can't use. The optimal number of clusters was determined per method rather than assumed, and every technique was scored with silhouette analysis on the same held-out data so the comparison was apples to apples rather than each method being tuned to its own favor.

Results
0.735
K-Means silhouette score, best of the five methods
286,000
records in the source Amazon sales dataset
35
variables per record, mixed numeric and categorical
7 to 8
optimal cluster count found per method
Stack
PythonScikit-learnPandasK-ModesK-Prototype
👋 Hi, I'm a digital version of Lasantha. Ask me about my work.