How to make targeted offers to customers?

This tutorial includes everything you need to set up IBM Decision Optimization CPLEX Modeling for Python (DOcplex), build a Mathematical Programming model, and get its solution by solving the model with IBM ILOG CPLEX Optimizer.

When you finish this tutorial, you’ll have a foundational knowledge of Prescriptive Analytics.

This notebook is part of Prescriptive Analytics for Python

It requires either an installation of CPLEX Optimizers or it can be run on IBM Watson Studio Cloud (Sign up for a free IBM Cloud account and you can start using Watson Studio Cloud right away).

Table of contents:

Describe the business problem

  • The Self-Learning Response Model (SLRM) node enables you to build a model that you can continually update. Such updates are useful in building a model that assists with predicting which offers are most appropriate for customers and the probability of the offers being accepted. These sorts of models are most beneficial in customer relationship management, such as marketing applications or call centers.
  • This example is based on a fictional banking company.
  • The marketing department wants to achieve more profitable results in future campaigns by matching the right offer of financial services to each customer.
  • Specifically, the datascience department identified the characteristics of customers who are most likely to respond favorably based on previous offers and responses and to promote the best current offer based on the results and now need to compute the best offerig plan.

A set of business constraints have to be respected:

  • We have a limited budget to run a marketing campaign based on “gifts”, “newsletter”, “seminar”.
  • We want to determine which is the best way to contact the customers.
  • We need to identify which customers to contact.

How decision optimization can help

  • Prescriptive analytics technology recommends actions based on desired outcomes, taking into account specific scenarios, resources, and knowledge of past and current events. This insight can help your organization make better decisions and have greater control of business outcomes.

  • Prescriptive analytics is the next step on the path to insight-based actions. It creates value through synergy with predictive analytics, which analyzes data to predict future outcomes.

  • Prescriptive analytics takes that insight to the next level by suggesting the optimal way to handle that future situation. Organizations that can act fast in dynamic conditions and make superior decisions in uncertain environments gain a strong competitive advantage.

  • For example:

    • Automate complex decisions and trade-offs to better manage limited resources.
    • Take advantage of a future opportunity or mitigate a future risk.
    • Proactively update recommendations based on changing events.
    • Meet operational goals, increase customer loyalty, prevent threats and fraud, and optimize business processes.

Prepare the data

The predictions show which offers a customer is most likely to accept, and the confidence that they will accept, depending on each customer’s details.

For example: (139987, “Pension”, 0.13221, “Mortgage”, 0.10675) indicates that customer Id=139987 will certainly not buy a Pension as the level is only 13.2%, whereas (140030, “Savings”, 0.95678, “Pension”, 0.84446) is more than likely to buy Savings and a Pension as the rates are 95.7% and 84.4%.

This data is taken from a SPSS example, except that the names of the customers were modified.

A Python data analysis library, pandas, is used to store the data. Let’s set up and declare the data.

Offers are stored in a pandas DataFrame.

Let’s customize the display of this data and show the confidence forecast for each customer.

name Product1 Confidence1 Product2 Confidence2
17 Cassio Lombardo Pension 0.13221 Mortgage 0.10675
7 Christian Austerlitz Pension 0.13221 Mortgage 0.10675
24 Earl B. Wood Savings 0.95678 Pension 0.83426
19 Eldar Muravyov Pension 0.13221 Mortgage 0.10675
6 Fabien Mailhot Pension 0.13221 Mortgage 0.10675
26 Franca Palermo Pension 0.13221 Mortgage 0.10675
25 Gabrielly Sousa Martins Savings 0.95678 Pension 0.75925
13 George Blomqvist Savings 0.16428 Pension 0.13221
0 Guadalupe J. Martinez Pension 0.13221 Mortgage 0.10675
21 Jameel Abdul-Ghani Gerges Pension 0.13221 Mortgage 0.10675
10 Lee Tsou Pension 0.13221 Mortgage 0.10675
23 Matheus Azevedo Melo Pension 0.13221 Mortgage 0.10675
1 Michelle M. Lopez Savings 0.95678 Pension 0.84446
3 Miranda B. Roush Pension 0.13221 Mortgage 0.10675
12 Miroslav Skaroupka Savings 0.95676 Mortgage 0.82269
5 Roland Gu�rette Pension 0.13221 Mortgage 0.10675
11 Sanaa' Hikmah Hakimi Pension 0.13221 Mortgage 0.10675
4 Sandra J. Wynkoop Pension 0.80506 Savings 0.28391
20 Shu T'an Savings 0.95675 Pension 0.27248
8 Steffen Meister Pension 0.13221 Mortgage 0.10675
2 Terry L. Ridgley Savings 0.95678 Pension 0.80233
18 Trinity Zelaya Miramontes Savings 0.28934 Pension 0.13221
16 Vlad Alekseeva Pension 0.13221 Mortgage 0.10675
14 Will Henderson Savings 0.95678 Pension 0.86779
9 Wolfgang Sanger Pension 0.13221 Mortgage 0.10675
15 Yuina Ohira Pension 0.13225 Mortgage 0.10675
22 Zeeb Longoria Marrero Savings 0.16188 Pension 0.13221

