k-Prototypes Clustering Tool

Mixed Data Segmentation

Segment customers, products, or campaigns using k-prototypes clustering—designed specifically for datasets with both continuous (spend, frequency) and categorical (region, tier) variables. Upload mixed-type data or explore prebuilt marketing scenarios.

👨‍🏫 Professor Mode: Guided Learning Experience

New to mixed-data clustering? Enable Professor Mode for step-by-step guidance through segmenting customers using both numeric and categorical variables!

OVERVIEW & WHAT THIS TOOL SOLVES

Real CRM tables rarely contain only continuous numbers—they mix numeric behavior (like annual spend and order frequency) with categorical attributes (like region, acquisition channel, and subscription tier). Standard K-Means chokes on text categories, and dummy-coding categories into 0/1 columns distorts Euclidean distances. k-Prototypes Clustering bridges K-Means and K-Modes to segment mixed-type marketing data in a single algorithm, summarizing each segment by its numeric averages and its most common categorical traits.

🎯 Questions It Answers

  • What natural customer or product segments emerge when we combine numeric behavioral metrics with categorical profile traits?
  • How do we balance the weight of numeric spend variables against categorical attributes like channel or tier?
  • What is the typical prototype (numeric means + categorical modes) of each discovered segment?

📂 What Data You Need

  • Mixed-Type CSV: Up to 5,000 rows where each row is a customer, lead, store, or product.
  • Continuous Columns: Numeric metrics (e.g., spend, visits, tenure).
  • Categorical Columns: Text or discrete group labels (e.g., region, industry, plan tier, preferred channel).

💡 What You'll Discover

  • Cluster Prototype Profiles: Side-by-side numeric means and dominant categorical modes for every segment.
  • Cost & Silhouette Diagnostics: Mixed-distance Elbow curve and Silhouette scores across candidate k values.
  • Gamma Weighting Control: Auto-calibrated or custom categorical weight showing how numeric and categorical features trade off.
🔍 Key Nuances & Common Traps to Watch For
  • How Gamma Balances Numbers and Categories: Because squared numeric differences and 0/1 categorical mismatches live on different scales, k-Prototypes multiplies categorical mismatches by a weight parameter (γ). By default, this tool standardizes continuous features and sets γ automatically based on average continuous spread, which you can fine-tune in settings.
  • Prototypes = Means + Modes: Each cluster center ("prototype") stores the arithmetic mean for every continuous variable and the mode (most frequent category) for every categorical variable.
  • Variable Type Check: Always review the auto-detected column types after upload so numeric IDs or zip codes aren't accidentally treated as continuous quantities.
📐 Under the Hood: Model Equations & Variable Definitions
1. Mixed Dissimilarity Function & k-Prototypes Objective
\[ d(\mathbf{x}_i, \mathbf{q}_l) = \sum_{j \in \mathcal{C}} (x_{ij} - q_{lj})^2 \;+\; \gamma \sum_{m \in \mathcal{D}} \delta(x_{im}, q_{lm}), \qquad \delta(a, b) = \begin{cases} 0 & \text{if } a = b \\ 1 & \text{if } a \neq b \end{cases} \]
💬 Read it in plain English: The total distance between customer i and cluster prototype l equals the squared Euclidean distance across continuous features plus weight γ times the count of mismatched categorical attributes.
xij, xim
Continuous & Categorical Customer Features YOUR DATA ⓘ
Customer i's value on continuous variable j ∈ C and category label on categorical variable m ∈ D.
qlj, qlm
Cluster Prototype Center (Means & Modes) ESTIMATED ⓘ
Prototype l's mean on continuous feature j (qlj) and modal category on categorical feature m (qlm).
δ(a, b)
Simple Matching Dissimilarity (0/1) OUTPUT ⓘ
Indicator that adds 0 when customer and cluster prototype match on category m and 1 when they differ.
γ
Categorical Weighting Parameter (Gamma) ESTIMATED ⓘ
Tradeoff weight controlling how strongly categorical mismatches influence cluster assignments relative to continuous distances.

DATA SOURCE

📚

Use a Case Study

Use presets to explore realistic segmentation scenarios with mixed data types, such as customer profiles (spend + demographics), product portfolios (performance + attributes), or lead databases (engagement + firmographics). Download and customize scenario data in Excel.

📤

Upload Your Data

Upload CSV with mixed data types

Include a header row. Columns can be continuous (numeric values) or categorical (text labels). The tool auto-detects variable types, which you can adjust after upload. Limit: 5,000 rows.

Drag & Drop CSV file (.csv, .tsv, .txt, .xls, .xlsx)

Include headers with mixed continuous and categorical columns.

No file uploaded.

INPUTS & SETTINGS


Preprocessing & clustering

to

