## Customer segmentation using Advanced Analytics

##### By Sergio Sanchez, Artelnics.

Customer segmentation is a marketing strategy that divides a customer base into discrete customer groups that share similar characteristics. By analysing data such as age, gender, interests and spending habits you can target specific clients and allocate resources optimally.

The following study shows an example of customer segmentation applied to telemarketing.

### Introduction

Telemarketing is a form of direct marketing that is widely used by all types of companies. This technique can be extremely powerful at generating sales, but it requires a strict selection of potential clients. Advanced Analytics allows us to select individual targets, which results in increased profitability.

The following study consists in analysing data from bank telemarketing campaigns to build a decision support system. This system can predict which customers will sign a deposit and which will not in order to maximize conversion rates and minimize costs.

### Data

The bank telemarketing database used here is related to direct marketing campaigns of a Portuguese bank institution. It contains information about 4.521 customers of a bank with 19 attributes. This adds up to a total of 85.899 data.

Every instance has different features such as age, account balance or last call duration. It also includes a flag to indicate whether the client has subscribed or not to a long-term deposit in a previous campaign.

The following listing is a preview of the data file.

### Descriptive analytics: What happened?

Descriptive analytics is a preliminary stage of data processing that creates a summary of historical data to yield useful information and possibly prepare the data for further analysis.

Basic statistics are very valuable information when designing a model, since they might alert to the presence of spurious data. It is a must to check for the correctness of the most important statistical measures of every single variable. The table below shows the minimums, maximums, means and standard deviations of all the variables in the data set.

Calculating the number of instances of each class in the target variable is another important descriptive analytics task. It shows the number of instances with negative conversion and the number of instances with positive conversion.

As we can see, the conversion rate here is 11.5%. Our main goal is to increase this number.

### Diagnostic analytics: Why did it happen?

Diagnostic Analytics is a form of Advanced Analytics which is focused on determining the factors and events that contributed to the outcome. It is characterized by techniques such as data discovery, data mining and correlations.

For pattern recognition problems, we can look for logistic dependencies between single input variables and the target variable. The following chart illustrates these dependencies.

The y-labels from greater to smaller correlations are: duration, previous_conversion, last_contact, contact_type, housing, ...

As we can see, the last variable (default) is not representative to predict the target variable. Therefore, it is classified as unused variable.

The first variable (call duration) is also classified as unused. We cannot know beforehand how long the call will last, so that it cannot be a predictor variable.

### Predictive analytics: What will happen?

Predictive analytics is the branch of Advanced Analytics that is used to make predictions about unknown future events. It uses machine learning algorithms to identify the likelihood of future outcomes based on historical data.

This part is divided into four subparts: configuration, training, testing and deployment.

#### Configuration

The neural network defines the predictive model as a multidimensional function containing adjustable parameters. The first step to create our predictive model is to choose a neural network architecture that represents the classification function.

The next figure is a graphical representation of the neural network used for this problem.

The number of inputs is 16, and the number of outputs is 1. The complexity, represented by the number of hidden neurons is 1.

#### Training

Once the architecture has been selected we carry out the training strategy. It is applied to the neural network in order to obtain the best possible performance.

The algorithm selected to train this neural network is the Quasi-Newton method (to learn more about this algorithm visit 5 algorithms to train a neural network). The next table shows the training results by the quasi-Newton method. It includes some final states from the neural network, the performance functional and the training algorithm.

#### Testing

Once the most technical part of our problem has been completed, we run different tests to determine if the predictive model is ready to make predictions.

The task "Calculate binary classification tests" provides us with some useful information for testing the performance of our problem. The next figure shows the output of this task.

The classification accuracy takes a high value of 76,8%, which means that the prediction is good for a large amount of cases.

Conversion rates measure the percentage of cases that perform a desired action. This value can be optimized by acting directly on the client or by a better choose of the potential consumer.

The next chart shows three rates. The first pair of columns represent the rates of the data set, the second pair represents the ratios for the predicted positives of the model and the last columns show the rates for the predicted negatives of the model.

The model multiplies the positives rate of the actual data by 2.5. The last columns shows the rates for the predicted negatives of the model. The model multiplies the negatives rate of the actual data by 1.1. This means that we will get greater accuracy for the next marketing campaign.

Finally, we run the cumulative gain task to make sure that our predictive model is ready to make predictions.

Cumulative gain charts are visual aids widely used in marketing for measuring the advantages of a predictive model.

In this case, the curve shows that the bank is able to reach more than 50% of the buyers by calling a little over 10% of customers.

#### Deployment

Once the predictive model has been tested, the algorithm can be saved for future use in the so-called “production mode”.

The mathematical expression of the predictive model written in Python code is shown below.

