Red Back Arrow Back To Blog
Hawke AI Blog Post

How to Use Machine Learning For Customer Segmentation

Eric Vardon Profile image
Eric Vardon
How to Use Machine Learning For Customer Segmentation Featured Image


73% of CEOs acknowledge that products, services, and experiences need to be meaningful to their customers.

But what does ‘meaningful’ actually mean? 

In most cases, meaning and purpose leads to personalization: the process of tailoring every experience and touchpoint to each customer group. And, you do have strategically segmented customer groups, right?

Don’t worry if not. 

Machine learning, a form of artificial intelligence, is capable of analyzing data sets like customers and profiling the best (and worst)  performing customer segments automatically.

Let’s get into how this works. There are two forms of machine learning to be aware of. The first being supervised. This uses rules and settings given to adjust operations and output.

Unsupervised machine learning on the other hand, allows AI to build new datasets and begin finding patterns on its own. 

Both are extremely convenient as it’s time-consuming to analyze piles of data and find patterns manually. You should be investing that time in projects, nurturing relationships, and securing new business opportunities.

I will be showing you how to discover segments with machine learning in today’s article. Stick around to the end to learn how to automate the entire process, too.

Start Defending Against Marketing Failures Today!

Discover why over a 1000 businesses trust Hawke AI to help protect their marketing ROI.

Request a free trial

Customer segmentation with machine learning

The following steps are one of many approaches to segment customers through machine learning. Apply your company’s tools, teams, and skills to conduct these processes in the most optimal way.

Step 1: Create a business case

Everything needs a goal. You don’t want to go into this process blindly. Otherwise, the outcome will be messy and disorganized. 

Rather, you need a business case. I.e. the purpose of using machine learning and artificial intelligence, to begin with.

In your case, it’s finding the most profitable customer groups within the entire pool of customers.

Once you’ve done that, move onto step two.

Step 2: Prepare the data

How many customers do you have? 100? 1,000? 10,000? The more the merrier in the case of customer segmentation deep learning

This is because you will be able to find more patterns and trends within the datasets. 

You will also need to set different features (a measurable variable or attribute) depending on the most important metrics for your business. This may include:

  • Average lifetime value
  • Customer acquisition cost
  • Client satisfaction
  • Retention rate
  • Net profit
  • Etc.

These need to be determined because they contribute to the visualization process later. Data preparation can be done with an open-source tool like pandas. Customers will need to be exported as raw data to be used in a tool like this.

Furthermore, take this example where machine learning was used to find customers through the number of products ordered, return rate, and total spending. These were merged into a data frame (a list of variables) called “customers.” 

It resulted in the following distribution:

While this is very useful data, it needs to be scaled for the most optimal insights and decision making.

That brings me to the third step.

Step 3: Use K-means clustering

K-means clustering is a popular unsupervised machine learning algorithm method. 

In layman terms, it finds all of the different “clusters” and groups them together while keeping them as small as possible. That means that you end up with the most possible customer segments to interpret.

The algorithm assigns each data point to the closest centroid forming different groups while moving the average to the center of each cluster. It looks like this:

Source: Wikimedia

The algorithm checks the sum of squared distance between the cluster point and each center. It minimizes the distance and inertia of each cluster. When it converges, iteration stops. 

Step 4: Choosing optimal hyperparameters

Choosing the best set of hyperparameters for an algorithm is called hyperparameter optimization or tuning.

This is the next step in deep learning customer segments because it helps us find the most accurate and rewarding customer groups based on our previous work. 

Continuing with the previous example, setting k values 1–15 would result in the corresponding chart:

Note how the further along you look to the right, the less inertia is occurring and the data becomes accurately grouped with a positive skew.

A sharp contraction with an “elbow” at k=4 tells us that four customer groups are ideal for this dataset. 

Step 5: Visualization and interpretation

With all of your hard work done, it’s now time to visualize the findings and interpret it to grow your business. 

Having profitable customer profiles at your fingertips will help improve marketing campaign targeting, feature launches, and the product roadmap.

This will give your organization much more clear concepts about which clients have the highest retention rate, contracts, and other metrics you originally determined

You can then optimize each group with their associated pros and cons to drive growth.

In the case of the customer group example I’ve been referencing, the visualization looked like this:

There are four customer groups with various product orders, spending, and return rate amounts. This allowed the company to clearly see the most favourable customer profile to target.

Try using the open-source plotting library Plotly Python for making interactive graphs, plots, and charts.

Final thoughts on machine learning customer segments

Customer segmentation is necessary. You can’t serve every customer the same product, experience, or ad as they won’t resonate with it the same. Doing so results in low-click through rate, engagement, and conversions.

That’s where segmenting comes into the picture. Finding all of the unique groups that make up a bigger customer base lets you get into customer’s heads and give them exactly what they want, improving their experience and boosting revenue.

Machine learning can take care of this entire process for your agency. While you can program a machine learning algorithm to do it for you, instantly reap the results with less time through our AI marketing platform.

Try Morphio today for free. Simply connect your tools, channels, and Morphio will automatically find and alert you of audience anomalies that can be targeted to generate the most profit from campaigns.

Eric Vardon Profile image

Eric Vardon

CEO, Co-Founder @ Morphio

Stay updated with Hawke AI by subscribing to our newsletter.


    We use cookies to collect data to improve your experience. By continuing, you agree to our Cookie Policy.