Customer Personality Analysis with Python

Data Science Project on Customer Personality Analysis with Python

Customer Personality Analysis is a detailed analysis of a company’s ideal customers. It helps a business to better understand its customers and makes it easier for them to modify products according to the specific needs, behaviours and concerns of different types of customers. In this article, I’m going to introduce you to a data science project on customer personality analysis with Python.

Customer Personality Analysis

Customer personality analysis helps a business to modify its product based on its target customers from different types of customer segments. For example, instead of spending money to market a new product to every customer in the company’s database, a company can analyze which customer segment is most likely to buy the product and then market the product only on that particular segment.

Also, Read – 200+ Machine Learning Projects Solved and Explained.

The most important part of a customer personality analysis is getting the answers to questions such as:

  1. What people say about your product: what gives customers’ attitude towards the product.
  2. What people do: which reveals what people are doing rather than what they are saying about your product.

In the section below, I’ll walk you through a data science project on analyzing customer personality with python. Here I will be using a dataset that contains data collected from a marketing campaign, where our task is to predict how different customer segments will respond for a particular product or service.

Customer Personality Analysis with Python

Now let’s start with the task of customer personality analysis with Python. Since this is a segmentation task, we will use clustering to summarize customer segments and then we will also use the Apriori algorithm here. Now let’s start by importing the necessary Python libraries and the dataset:

Before moving further, let’s have a look at the data by using the automatic EDA technique:

from dataprep.eda import plot, plot_correlation, create_report, plot_missing
plot(data)
EDA customer personality analysis
Note: You will get to see more visualizations in the output.

Now I will create some new features in the dataset to define the customer personalities as a part of data preparation:

First Five Rows in the Dataset
First Five Rows in the Dataset

Now I will remove the outliers and the missing values in the dataset:

data=data.dropna(subset=['Income'])
data=data[data['Income']<600000]

Clustering

To take a look at the clustering of clients in the dataset, I’ll define the segments of the clients. Here we will use 4 equally weighted customer segments:

  1. Stars: Old customers with high income and high spending nature.
  2. Neet Attention: New customers with below-average income and low spending nature. 
  3. High Potential: New customers with high income and high spending nature.
  4. Leaky Bucket: Old customers with below-average income and a low spending nature.

In the code section below, I will first normalize the data and then I will create customer clustering according to the metrics defined above:

clusters for customer personality analysis

Now let’s plot this data to have a look at the clustering of customers:

clustering on dataset

Data Preparation for Customer Personality Analysis

Now I will prepare the data for the Apriori algorithm. Here I will be defining three segments of the customers according to the age, income and seniority:

Now I will define new segments according to the spending of customers on each product which will be based on:

  1. Non Buyer
  2. Low Buyer
  3. Frequent Buyer
  4. Biggest Buyer

Apriori Algorithm

The Apriori algorithm is the simplest technique to identify the underlying relationships between different types of elements. The idea behind this algorithm is that all nonempty subsets of a frequent category must also be frequent. Here I will be using the Apriori algorithm for the task of customer personality analysis with Python. Here I will use this algorithm to identify the biggest customer of wines:

Conclusion

So according to the output and overall analysis conducted on this data science project on customer personality analysis with Python, we can conclude that the biggest customers of wines are:

  1. Customers with an average income of around $69,500.
  2. Customers with an average total spend of approximately $1,252.
  3. Customers registered with the company for approximately 21 months.
  4. Customers with a graduate degree.
  5. And customers who are also heavy consumers of meat products.

I hope you liked this article on Customer Personality Analysis with Python. Feel free to ask your valuable questions in the comments section below.

Default image
Aman Kharwal
Coder with the ♥️ of a Writer || Data Scientist | Solopreneur | Founder
Articles: 1102

Leave a Reply