Diy Platform Building Churn Model

Build your own Churn Model

Acquiring new customers can be several times more expensive than retaining existing ones. One of the main problems of all the businesses is to reduce the customer churn or to retain their existing customers. Building a machine learning application for predicting churn score of a customer can help the enterprises in retaining their customers.

The reader of this document is expected to have an intermediate level of understanding about Datoin features. Before reading this page take a Quick Walkthrough.
Please login to Datoin Dashboard if you have not logged in already.

Let us see how we can build a Datoin ML application to predict the churn scores.

Here are the steps you will need to follow to build a Churn analysis application using Datoin:

  1. Training a classification model on your data. This step involves creating a Training application.
  2. Using your trained model to predict churn score on new data. This step involves creating an Inference application.

Data:

The fuel of every machine learning application is data. So, first of all, we need training data to train our model.
The data should be customer or dealer data with any number of numeric, categorical and/or Boolean fields (these are called features) and one target field which should contain YES or TRUE for churned customers and NO or FALSE otherwise.
The example data we are using is from telecommunication industry and it contains different customer metrics like total calls, total SMS, geography etc. These metrics become features to the trainer application.
Here is the screenshot of the sample data.
Screenshot From 2018 05 29 16 23 58

Training application:-

Building Training application is a 3 step process:
a) Design
b) Prepare
c) Run

a) Design:

  1. Go to the studio by clicking on STUDIO icon.

  2. From the footer bar, click on NEW icon, it will display a new canvas.

  3. Search for the training Data Set by searching on DATA SET in the search bar in the right panel. For this example, we have already uploaded a training data set called Churn Train data for you. So search for Churn Train data dataset. We will get a data block as shown in the screenshot:
    Screenshot From 2018 05 28 16 07 22

  4. Drag the data set to the canvas as shown :
    Screenshot From 2018 05 28 16 09 55

  5. On the right panel, click on BLOCKS icon and search for BASE FORMATTER block and drag it to the canvas. The block converts the input data in a format compatible with Datoin ML blocks.

  6. Connect all the keys from dataset to the Base Formatter block except the key named Churn. Because Churn key is our target label to be predicted.
    Screenshot From 2018 05 28 16 16 14

  7. On right panel, search for CHURN MODEL TRAINER block and drag it to the canvas. This block is responsible for training the ML model.

  8. Connect the base_vector and id fields from the BASE FORMATTER block to base_vector and groupKey fields respectively of the CHURN MODEL TRAINER block. The groupKey field just helps in accumulating all the documents before training.

  9. Connect Churn field from the data set to is_churn field of CHURN MODEL TRAINER block.

  10. Search for JSON EXPORTER, you will find a block named Json Line Exporter, drag it to the canvas and connect the evaluation_report field to it. The entire workflow is shown in below screenshot.
    Screenshot From 2018 05 28 16 26 26

  11. Now click on SETTINGS icon in the right panel and enter the application name and description in the form.![Screenshot From 2018 05 28 16 42 43Screenshot From 2018 05 29 11 04 29

  12. Click on BUILD button in the footer menu and build the trainer application.

b) Prepare

  1. Currently, the studio is in Prepare mode. Click on CONFIGURE icon of CHURN MODEL TRAINER block. It will open configurations of the block on right side, expand it by clicking on it, it will be named Churn Model Trainer Setting.
  2. Name your ML model and the folder you want to save the model in. Then save the changes by clicking on SAVE button.
    Screenshot From 2018 05 29 15 55 54

Note: Keep note of the folder and the model name here. This will be used when we build the inference application later.

  1. Your app is ready to run! Click on DASHBOARD icon in the footer menu. You will be taken to the dashboard of the trainer application.

c) Run
16) To run the trainer application, click on Run as Batch icon. The training will take few minutes to few hours depending on the algorithm and training data. The status of the application will be Running. You can view logs by clicking on View Logs link that is present below the Run Status. In this particular example, training will take some 6 to 8 minutes.
Screenshot From 2018 05 28 16 52 31

  1. Once the job completes, the status will be changed to SUCCEEDED. That means the training process is done and the model is ready.
  2. The JSON report of the generated model can be viewed in datasets.
    On Dashboard click on DATA icon from the left panel ➤ DATA SETS icon from the sidebar. Navigate to my-data/jl/, there you will find a folder with name same as you have named your training application in step 11. Inside this folder, there will be a file named data-run-x, where x will be your iteration number of app. It is a JSON object, you can click on it to view accuracy, precision of model.

