WARNING: This repository is no longer maintained :warning: This repository will not be updated. The repository will be kept available in read-only mode.
This repository will not be updated. The repository will be kept available in read-only mode. For an alternate, please see https://github.com/IBM/predictive-model-on-watson-ml or the on-premise Cloud Pak for Data version of this pattern: https://github.com/IBM/telco-customer-churn-on-icp4d
In this Code Pattern, we use IBM Watson Studio to go through the whole data science pipeline to solve a business problem and predict customer churn using a Telco customer churn dataset. Watson Studio is an interactive, collaborative, cloud-based environment where data scientists, developers, and others interested in data science can use tools (e.g., RStudio, Jupyter Notebooks, Spark, etc.) to collaborate, share, and gather insight from their data as well as build and deploy machine learning and deep learning models.
When the reader has completed this Code Pattern, they will understand how to:
Sign up for IBM's Watson Studio. By creating a project in Watson Studio a free tier Object Storage service will be created in your IBM Cloud account. Take note of your service names as you will need to select them in the following steps.
Note: When creating your Object Storage service, select the Free storage type to avoid having to pay an upgrade fee.
Note: By creating a project in Watson Studio a free tier
Object Storage
service will be created in your IBM Cloud account. Take note of your service names as you will need to select them in the following steps.
New Project
.Data Science
option and click Create Project
.Create
Download the dataset we will use in this pattern from the following link: https://community.watsonanalytics.com/wp-content/uploads/2015/03/WA_Fn-UseC_-Telco-Customer-Churn.csv
Drag and drop the dataset (csv
) file you just downloaded to Watson Studio's dashboard to upload it to Cloud Object Storage.
Import the notebook found in this repository inside the notebook folder by copying and pasting this URL in the relevant field https://raw.githubusercontent.com/IBM/customer-churn-prediction/master/notebooks/customer-churn-prediction.ipynb
Give a name to the notebook and select a Python 3.5
runtime environment, then click Create
.
To make the dataset available in the notebook, we need to refer to where it lives. Watson Studio automatically generates a connection to your Cloud Object Storage instance and gives access to your data.
2. Loading Our Dataset
Insert to code
for the data you have uploaded. Choose Insert pandas DataFrame
.Machine Learning
or use the Search bar to find Machine Learning
.Create
.Service credentials
tab on the left, view credentials and make a note of them.Note: If you can't see any credentials available, you can create a
New credential
.
14. ROC Curve and models comparisons
. You will need to replace the code inside with your credentials.The steps should allow you to understand the dataset, analyze and visualize it. You will then go through the preprocessing and feature engineering processes to make the data suitable for modeling. Finally, you will build some machine learning models and test them to compare their performances.
Click on the following button to clone the repo for this frontend app and create a toolchain to start deploying the app from there.
IBM Cloud API Key:
choose Create+
, and then click on Deploy
.To monitor the deployment, in Toolchains click on Delivery Pipeline
and view the logs while the apps are being deployed.
Runtime
on the menu and navigate to the Environment variables
tab.WML_INSTANCE_NAME
, USERNAME
, PASSWORD
, INSTANCE_ID
, and URL
, that you saved at the end of Create Watson Machine Learning Service instance. Add the MODEL_URL
that you created in the Notebook as the variable scoring_endpoint
.
The app will automatically restart and be ready for use.For developing the UI locally and testing it:
cd frontend/
Create a .env
file in frontend folder (frontend/.env) to hold your credentials.
cp env.example .env
For our purposes here, our .env
file will look like the following:
WML_INSTANCE_NAME=**Enter with your Watson Machine Learning service instance name**
USERNAME=**Enter your WML username found in credentials**
PASSWORD=**Enter your WML password found in credentials**
INSTANCE_ID=**Enter your WML instance_id found in credentials**
URL=**Enter your WML url found in credentials**
MODEL_URL=**Change with your model URL after deploying it to the cloud as in step 8**
Copy the variable for the .env file using the variables obtained at the end of Create Watson Machine Learning Service instance. Add the MODEL_URL
that you created in the Notebook.
Run the application.
cd frontend/
npm install
npm start
You can view the application in any browser by navigating to http://localhost:3000. Feel free to test it out.
This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.