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:
- Training a classification model on your data. This step involves creating a Training application.
- Using your trained model to predict churn score on new data. This step involves creating an Inference application.
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.
Building Training application is a 3 step process:
Go to the studio by clicking on STUDIO icon.
From the footer bar, click on NEW icon, it will display a new canvas.
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 datafor you. So search for
Churn Train datadataset. We will get a data block as shown in the screenshot:
Drag the data set to the canvas as shown :
On the right panel, click on BLOCKS icon and search for
BASE FORMATTERblock and drag it to the canvas. The block converts the input data in a format compatible with Datoin ML blocks.
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.
On right panel, search for
CHURN MODEL TRAINERblock and drag it to the canvas. This block is responsible for training the ML model.
Connect the base_vector and id fields from the
BASE FORMATTERblock to base_vector and groupKey fields respectively of the
CHURN MODEL TRAINERblock. The groupKey field just helps in accumulating all the documents before training.
Connect Churn field from the data set to is_churn field of
CHURN MODEL TRAINERblock.
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.
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 43
Click on BUILD button in the footer menu and build the trainer application.
- Currently, the studio is in Prepare mode. Click on CONFIGURE icon of
CHURN MODEL TRAINERblock. It will open configurations of the block on right side, expand it by clicking on it, it will be named
Churn Model Trainer Setting.
- Name your ML model and the folder you want to save the model in. Then save the changes by clicking on SAVE button.
Note: Keep note of the folder and the model name here. This will be used when we build the inference application later.
- 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.
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.
- Once the job completes, the status will be changed to SUCCEEDED. That means the training process is done and the model is ready.
- 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 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
Building Inference application is a 3 step process:
- Go to the studio by clicking on Studio icon.
- From the footer bar, click on New icon, it will display a new canvas.
- 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 datafor you. So search for
Churn Test datadataset.
Note: The data used in inference should have same fields as the training data except target label.
Drag the data set to the canvas.
On the right panel, click on Blocks icon and search for
BASE FORMATTERblock and drag it on the canvas. Connect the keys from dataset to formatter exactly in same way as in training.
CHURN PREDICTION CLASSIFIERand drag it to canvas, map base_vector and id from
CHURN PREDICTION CLASSIFIER.
CSV DATASET EXPORTERand drag it to the canvas, Connect the keys score and is_churn of
CHURN PREDICTION CLASSIFIERwith CSV exporter. The entire workflow is shown in below screenshot.
Optionally, you can set the target folder and target Data Set name where you want to save the results.
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.
Click on Build button in the footer menu and build the Inference application.
Currently, the studio is in Prepare mode. Click on Configure icon of
CHURN PREDICTION CLASSIFIERblock. It will open configurations of the block on right side, expand it by clicking on it, it will be named
Churn Prediction Classifier Setting.
Paste the ML model id that you have copied in Find the ML model step above.
Now click on dashboard and it will take you to app view page.
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.
- 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.
- 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.
That's it! You have built your first Churn prediction application using Datoin.