← Back to All Projects | Home

The Hardest Segmentation Decision Was Not the Clustering Method

Telecom customer segmentation through observation-unit design, iterative profiling, and supervised rule-based assignment

Overview

This project built a full customer segmentation system for telecom CVM operations. It had two phases: unsupervised clustering to discover behavioral segments, then supervised classification to assign new customers to those segments using interpretable business rules.

The main challenge was not the clustering algorithm. It was the series of design decisions that came before and after: defining what one row should represent, making variables compatible with distance-based methods, iterating until clusters became operationally meaningful, and bridging the unsupervised output to a production-ready assignment system.

The project combined representation design, variable shaping, clustering experimentation, telecom-specific profiling, and supervised rule extraction to produce actionable segment structures rather than just mathematical clusters.

Architecture

Telecom customer segmentation architecture

The Core Idea

The first segmentation question was not about the clustering method.

It was about a more fundamental design choice: what should one observation represent? Whether the variables can even coexist in a shared distance space? Whether the clusters, once produced, actually mean something to the business? And how to make the segmentation production-ready for customers who arrive after the model was built?

Each of these questions required a different type of thinking:

  • Observation-unit design — a customer average or a monthly behavioral state
  • Variable clusterability — making distributions compatible with distance methods
  • Iterative profiling — turning statistical clusters into business-readable identities
  • Supervised assignment — bridging unsupervised output to production scoring

Observation Unit Design

Observation unit design

With months of behavioral history per subscriber, the first design question was: what exactly should one row in the analytical base table represent?

Two valid approaches

Approach A — One Subscriber = One Row

Collapse the behavioral window into one profile per customer: average usage intensity, average recharge frequency, average data consumption.

What you segment: customers as stable entities.

Good for: long-term CVM strategy, structural campaigns, customer typology.

Approach B — One Subscriber-Month = One Row

Keep each monthly snapshot as a separate observation. The same subscriber in March, April, and May becomes three different rows.

What you segment: behavioral states over time.

Good for: detecting transitions, early warning signals, lifecycle modeling.

That single design decision changes the entire segmentation output.

Selected code: aggregated subscriber behavioral profile

/* Approach A: one subscriber = one row */
/* Collapse N months into average behavioral profile */
select subscriber_id,
       sum(recharge_amount) / history_months       as avg_recharge_amount,
       sum(recharge_count) / history_months        as avg_recharge_count,
       sum(recharge_days) / history_months         as avg_recharge_days,
       sum(weekend_recharge) / history_months      as avg_weekend_recharge,
       case when sum(recharge_count) > 0
            then sum(recharge_amount) / sum(recharge_count)
            else 0 end                             as avg_recharge_value,
       case when sum(recharge_count) > 0
            then sum(recharge_days) / total_days_in_window
            else 0 end                             as recharge_frequency
from subscriber_recharge_monthly
group by subscriber_id;
                

Design insight: The question "which clustering method?" must come after the question "does the business need stable customer types or changing customer states?" The unit of analysis is a modeling decision, not a formatting detail.

Iterative Profiling and Redesign

Iterative profiling loop

Useful segments did not emerge from running one clustering method once. The final segmentation came from repeated cycles of representation, clustering, profiling, and redesign.

The business cannot act on Cluster 1, Cluster 2, Cluster 3. Operations needs identities it can recognize: young prepaid users, data-heavy consumers, old loyal subscribers, multisim households, fragile low-activity profiles.

The iteration loop

Represent Cluster Profile Rethink Rebuild

Profiling dimensions per iteration

  • Recharge behavior — frequency, regularity, weekend patterns, top-up value distribution
  • Voice vs data mix — usage intensity by service type, on-net vs off-net split
  • Handset quality — 2G / 3G / 4G device capability, device change frequency
  • Network community — graph degree, community size, operator mix in social group
  • Region and mobility — geographic footprint, number of distinct cell towers visited
  • CVM response — campaign sensitivity, offer activation behavior, response to promotions
  • Churn signals — inactivity days, declining usage trends, recharge evaporation patterns

Design insight: Unlike supervised learning, there is no target variable to tell you whether the representation is right. Good segmentation is designed through iteration. The iteration is not optional — it is the method.

Variable Clusterability

Variable transformation for clustering

The raw feature space had extreme distributions. Some variables were wildly skewed. Before reducing redundancy, the project answered: can these variables even live in the same clustering space?

Variable-specific transformation strategy

LOG

Moderate skew (1–3)

Applied to: avg call duration, community size, cell tower count, SMS volume

SQRT

Light skew

