Predict churn of customers in telecommunications companies

End-to-end machine learning examples

Annual churn rates for telecommunications companies are usually greater than 10 %. Customer churn is a big problem for telecommunications companies.

For that reason, it is important that the companies are aware of churn rate to develop strategies that allows them to keep as many clients as possible.

The aim of this example is to use machine learning to understand why customers do churn and what can be done about it.

1. Application type

This is a classification project, since the variable to be predicted is binary (churn or loyal customer).

The goal here is to model the probability of churn, conditioned on the customer features.

2. Data set

The data file telecommunications_churn.csvcontains a total of 19 features for 3333 customers. Each row corresponds to a client of a telecommunications company for whom it has been collected information about the type of plan that they have contracted, the minutes that they have talked or the charge that they pay every month, among others.

The data set includes the following variables:

The first step of this analysis is to check the distrbutions of the variables. The next figure shows a pie chart of churn and loyal customers.

As we can see, the annual churn rate in this company is almost 15%.

The input-target correlations might indicate us what factors are most influential for the churn of customers.

Here, the most correlated variable with churn is international_plan. A positive correlation here means that a high ratio of customers with international plan are leaving the company. May be our competitors have better plans for those customers that make international calls.

2. Neural network

The predictive model is represented by a neural network.

The architecture shown below consists of 18 scaling neurons (yellow), 5 neurons in the first layer (blue) and 1 probabilistic neuron (red).

4. Training strategy

As we saw before, the data set is unbalanced. In that way, we set the weighted squared error as error method. The next chart shows how the loss decreases during the training process with the iterations of the Quasi-Newton method.

As we can see, the initial value is 1.24397, and the final value after 173 iterations is 0.333412.

The next table shows more information about the results of the training with the quasi-Newton method.

They show that the selection loss and the final parameters norm are not big and that the analysis of all the training instances was made in 12 seconds.

5. Model selection

The objective of model selection is to find the network architecture with best generalization properties, that is, that which minimizes the error on the selection instances of the data set.

More specifically, we want to find a neural network with a selection error less than XXX, which is the value that we have achieved so far.

Order selection algorithms train several network architectures with different number of neurons and select that with the smallest selection error.

The incremental order method starts with a small number of neurons and increases the complexity at each iteration. The following chart shows the training error (blue) and the selection error (orange) as a function of the number of neurons.

6. Testing analysis

Once the model has been trained, it is time to evaluate its performance on new data that have not been used neither for training nor for selection.

The ROC curve measures the discrimination capacity of the classifier between positives and negatives instances. The next chart shows the ROC curve for our problem.

The proximity of the curve to the upper left corner means that the model has a good capacity to discriminate between the two classes.

The most important parameter from the ROC curve is the area under the curve (AUC). This value is 0.5 for a random classifier and 1 for a perfect classifier. For this example we have AUC = 0.896, which means that the model is predicting well the churn of our customers.

confusion matrix

Predicted positive Predicted negative
Real positive 316 (15.8%) 96 (4.8%)
Real negative 325 (16.3%) 1263 (63.1%)

The binary classification tests are calculated from the values of the confusion matrix.

These binary classification tests show that the model can predict correctly most of the instances.

7. Model deployment

The predictive model takes the form of a function of the outputs with respect to the inputs. The mathematical expression of the predictive model which is listed below.

The above formula can be embedded into any software.

Related examples:

Related solutions: