LogoDuyệtSr. Data Engineer
HomeAboutPhotosInsightsCV

Footer

Logo

Resources

  • Rust Tiếng Việt
  • /archives
  • /series
  • /tags
  • Status

me@duyet.net

  • About
  • LinkedIn
  • Resume
  • Projects

© 2026 duyet.net | Sr. Data Engineer | 2026-02-27

Python - Churn prediction with Graphlab

Note: This post is over 9 years old. The information may be outdated.

Churn prediction is the task of identifying whether users are likely to stop using a service, product, or website. With Graphlab toolkit, you can start with raw (or processed) usage metrics and accurately forecast the probability that a given customer will churn.

Note (2025): Graphlab has been deprecated and was succeeded by Turi Create. For modern churn prediction, consider using scikit-learn, TensorFlow, or PyTorch instead. This article is kept for historical reference.

Introduction

A churn predictor model learns historical user behavior patterns to make an accurate forecast for the probability of no activity in the future (defined as churn).

How is churn defined?

Customer churn can be defined in many ways. In this toolkit, churn is defined to be no activity for a fixed period of time (called the churn_period). Using this definition, a user is said to have churned if there is no activity for a duration of time known as the churn_period (by default, this is set to 30 days). The following figure better illustrates this concept.

Input Data

In the dataset, let us assume that the last timestamp was October 1,

+---------------------+------------+----------+
|     InvoiceDate     | CustomerID | Quantity |
+---------------------+------------+----------+
| 2010-12-01 08:26:00 |   17850    |    6     |
| 2010-12-01 08:26:00 |   17850    |    6     |
| 2010-12-01 08:26:00 |   17850    |    8     |
| 2010-12-01 08:26:00 |   17850    |    6     |
| 2010-12-01 08:26:00 |   17850    |    6     |
| 2010-12-01 08:26:00 |   17850    |    2     |
| 2010-12-01 08:26:00 |   17850    |    6     |
| 2010-12-01 08:28:00 |   17850    |    6     |
| 2010-12-01 08:28:00 |   17850    |    6     |
| 2010-12-01 08:34:00 |   13047    |    32    |
| 2010-12-01 08:34:00 |   13047    |    6     |
| 2010-12-01 08:34:00 |   13047    |    6     |
| 2010-12-01 08:34:00 |   13047    |    8     |
| 2010-12-01 08:34:00 |   13047    |    6     |
| 2010-12-01 08:34:00 |   13047    |    6     |
| 2010-12-01 08:34:00 |   13047    |    3     |
| 2010-12-01 08:34:00 |   13047    |    2     |
| 2010-12-01 08:34:00 |   13047    |    3     |
| 2010-12-01 08:34:00 |   13047    |    3     |
| 2010-12-01 08:34:00 |   13047    |    4     |
+---------------------+------------+----------+
[532618 rows x 5 columns]

If the churn_period is set to 1 month, a churn forecast predicts the probability that a user will have no activity for a 1 month period after October 1, 2011.

Mar 18, 2017·9 years ago
|Machine Learning|
PythonData ScienceMachine Learning
|Edit|

Related Posts

Deploy Deep Learning model as a web service API

Trong bài này mình sẽ hướng dẫn deploy 1 model Deep learning, cụ thể là Keras dưới dạng một web service API. Sử dụng Flask framework python và Redis server như một Messeage Queue.

Jul 21, 2018·8 years ago
Read more

Sử dụng PyTorch với GPU miễn phí trên Google Colab

Google Colab (https://colab.research.google.com/) là một phiên bản Jupyter/iPython đến từ Google (think iPython + Google Drive), cung cấp cho chúng ta một môi trường notebook-based với backend Python 2/3 miễn phí. Google Colab rất hữu ích trong việc chia sẻ, giáo dục và teamwork trong các dự án về Machine Learning.

Jun 3, 2018·8 years ago
Read more

Python - Nhận dạng xe hơi với OpenCV

Trong bài này, mình sẽ hướng dẫn sử dụng OpenCV để nhận diện xe hơi trong ảnh (video frame) với đặc trưng HAAR, sử dụng file mô hình đã được trained.

Sep 20, 2017·8 years ago
Read more

Phân lớp văn bản

Trong Machine Learning và NLP, phân lớp văn bản là một bài toán xử lí văn bản cổ điển, gán các nhãn phân loại lên một văn bản mới dựa trên mức độ tương tự của văn bản đó so với các văn bản đã được gán nhãn trong tập huấn luyện.

Aug 11, 2017·9 years ago
Read more
On this page
  • Introduction
  • How is churn defined?
  • Input Data
On this page
  • Introduction
  • How is churn defined?
  • Input Data