Applied to: active days ratio, 4G usage percentage, off-net duration share

Power ^0.25

Heavy skew (5+)

Applied to: recharge amount, total revenue, total data volume

EXP

Reverse / compressed

Applied to: multi-SIM flag, data pack percentage, 3G usage percentage

Design insight: In distance-based unsupervised learning, bad variable shape is often a bigger problem than variable redundancy. Before asking whether two variables are too similar, make sure each one is even representable in a stable distance space.

Compression Before Structure

K-means compression before hierarchical clustering

With hundreds of thousands of subscribers, hierarchical clustering cannot run directly. K-means scales linearly but flattens nested structure. The solution: use both in sequence.

Stage 1: K-Means Compression

Compress the full subscriber base into many representative centroids. Fast, scalable, captures local density patterns.

Stage 2: Hierarchical Clustering (Ward)

Run Ward's method on the centroids. Finds nested structure, natural segment boundaries, optimal cluster count.

Selected code: two-stage clustering

/* Stage 1: K-means compression */
proc fastclus data=normalized_subscriber_features
     maxclusters=1000
     out=compressed_centroids;
  var feature_1 - feature_49;
run;

/* Stage 2: Hierarchical clustering on centroids */
proc cluster data=compressed_centroids
     method=ward
     outtree=dendrogram_output;
  var feature_1 - feature_49;
run;

/* Cut dendrogram at chosen level */
proc tree data=dendrogram_output
     nclusters=8
     out=final_segment_assignment;
run;
                

Design insight: The first algorithm is not the segmenter — it is the reducer. One algorithm can serve as a modeling layer for another.

Supervised Rule-Based Assignment

Supervised rule extraction and assignment

The unsupervised phase gave meaningful clusters. But clusters alone cannot operationally assign new customers. So the supervised phase extracted interpretable rules and applied them as a production scoring system.

The bridge: from clusters to rules

1. Label

Assign unsupervised segment identities as supervised target.

2. Train

Fit decision tree. Compare with NN and regression benchmarks.

3. Extract

Extract splitting rules with conditions and thresholds.

4. Adjust

Round to business-meaningful values. Validate with CVM teams.

Design insight: Discovery is unsupervised. Assignment is supervised. The bridge is rule extraction with business-adjusted thresholds.

Key Takeaway

The hardest segmentation decision was not the clustering method.

It was defining what one row should represent, making the variables clusterable, iterating until clusters became operational segments, and then bridging unsupervised discovery to supervised rule-based assignment for production use.

Public Repository Scope

This public version shares the segmentation architecture, methodological framing, selected pseudocode, and project presentation. Raw telecom data, confidential schemas, monetary values, and production identifiers are not included.

← Back to Portfolio

Customer Segmentation, Mahmoud Trigui

Telecom Customer
Segmentation

The hardest segmentation decision was not the clustering method — it was defining what one row should represent, making the variables clusterable, iterating until clusters became operationally meaningful, and bridging unsupervised discovery to a production-ready supervised assignment system.

Tunisia Telecom CVM Operations Production deployed SAS · K-means · Ward · Decision Tree

Architecture

Telecom customer segmentation architecture
📋 View detailed architecture diagram
  PHASE 1: UNSUPERVISED DISCOVERY
  Raw Telecom Behavioral History → Observation Unit Design
  → Feature Preparation (zero-replace, cap, transform) → Variable Reduction (174 → 49)
  → Clustering (K-means compression → Hierarchical Ward) → Iterative Profiling & Redesign
  → Operational Segments (Data Addicts, High Consumers, Jeunes, Old Loyal, MultiSIM, Fragile…)

  PHASE 2: SUPERVISED ASSIGNMENT
  Decision Tree on Labeled Clusters → Business Threshold Adjustment → Production Scoring System
  (monthly re-assignment without re-running unsupervised pipeline)
                        

Overview

Built a full customer segmentation system for CVM (Customer Value Management) operations at Tunisia Telecom. Two phases: unsupervised clustering to discover behavioral segments, then supervised classification to assign new and existing customers using interpretable business rules.

The main challenge was not the algorithm. It was a sequence of design decisions: what should one row represent, are the variables even compatible with distance-based clustering, and how do you bridge the output of an unsupervised model to a system that can score new subscribers every month without re-running the pipeline.

The Four Core Design Problems

1. Observation Unit Design: Customers vs. Behavioral States

Observation unit design

