IBM Accelerator Catalog
IBM Accelerator Catalog

Customer Retention Prediction Using DB2 Machine Learning Stored Procedures Notebook

Through this notebook, we showcase the inbuilt machine learning capabilities in Db2 to solve a common business problem (Customer retention).

Slide Two

About this accelerator

Through this notebook, we showcase the inbuilt machine learning capabilities in Db2 to solve a common business problem (Customer retention). The analytics stored procedures in Db2 use data from Db2 tables to provide an ML solution. We demonstrate the use of these analytics stored procedures and their integration with Watson Studio for model development via Python Jupyter notebook.

For more information, see Machine learning stored procedures.

Business Problem

One of the challenges in any business is to retain existing customers. Businesses often carry out surveys to gather public opinion on their products and services. A generic template for the survey includes a few personal questions, preferences, and product-related questions.

The machine learning model pipeline is as follows:

  • Establish a connection to the Db2 database from your notebook
  • Split train and test data
  • Train a decision tree model and KNN
  • Perform feature engineering
  • Finally, select the best model after testing it on the test data

Data

The sample data file named Customer_survey.csv used in this example is from a fictional customer survey. Modify cell 5 to point to the correct schema. This schema should contain the table named PROC_CUSTOMER_SURVEY (original dataset). Click the blue Download button above to download the zip file that also contains the sample data.

Results

The ML model was able to predict 72% customers may come back or retain for the given test dataset with the prediction/precision accuracy of 94%.

Note: Both the prediction and accuracy values could vary depending on many factors such as train/test data, feature engineering, etc.

Db2 Credentials

Load the Db2 credentials from a local json file in cell 1. If you are running the notebook for the first time then you will need to create a local json file named db2-cred.json. Fill in the username and password and then save it in the same working directory.

Content:

Content

Run on Watson Studio

This notebook can be directly imported into Watson Studio. For more information, see Notebooks (Watson Studio).


More information

Additional details

  • Accelerator typeNotebook
  • IndustryAny
  • Business functionAny
  • Product and version Watson Studio,Db2 on Cloud - Current
  • Author typeIBM
  • Company nameIBM
  • Author nameAaditya Shukla, Karan Karu
  • Last modifiedOctober 29th, 2020
  • Language English