churn_predictorΒΆ

The GraphLab Create Churn Prediction toolkit allows predicting which users will churn (stop using) a product or website given user activity logs. Here is a short example of using this module on a sample dataset.

>>> import graphlab as gl
>>> import datetime

# Load a data set.
>>> sf = gl.SFrame(
... 'https://static.turi.com/datasets/churn-prediction/online_retail.csv')

# Convert InvoiceDate from string to datetime.
>>> import dateutil
>>> from dateutil import parser
>>> sf['InvoiceDate'] = sf['InvoiceDate'].apply(parser.parse)

# Convert SFrame into TimeSeries.
>>> time_series = gl.TimeSeries(sf, 'InvoiceDate')

# Create a train-test split.
>>> train, valid = gl.churn_predictor.random_split(time_series,
...           user_id='CustomerID', fraction=0.9)

# Train a churn prediction model.
>>> model = gl.churn_predictor.create(train, user_id='CustomerID',
...                       features = ['Quantity'])
churn_predictor.create Create a model to predict the probability that an active user will become inactive in the future.
churn_predictor.get_default_options Get the default options for the toolkit ChurnPredictor.
churn_predictor.random_split Randomly split an SFrame/TimeSeries into two SFrames/TimeSeries based on the user_id such that one split contains data for a fraction of the users while the second split contains all data for the rest of the users.
churn_predictor.ChurnPredictor Create a churn forecast model (an object of type ChurnPredictor) that predicts the probability that an active user/customer will become inactive in the future (defined as churn).
churn_predictor._churn_predictor.ChurnPredictorViews