Customer segmentation using Advanced Analytics

By Sergio Sanchez, Artelnics.

Customer segmentation

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.


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.

Telemarketing image


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.

data table

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.

Data statistics results

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

Pie chart about targets distribution
Instances distribution pie chart.

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.

Logistic correlations
Logistic correlation chart.

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.


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.

neural network picture

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


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.

Neural network training results


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.

Information for testing the performance

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.

Ratios for predicted positives and negatives
Conversion rates chart.

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.

Cumulative gain chart
Cumulative gain plot.

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.


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) : 

		(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.

Inputs example table

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

Conversion table

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

It is very useful to see the 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".

Directional output chart
Directional output plot.

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


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.