from math import exp def Logistic (x) : return (1/(1+exp(-x))) def Probability (x) : if x < 0 : return 0 elif x > 1 : return 1 else : return x def expression (age, job, married, single, divorced, education, default, balance, housing, loan, contact_type, day, month, duration, campaign_contacts, last_contact, previous_contacts, previous_conversion) : scaled_age=2*(age-19)/(87-19)-1 scaled_job=2*(job-0)/(2-0)-1 scaled_married=2*(married-0)/(1-0)-1 scaled_single=2*(single-0)/(1-0)-1 scaled_divorced=2*(divorced-0)/(1-0)-1 scaled_education=2*(education-1)/(3-1)-1 scaled_default=2*(default-0)/(1-0)-1 scaled_balance=2*(balance+3313)/(71188+3313)-1 scaled_housing=2*(housing-0)/(1-0)-1 scaled_loan=2*(loan-0)/(1-0)-1 scaled_contact_type=2*(contact_type-0)/(1-0)-1 scaled_day=2*(day-1)/(31-1)-1 scaled_month=2*(month-1)/(12-1)-1 scaled_duration=2*(duration-5)/(3025-5)-1 scaled_campaign_contacts=2*(campaign_contacts-1)/(50-1)-1 scaled_last_contact=2*(last_contact-1)/(871-1)-1 scaled_previous_contacts=2*(previous_contacts-0)/(25-0)-1 scaled_previous_conversion=2*(previous_conversion-0)/(1-0)-1 y_1_1=Logistic(-0.845372 +2.44839*scaled_age -1.98881*scaled_job -1.28157*scaled_married +0.299261*scaled_single +1.68906*scaled_divorced -0.99358*scaled_education +1.1506*scaled_default +2.59413*scaled_balance -5.00125*scaled_housing -1.77903*scaled_loan +0.0659562*scaled_contact_type +1.58641*scaled_day -2.29512*scaled_month -0.7448*scaled_duration -1.40672*scaled_campaign_contacts -0.292286*scaled_last_contact +1.30387*scaled_previous_contacts +7.39566*scaled_previous_conversion) y_1_2=Logistic(-0.985658 +0.441268*scaled_age -0.126779*scaled_job +0.501291*scaled_married +0.557487*scaled_single +0.744254*scaled_divorced -0.347301*scaled_education +0.331576*scaled_default +0.946399*scaled_balance +0.188675*scaled_housing +0.13908*scaled_loan +1.43838*scaled_contact_type -0.0805846*scaled_day +0.337348*scaled_month -6.35792*scaled_duration +2.36321*scaled_campaign_contacts +0.0101778*scaled_last_contact -0.64957*scaled_previous_contacts +0.307788*scaled_previous_conversion) y_1_3=Logistic(-0.691795 -5.67445*scaled_age -0.0942581*scaled_job +0.833415*scaled_married +0.461637*scaled_single -0.03732*scaled_divorced +1.41335*scaled_education +1.29597*scaled_default -0.0798936*scaled_balance -0.676705*scaled_housing +4.66136*scaled_loan -8.43715*scaled_contact_type +3.78287*scaled_day -5.7032*scaled_month -3.20221*scaled_duration -2.42509*scaled_campaign_contacts -0.558123*scaled_last_contact +1.9523*scaled_previous_contacts -1.78601*scaled_previous_conversion) non_probabilistic_conversion=Logistic(10.4448 +4.39097*y_1_1 -12.6806*y_1_2 -8.37086*y_1_3) (conversion) = Probability(non_probabilistic_conversion) return conversion

As we can see, it takes the inputs age, job, married, single, divorced, education, balance, housing, loan, contact, day, month, campaign, pdays, previous and poutcome to produce the output prediction.

### Prescriptive analytics: How can we make it happen?

Prescriptive analytics is the application of the predictive model to determine the best solution or outcome among various choices, given the known parameters.

The following table shows a hypothetical client of our bank.

We can predict whether this client is going to buy the product by running the algorithm calculated above. The next table shows the result.

There is a 39,60% probability that this client will buy the financial product.

It is very useful to see how the result varies as a function of a single variable, when all the others are fixed. This can be seen by calculating the directional output. The next plot shows the target variable "conversion" as a function of the variable "contact_type".

The goal is to predict different scenarios to plan a strategic approach to each of them.

### Conclusion

Nowadays, it is widely recognized that personalised marketing significantly outperforms traditional customer segmentation. Advanced Analytics studies personal and behavioral data to accurately target those most profitable clients.

The results from this application of predictive analytics show that valuable knowledge can be extracted from customers’ data. By selecting the most likely buyers, revenues can be significantly increased while at the same time reducing costs.