Congratulations on successfully completing the training process on your data. Let us use the trained model to predict churn for new customer data.

Troubleshooting the Training application
Below are the options to try, if your training process was not successful:

  • If job status is FAILED:
    This could be possible because of:
    1) Limited resources.
    Try with a small amount of training data or contact datoin help team for increasing resources.
    2) Wrong key mapping:
    Review key mapping (connection between blocks), ensure that it is proper as shown in above steps.
    Logs can also give you an idea of what went wrong, view logs (step 16) and look for error messages.
    If the problem persists, please contact the Datoin support team via the Ask for help! chatbot.

Inference application:

Inference applications use the ML model, built by the training application (previous step), to predict the churn score for given customer. Let us create an inference application.

Find the ML model

On Dashboard, click on DATA icon from the left panel ➤ Models icon from the sidebar. Now navigate to a folder with the name as you have set in step 14 of training.
Inside that folder, you will find an ML model with the name as you have set in step 14 of training. Each run of your training application will produce a new ML model. The number at the end of the model name indicates this.
Click on Options drop-down on the right side of your ML model and copy the id of the model by clicking on Copy Id. In this example the model is Data/Models/abc/churn_prediction_model_2
Screenshot From 2018 05 29 16 10 29

Build application

Building Inference application is a 3 step process:
a) Design
b) Prepare
c) Run

a) Design

  1. Go to the studio by clicking on Studio icon.
  2. From the footer bar, click on New icon, it will display a new canvas.
  3. Search for the DataSet on which you want to infer by searching on DataSet in the search bar in the right panel. For this example, we have already uploaded a data set called Churn Test data for you. So search for Churn Test data dataset.

Note: The data used in inference should have same fields as the training data except target label.

  1. Drag the data set to the canvas.

  2. On the right panel, click on Blocks icon and search for BASE FORMATTER block and drag it on the canvas. Connect the keys from dataset to formatter exactly in same way as in training.

  3. Search for CHURN PREDICTION CLASSIFIER and drag it to canvas, map base_vector and id from Base formatter to CHURN PREDICTION CLASSIFIER.

  4. Search forCSV DATASET EXPORTER and drag it to the canvas, Connect the keys score and is_churn of CHURN PREDICTION CLASSIFIER with CSV exporter. The entire workflow is shown in below screenshot.
    Screenshot From 2018 05 28 17 31 55

  5. Optionally, you can set the target folder and target Data Set name where you want to save the results.

  6. Now click on Settings icon on the right panel and enter the application name and description in the form similarly as done in training application.

  7. Click on Build button in the footer menu and build the Inference application.

b) Prepare

  1. Currently, the studio is in Prepare mode. Click on Configure icon of CHURN PREDICTION CLASSIFIER block. It will open configurations of the block on right side, expand it by clicking on it, it will be named Churn Prediction Classifier Setting.

  2. Paste the ML model id that you have copied in Find the ML model step above.
    Screenshot From 2018 05 29 09 56 34

  3. Now click on dashboard and it will take you to app view page.

  4. Your app is ready to run! Click on Dashboard icon in the footer menu. You will be taken to the dashboard of the Inference application.

c) Run

  1. To run the Inference application, click on Run as Batch icon. The inference will take few minutes to few hours depending on data size. The status of the application will be Running. You can view logs by clicking on View Logs link that is present below the Run Status. In this particular example inference will take some 2 to 3 minutes.
  2. Once the job gets completed, the status will be changed to SUCCEEDED. That means the inference process is done and results are ready. Navigate to Data/Data Sets/my-data/csv/churn-classifier-app/data-run-1. This will be a CSV file containing the churn score and the is_churn (boolean value) for every input document.
    NOTE: The above path may change, depending on the name you have set in step 8.
    Screenshot From 2018 05 29 17 04 17

That's it! You have built your first Churn prediction application using Datoin.