Customer Churn Prediction

View as Markdown

Solution Background and Business Value

Customer churn prediction helps businesses retain users by identifying those at risk of leaving and taking proactive steps to re-engage them. This is particularly useful for subscription-based services, e-commerce platforms, and streaming services.

With Kumo AI, businesses can:

  • Train a churn model tailored to their data and customer behavior.

  • Use the Kumo REST API to export predictions to a CRM system.

  • Send targeted notifications through email, SMS, or push notifications to customers likely to churn.

Kumo’s Predictive Query Language (PQL) supports flexible churn definitions, including:

  • Subscription churn: Predict users likely to cancel within the next 3 months.

  • Inactivity churn: Predict users unlikely to log in within the next 7 days.

  • Purchase churn: Predict users unlikely to make a purchase in the next 30 days.

Data Requirements and Schema

A core set of tables is required; additional tables improve prediction quality.

Core Tables

  1. Users Table: stores customer information. Key attributes: user_id (unique identifier). Optional: signup date, subscription status, location.

  2. Events Table: tracks user activity such as purchases, logins, and video streams. Key attributes: user_id (links to a user), timestamp (time of event). Optional: event type (purchase, session start, stream start).

  3. Items Table: contains details about products or content. Key attributes: item_id (unique identifier). Optional: product category, price, genre.

Optional Enhancement Tables

  • Merchants Table: Details about merchants in a marketplace.

  • Sessions Table: Session start and end times for users.

  • Clicks Table: User interactions with specific items.

  • Reviews Table: User-generated product reviews.

Entity Relationship Diagram (ERD)

Predictive Queries

Churn is defined as users who become inactive within a given timeframe. The PQL queries below use X (future window in days) and Y (lookback window in days) as configurable placeholders.

1. Predicting Purchase Churn

PREDICT COUNT(events.*, 0, X, days) = 0
FOR EACH users.user_id
WHERE COUNT(events.*, -Y, 0, days) > 0

Predicts users who will not make a purchase in the next X days, given that they were active in the last Y days.

2. Predicting Streaming/Inactivity Churn

PREDICT COUNT(events.* WHERE events.type = 'stream', 0, X, days) = 0
FOR EACH users.user_id
WHERE COUNT(events.* WHERE events.type = 'session', -Y, 0, days) > 0

Predicts users who will not stream content in the next X days, given that they had active sessions in the last Y days.

3. Predicting Subscription Churn

PREDICT COUNT(events.* WHERE events.type = 'unsubscribe', 0, X, days) > 0
FOR EACH users.user_id
WHERE LAST(users.subscription_status, 0, -Y, days) == 'active'

Predicts users who will unsubscribe in the next X days, given that they were subscribed in the last Y days.

Building models in Kumo Fine-Tune SDK

1. Initialize the Kumo Fine-Tune SDK

1import kumoai as kumo
2
3kumo.init(url="https://<customer_id>.kumoai.cloud/api", api_key=API_KEY)

2. Connect data

1connector = kumo.S3Connector("s3://your-dataset-location/")

3. Select tables

1users = kumo.Table.from_source_table(
2 source_table=connector.table('users'),
3 primary_key='user_id',
4).infer_metadata()
5
6events = kumo.Table.from_source_table(
7 source_table=connector.table('events'),
8 time_column='timestamp',
9).infer_metadata()
10
11items = kumo.Table.from_source_table(
12 source_table=connector.table('items'),
13 primary_key='item_id',
14).infer_metadata()

4. Define graph schema

1graph = kumo.Graph(
2 tables={
3 'users': users,
4 'events': events,
5 'items': items,
6 },
7 edges=[
8 dict(src_table='events', fkey='user_id', dst_table='users'),
9 dict(src_table='events', fkey='item_id', dst_table='items'),
10 ],
11)
12
13graph.validate(verbose=True)

5. Train the model

1pquery = kumo.PredictiveQuery(
2 graph=graph,
3 query="""
4 PREDICT COUNT(events.*, 0, X, days) = 0
5 FOR EACH users.user_id
6 WHERE COUNT(events.*, -Y, 0, days) > 0
7 """
8)
9
10pquery.validate(verbose=True)
11
12model_plan = pquery.suggest_model_plan()
13trainer = kumo.Trainer(model_plan)
14training_job = trainer.fit(
15 graph=graph,
16 train_table=pquery.generate_training_table(non_blocking=True),
17 non_blocking=False,
18)
19print(f"Training metrics: {training_job.metrics()}")

Deployment Strategy

In production, churn prediction models integrate into automated retention strategies:

  1. Generate churn scores using Kumo.

  2. Filter users by churn risk and store the scores.

  3. Export churn scores to a CRM (for example, Salesforce, Marketo, or Braze).

  4. Trigger personalized engagement such as emails, push notifications, or discounts.

  5. Automate the pipeline using a workflow orchestration tool (for example, Airflow or Dagster).