Git Product home page Git Product logo

lifetime_value's Introduction

Lifetime Value

Accurate predictions of customers’ lifetime value (LTV) given their attributes and past purchase behavior enables a more customer-centric marketing strategy. One challenge of LTV modeling is that some customers never come back, and the distribution of LTV can be heavy-tailed. The commonly used mean squared error (MSE) loss does not accommodate the significant fraction of zero value LTV from one-time purchasers and can be sensitive to extreme large LTV from top spenders.

We model the distribution of LTV given associated features as a mixture of zero point mass and lognormal distribution, which we refer to as zero-inflated lognormal (ZILN) distribution. This modeling approach enables us to capture the churn probability and account for heavy-tailedness nature of LTV at the same time, and also allows for easy uncertainty quantification of the point prediction. The proposed loss function can be used in both linear models and deep neural networks (DNN). We also advocate normalized Gini coefficients to quantify model discrimination and promote decile charts to assess model calibration.

The proposed loss function (implemented in Keras) and evaluation metrics are integrated into a python package. And we demonstrate the predictive performance of our proposed model in notebooks on two real-world public datasets.

Paper

Wang, Xiaojing, Liu, Tianqi, and Miao, Jingang. (2019). A Deep Probabilistic Model for Customer Lifetime Value Prediction. arXiv:1912.07753.

Installation

The easiest way is propably using pip:

pip install -q git+https://github.com/google/lifetime_value

If you are using a machine without admin rights, you can do:

pip install -q git+https://github.com/google/lifetime_value --user

If you are using Google Colab, just add "!" to the beginning:

!pip install -q git+https://github.com/google/lifetime_value

Package works for python 3 only.

Usage

Package can be imported as

import lifetime_value as ltv

notebooks

The best way to learn how to use the package is probably by following one of the notebooks, and the recommended way of opening them is Google Colab.

Kaggle Acquire Valued Shoppers Challenge Dataset

This Kaggle challenge provides almost 350 million rows of completely anonymised transactional data from over 300,000 shoppers. We use the transactional data to demonstrate LTV modeling.

We download the transaction.csv (21GB) file from Kaggle server and prepare csv files for each of top 20 most common companies. Then we train a Keras model to predict customer's lifetime value and returning probability.

The raw data is available here.

  • Data preparation downloads kaggle data transaction.csv and preprocesses the top 20 most common companies' data to customer-level one. This is optional, and running this will save time for regression and classification because the data are cached.
  • Regression trains a Keras regression linear/dnn model with specified loss function and evaluates the results.
  • Classification trains a Keras classification linear/dnn model with specified loss function and evaluates the results.

KDD Cup 98

The Second International Knowledge Discovery and Data Mining Tools Competition (a.k.a., the KDD Cup 1998) provides a dataset collected by Paralyzed Veterans of America (PVA), a non-profit organization that provides programs and services for US veterans with spinal cord injuries or disease. The organization raised money via direct mailing campaigns and was interested in lapsed donors: people who have stopped donating for at least 12 months. The provided dataset contains around 200K such donors who received the 1997 mailing and did not make a donation in the previous 12 months. We tackle the same task of the competition, which is to predict the donation dollar value to the 1997 mailing campaign.

The raw data is available here.

  • Regression trains regression models and makes comparisons on different methods.

People

Package is created and maintained by Xiaojing Wang, Tianqi Liu, and Jingang Miao.

lifetime_value's People

Contributors

miaojingang avatar terenceliu4444 avatar wangxj03 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lifetime_value's Issues

Question regarding simultaneous objectives

First of all, thank you for making the code for the loss function, metrics & example notebooks open source.

I am looking forward to trying this approach out. I have one question that I am a bit confused about.

The paper mentions that the model structure, in combination with the loss function used, allows for one model to capture both objectives: churn prediction and remaining lifetime value prediction.

First, it is capable of predicting the churn probability and LTV value simultane-
ously. It reduces the engineering complexity of building a two-stage model (Vanderveld et al., 2016)
— a binary classification model to predict repeat purchase propensity, followed by a regression model
to predict the LTV of returning customers predicted in stage 1.

Indeed, the loss function returns a composite of both churn & remaining value losses:

  return classification_loss + regression_loss

However, the notebooks are split up in two, one for each separate objective.

Can one trained model indeed perform both tasks: the notebooks are split up to illustrate a comparison between the churn and remaining value tasks to two separate models?

Or are did I completely misinterpret the paper? In which it is meant that the type of model can perform both tasks, but you need two trained models: one fine-tuned for each task.

Thanks, and I am looking forward to trying this out. :)

How are LTV distributions calculated?

Thank you for making the code for the loss function, metrics and example notebooks open source.

From the last paragraph in section 3:

Another key advantage of the ZILN loss is that it provides a full prediction distribution. We obtain not only the probability of returning but also the value distribution of LTV for returning customers. In addition to mean LTV prediction, the uncertainty of LTV predictions can be assessed using quantiles of a lognormal distribution as in general quantile regression.

To me it is unclear both from checking the code examples and the paper, how the LTV prediction distributions are calculated, can you get them both for a singel predictions and a group of prediction for example?

Thank you!

Loss calculation

In the function to calculate ZILN loss,

The classification loss and regression loss is combined together, however, the scale of two loss is different meaning, the binary crossentropy loss is often much smaller than regression loss. Shouldn't we compensate for this difference in scale?

In addition, why do we take the negative of regression loss?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.