Use IBM Decision Optimization CPLEX Modeling for Python

Let’s create the optimization model to select the best ways to contact customers and stay within the limited budget.

Step 1: Import the library

Run the following code to import the Decision Optimization CPLEX Modeling library. The DOcplex library contains the two modeling packages, Mathematical Programming (docplex.mp) and Constraint Programming (docplex.cp).

If cplex is not installed, install CPLEX Community edition.

Step 2: Set up the prescriptive model

Create the model

Define the decision variables

  • The integer decision variables channelVars, represent whether or not a customer will be made an offer for a particular product via a particular channel.
  • The integer decision variable totaloffers represents the total number of offers made.
  • The continuous variable budgetSpent represents the total cost of the offers made.

Set up the constraints

  • Offer only one product per customer.
  • Compute the budget and set a maximum on it.
  • Compute the number of offers to be made.
Model: marketing_campaign
 - number of variables: 326
   - binary=324, integer=1, continuous=1
 - number of constraints: 34
   - linear=34
 - parameters: defaults
 - problem type is: MILP

Express the objective

We want to maximize the expected revenue.

Solve the model

If you’re using a Community Edition of CPLEX runtimes, depending on the size of the problem, the solve stage may fail and will need a paying subscription or product installation.

Step 3: Analyze the solution

First, let’s display the Optimal Marketing Channel per customer.

Marketing plan has 20 offers costing 364.0
channel product customer
0 newsletter Car loan Fabien Mailhot
1 newsletter Car loan Christian Austerlitz
2 newsletter Car loan Lee Tsou
3 newsletter Car loan Sanaa' Hikmah Hakimi
4 newsletter Car loan George Blomqvist
5 newsletter Car loan Yuina Ohira
6 newsletter Car loan Vlad Alekseeva
7 newsletter Car loan Cassio Lombardo
8 newsletter Car loan Trinity Zelaya Miramontes
9 newsletter Car loan Eldar Muravyov
10 newsletter Car loan Jameel Abdul-Ghani Gerges
11 newsletter Car loan Zeeb Longoria Marrero
12 seminar Savings Terry L. Ridgley
13 seminar Savings Gabrielly Sousa Martins
14 seminar Mortgage Miranda B. Roush
15 seminar Mortgage Miroslav Skaroupka
16 seminar Mortgage Matheus Azevedo Melo
17 seminar Mortgage Franca Palermo
18 seminar Pension Michelle M. Lopez
19 seminar Pension Will Henderson

Then let’s focus on seminar.

product customer
12 Savings Terry L. Ridgley
13 Savings Gabrielly Sousa Martins
14 Mortgage Miranda B. Roush
15 Mortgage Miroslav Skaroupka
16 Mortgage Matheus Azevedo Melo
17 Mortgage Franca Palermo
18 Pension Michelle M. Lopez
19 Pension Will Henderson

Summary

You learned how to set up and use IBM Decision Optimization CPLEX Modeling for Python to formulate a Mathematical Programming model and solve it with CPLEX.

References

Copyright � 2017-2019 IBM. IPLA licensed Sample Materials.