With monthly behavioral history per subscriber, the first question was: does one row represent a customer (collapsed over time) or a behavioral state (one row per subscriber-month)? Approach A produces stable long-term customer typologies — useful for structural CVM strategy. Approach B reveals behavioral transitions — useful for early warning signals and lifecycle modeling. The choice was made based on the specific CVM use case, not on what was computationally easier.

/* Approach A: one subscriber = one row */
select subscriber_id,
       sum(recharge_amount) / history_months  as avg_recharge_amount,
       sum(recharge_count)  / history_months  as avg_recharge_count,
       case when sum(recharge_count) > 0
            then sum(recharge_amount) / sum(recharge_count)
            else 0 end                         as avg_recharge_value,
       sum(recharge_days)   / total_days       as recharge_frequency
from subscriber_recharge_monthly
group by subscriber_id;

2. Variable Clusterability Before Redundancy Removal

Variable transformation for clustering

The raw feature space had extreme skewness — some variables with skewness above 40, kurtosis above 1000. Standard scaling alone would make the distance geometry unstable. Before any correlation-based feature removal, every variable was tested for clusterability and assigned a transformation: log (moderate skew), sqrt (light skew), power ^0.25 (heavy skew), or exp (compressed). Variables that could not be stabilized by any transformation were removed — not because they were redundant, but because they were unusable in a distance space.

/* Variable-specific transformation assignments */
recharge_amount:      power_transform → (max(value,0) / scale) ^ 0.25
avg_call_duration:    log_transform   → log(max(value,0) / scale + 1)
active_days_ratio:    sqrt_transform  → sqrt(max(value,0) / scale)
total_data_volume:    power_transform → (max(value,0) / scale) ^ 0.25

/* Pipeline summary */
/* Input:    174 candidate variables                    */
/* Retained:  49 variables (transformable + stable)    */
/* Rejected:  49 variables (no transform stabilized)   */

3. K-means Compression Before Hierarchical Clustering

K-means compression before hierarchical clustering

With hundreds of thousands of subscribers, hierarchical clustering cannot run directly (quadratic complexity). But K-means alone flattens nested structure. The solution: use K-means as a compression layer first (compressing to ~1000 representative centroids), then run Ward's hierarchical method on those centroids. K-means acts as a reducer, not the final segmenter — and the dendrogram reveals the natural cluster count.

/* Stage 1: K-means compression */
proc fastclus data=normalized_features
    maxclusters=1000
    out=compressed_centroids;
  var feature_1 - feature_49;
run;

/* Stage 2: Hierarchical clustering on centroids */
proc cluster data=compressed_centroids
    method=ward
    outtree=dendrogram;
  var feature_1 - feature_49;
run;

/* Cut dendrogram at chosen depth */
proc tree data=dendrogram nclusters=8
    out=final_segments;
run;

4. Supervised Rule-Based Assignment for Production

Supervised rule extraction and assignment

A subscriber who activated last month has only 1–2 months of history. The unsupervised model was built on a longer behavioral window — it cannot score new customers. The supervised phase bridges this gap: use existing cluster memberships as a target label, augment across multiple months, train a decision tree, extract rules, round thresholds with CVM teams, and deploy as a monthly scoring system. The model that assigns is not the model that discovered.

/* Business-adjusted assignment rule (example) */
/* Raw tree split: data_revenue_ratio > 0.734 ... */
/* Business rule: */
if data_revenue_ratio > 0.70
   and data_pack_frequency > 2
   and voice_duration_share < 0.45
   then assign → "Data Intensive"
/* Note: original cluster ~100K, rule-based segment ~90-110K */
/* Goal: stability and interpretability, not exact replication */

Iterative Profiling Dimensions

Each clustering iteration was profiled across all of the following dimensions. Segments that could not be described in business terms across most dimensions were discarded and the variable set was revised:

  • Recharge behavior: frequency, regularity, weekend patterns, top-up value distribution
  • Voice vs. data mix: usage intensity by service, on-net vs. off-net split
  • Handset quality: 2G/3G/4G device capability, device change frequency
  • Network community: graph degree, community size, operator mix in social group
  • Region and mobility: geographic footprint, distinct cell towers visited
  • CVM response: campaign sensitivity, offer activation behavior
  • Churn signals: inactivity days, declining usage trends, recharge evaporation

Key Takeaway

Useful segments did not emerge from running one clustering method once. The final segmentation came from repeated cycles of representation, clustering, profiling, and redesign. Unlike supervised learning, there is no target variable to tell you whether the representation is right — iteration is not optional, it is the method.

Design insight: In distance-based unsupervised learning, bad variable shape is a bigger problem than variable redundancy. And the question "which clustering method?" must come after "are all these variables even representable in a shared distance space?"