Customer loyalty cannot be directly observed or measured, but can be inferred probabilistically. This use case shows how to predict the loyalty level of customers to a retailer from customer shopping patterns.
Customers who make frequent purchases or costlier purchases tend to be more loyal to a brand than infrequent shoppers buying low-value items. A customer who makes a purchase each week is more loyal than a customer who makes a purchase once a year. Similarly, a customer spending more money is more loyal than a customer spending less money.
You can use the shopping patterns of several customers to build a Hidden Markov Model to analyze the loyalty of new customers who do not have extensive purchase histories. Gaining insight about the loyalty levels of customers can help retailers devise strategic marketing plans to retain loyal customers and convert low-loyalty customers to high loyalty. Retailers can also take proactive action to turn around the fading relationship with customers who show a downward trajectory of loyalty. This is particularly important for high-value customers.
The data set for this use case is the shopping history of customers. This data set is transformed into observations that can be used to train an HMM. Based on the time between purchases and the difference in amount spent between purchases, purchases are classified into the following different levels:
|Time between purchases||Difference in amount spent|
|Small (S)||Less (L)|
|Medium (M)||Same (S)|
|Large (L)||More (M)|
To determine the level that a purchase belongs to, you can use K-Means clustering with K=3 to generate clusters based on either time difference between purchases or difference in amount spent. Purchases clustered using either metric are classified into one of the three purchase levels. The observation associated with a purchase is the combination of the levels from both metrics.
Assuming that a customer has one of three loyalty levels—low (L), normal (N), or high (H)—the number of hidden states is three. The business determines the definitions of the loyalty levels.
This example uses supervised learning, so each purchase in the input data set is labeled with the customer loyalty level. You can use these labeled observations to train an HMM which can later be used to assign loyalty levels to new, unlabeled purchase data.