Advanced settings

Distance weight parameter (γ)

Gamma (γ) controls the relative weight of categorical vs. continuous variables in distance calculations. Auto-mode uses the average standard deviation of the scaled continuous features, measured in the same space the distance is, so with z-scores it lands near 1 (typically works well). With no scaling or 0–100 scaling, the distance squares numeric gaps on a much larger scale than the auto value, so category mismatches end up nearly irrelevant: standardize first, or set γ by hand. Increase γ to give categorical variables more influence; decrease to prioritize continuous variables.

Auto: γ = (will be calculated after data load)

Reproducibility
Additional info & guidance

Start with k=3–4 and run diagnostics for k=2–8. Look for an elbow in the cost plot and high silhouette values (0.5 or more for reasonable separation; 0.25–0.5 is weak) to identify well-separated clusters. Because k-prototypes uses multiple random initializations, results are generally stable but may vary slightly between runs.

Standardization is recommended when continuous variables have very different scales (e.g., age 0–100 vs. spend $0–$10,000). Note: standardization affects auto-calculated gamma by changing variance structure. If clusters seem overly driven by one variable type, adjust gamma manually.

VISUAL OUTPUT

Parallel Coordinates Plot

How to read this chart

Each line represents one observation, colored by cluster. Continuous axes show numeric scales; categorical axes show discrete levels. Look for line bundles within the same color—these indicate observations with similar profiles across multiple variables. Diverging patterns suggest different cluster characteristics.

Elbow Plot (Total Cost vs. k)

Interpretation Aid

Total cost combines continuous squared distances and γ-weighted categorical mismatches. Look for an "elbow" where cost stops dropping significantly—this suggests a natural cluster count. Beyond the elbow, additional clusters provide diminishing value. Your selected k is highlighted.

Silhouette Plot (Average Silhouette vs. k)

Interpretation Aid

Silhouette values range from -1 to 1. Higher values indicate better-defined clusters (observations are closer to their own cluster than to others). Values near 0 suggest overlapping clusters; negative values indicate possible misassignments.

CLUSTER SUMMARY & RESULTS

Summary metrics

k (clusters) --
n (observations) --
Total cost ⓘ --
Avg. silhouette ⓘ --
Gamma (γ) ⓘ --
What do these metrics mean?
  • Total cost: The sum of distances from each observation to its assigned cluster center. Lower values indicate tighter, more cohesive clusters. Use this to compare different k values—look for an "elbow" where cost reduction slows.
  • Avg. silhouette: Measures how well observations fit their clusters. Ranges from -1 to 1. Interpretation, read at two decimals (Kaufman & Rousseeuw): 0.71 or more = strong structure, 0.51–0.70 = reasonable, 0.26–0.50 = weak, 0.25 or less = no substantial structure.
  • Gamma (γ): Balances the influence of continuous vs. categorical variables in the distance calculation. A mismatch on a categorical variable adds γ to the distance. When auto-calculated, it equals the average standard deviation of scaled continuous features.

APA-Style Report

After you run the clustering, this panel will describe the solution in a formal statistical style, including the number of clusters, the gamma weight and separation.

Managerial Interpretation

This panel translates the clustering into plain language: how many groups were found, what distinguishes them, and how far to trust them.

Cluster profiles

For continuous variables, values show cluster means with within-cluster standard deviation (±sd). For categorical variables, values show the mode with percentage of cluster members having that value.

Show continuous values in: Run clustering to compare the two. This also switches the parallel coordinates plot above.
ClusterSize
Run clustering to see cluster profiles.

The download keeps all of your original columns and adds cluster_id plus distance_to_prototype — the k-prototypes cost of that row against its own prototype (scaled squared distance on the continuous variables, plus γ for every categorical mismatch). A large value flags a row that was placed somewhere but does not really belong.

Interpreting cluster profiles

Each row shows a cluster's prototype. For continuous variables, the table displays the mean value across all cluster members. For categorical variables, it shows the mode (most common category). Use these profiles to create business-friendly labels—e.g., a cluster with high spend, "West" region, and "Enterprise" tier might be "High-Value West Coast Enterprise Customers."

APPLY THE SEGMENTS TO A HOLDOUT SAMPLE

Upload a second file — rows held back, next quarter’s accounts, a different market — and each row is assigned to its nearest prototype from the run above, using the same γ and the same continuous scaling.

The holdout is scaled with the training means and standard deviations, never with its own. A categorical level that never appeared in training simply mismatches every prototype, which is honest but means such rows are placed on their continuous values alone — they are counted separately below.

Drag & Drop a holdout CSV (.csv, .tsv, .txt)

It must contain the same variable columns you clustered on. Any other columns are carried through to the download untouched.

Run clustering first, then upload a holdout file here.