📜 ⬆️ ⬇️

Apriori: new or well forgotten old



Recommended (they are also recommendation) systems have been used in e-commerce for about 20 years. The most successful examples we can see in the giants are Amazon and Taobao. But what about offline retail? Do these existing recommender systems apply to it? And is there an alternative?

A task arose for the Datawiz team: to create a similar recommendation system for offline retail. All we had was customer data held by retailers - various loyalty programs.
')
A non-standard solution was found immediately - the old, kind and proven Apriori algorithm. Want to learn how to use pair analysis in a new way? Welcome under cat.

Let's look at one of the examples of conducting a pairwise analysis according to the loyalty program of an electronics store.

The example is schematic, do not blame me.

So, Igor and Sasha are regular customers of the same chain, they are participants of the loyalty program and they have discount cards of this store.

These are their purchases:




Standard solution : If we apply classic pair analysis to these checks, the Apriori algorithm will analyze each individual shopping basket (each individual check). The algorithm will calculate all possible pairs in each check; probability and frequency of purchase of these goods together.

In our example, Apriori will find one obvious pair of “TV - Adapter”, with a high probability and frequency of purchase. But is it? Just one pair?

Our solution : the algorithm is the same - the approach is different. Interesting?

STEP 1


We combine all Igor's checks into one check. We also do the checks of Sasha and other customers from the loyalty program. We get the number of checks equal to the number of customers participating in the loyalty program.



STEP 2


After we have combined checks for each client, apply the Apriori algorithm to them. The algorithm still allocates a pair of "TV-Adapter", as often purchased. But at the same time he gives out other pairs with a high probability of purchase, which were previously invisible: “TV-Audio System”, “Adapter-Audio System”, etc.

STEP 3


We determine the time distance between events, that is, the interval between purchases of the pairs found by us. This value will be averaged. For couples “TV-Audio” and “Adapter-Audio”, this interval will be 1 year 4 months ((1 year + 1 year 8 months) / 2).

So, we found pairs “scattered” in time (well, or so - distributed over a long period of time).

Why do we need it and “what do we have from this goose”? :)


By applying the Apriori algorithm to the data on the loyalty program and finding these “scattered” pairs, we can create a recommender system.

For example, each new customer who acquires a TV or an Adapter, after about 1 year and 4 months. You can make a profitable offer to purchase the audio system.

At the exit, we will have a table with recommendations: when and with which client to contact, and what to offer.



Further, the choice of the tool for direct marketing: e-mail, sms, phone call - all means are good.

Application of pair analysis of loyalty program data for different types of retail:


In the retail of electronics, the pairwise analysis under the loyalty program is best carried out not by product, but by product category. Since there is a constant replenishment of the range, change and expansion of the model series.

For retail clothing, a new method of pair analysis should also be carried out by product category. This is due to the short life cycle of the product (change of collections, brands and other specifics of the industry).

In the food retail pair analysis under the loyalty program is also applicable.
Here, the frequency of purchases is very high, but it is even easier to identify patterns (customer patterns) of customers. Although steam will be much more.

Example: a client thoroughly “tares” once a week - on Saturday, but in the middle of the week (Tuesday-Wednesday) he constantly comes for yogurt, buns and other “goodies”. If the retailer offers this client a good discount on yogurt buns on Saturday, the client is not likely to resist this offer, because he would have bought them already. And by Wednesday the yoghurt will end safely and the customer will come to the store again, because it is a habit :).

What is this all about?


Detection of typical shopping patterns and those pairs that cannot be detected with the classic pairwise analysis is a source of additional profit for the company.

Well, and the better you know your customers, and the more personalized your communication with them - the higher the loyalty. After all, for this and there are loyalty programs, is not it?

PS About pair analysis for retail we have an article on Habré. (As with the Apriori algorithm, we analyze shopping carts and identify paired products (key and related), and what is the practical application of such an analysis when placing goods on the trading floor).

Don't forget to read our other article “Clustering: tell me what you buy, and I will tell you who you are.”

All good!

Source: https://habr.com/ru/post/249243/


All Articles