Get In Touch
Please feel free to contact with any questions using the form below
By clicking the button you agree to process your personal data and agree with the privacy policy

How to Cross-sell if You Have No Time to Wait


How to Cross-sell if You Have No Time to Wait

It's important for a business to know who your buyers are, how old they are, where they live, and what they like. These characteristics help segment the buyers successfully. But, it is equally as important to be aware of what exactly they buy and how. That's why we should analyze shopping carts paying attention to the selection of products from different categories.
This analysis will allow to:
  • increase the effectiveness of marketing campaigns;
  • optimize the assortment and supplies;
  • create business templates of purchases.
The funniest example of this was the analysis of the carts by the company, Teradata, where "beer-diapers" turned out to be the most popular pair. It is very difficult to find such a connection without any special algorithms.
Many platforms have functions for the selection of product pairs using their own solutions. But it is time-consuming to set them up and the model needs at least two weeks to learn.
Our solution will allow you to detect such a pair in several hours and partially automate the manual recommendations.

Product Pairs Selection Algorithm

We use the associative rules search algorithms for selection, i.e. we search for logical interrelations between the connected data. In our case, the rule sounds like this: "If there is a product A in the cart, then there is a possibility that product B will also be there".
The more products there are, the more product pairs there will be. Following the logic, a product pair does not necessarily consist of two products, there may be three, four, five of them, and so on. The amount of pairs is calculated with this formula: 2^n — 1, where n is a number of products. For example, if you have 10 products, then there will be 2^10 — 1 = 1023 product pairs. This is why you need to understand that not all the received rules will be statistically significant.
To get only the real rules you need to use two main criteria — support and confidence.
  1. Support is the percentage of the transactions containing a certain product or a bundle of the products. It is used to bring out the most popular products.
support calculation formula
2. Confidence is the probability of the fact that if there is a product A, then there will be a product B.

confidence calculation formula
For the algorithm to work, you need to set up the minimal value of the support (min_sup) and confidence (min_conf).
Product Recommendations in Email-Campaigns: How It Works
As a rule, the minimum thresholds are defined experimentally. But you should remember about the peculiarities of the thresholds' minimal values:
  1. If the support value is too great, the algorithm will define meaningless rules at the output. That's why it isn't recommended to set the support to more than 20%.
  2. If the support value is small, several products may appear within the rules, which are actually random. In this case, you need to watch the lift value.
  3. If the confidence value is too small, as a rule, this pair cannot be taken into account. The confidence value <7% seems more random.
  4. The confidence value of more than 85% says that customers practically always buy this pair.
In the end, the associative rules search task is solved in two stages:
  1. Search for the most popular elements (support>min_sup);
  2. Derive the rules from the elements, formed on the first step (confidence>min_conf).
The most popular and productive data mining algorithm for associative rules search is the self-learning Apriori algorithm.
The arules package contains the functions managing Apriori's work. You can do the product pairs analysis via RStudio, but we will examine the work of the algorithm in the Power BI.

Getting the Data Ready for the Algorithm Launch

You need to process the data beforehand for the algorithm to work correctly. 80% of the result of the algorithm's work depends on the source data's quality. Moreover, if you don't have enough source data, you're unlikely to get adequate results.
Data submitted to the input should be represented as a transactional table, where every line is a separate transaction and the columns contain the names of the purchased products. In our case, it is a CSV file. We've changed the names of some products in order to maintain the client's privacy. Then upload this data into Power BI.
products table

Launching the Algorithm

We manage the Apriori algorithm via R-script opened in Power BI. Let's take a closer look at the script's work.
  1. We link up the libraries needed for the script's execution: library(Matrix)library(arules)library(readr). Make sure that you have installed all the necessary packages before launching the script in Power BI beforehand. For example, open install.packages("arules") in R-studio to install the "arules" package.
  2. In its current form, the data uploaded into the Power Query is not well-suited for the Apriori algorithm work in R. That's why the data transforms into transaction objects with the help of this function: data<-read.transactions(«file address», header=TRUE, sep=«,», encoding=«UTF-8»).
  3. We search the rules that determine the product pairs with the help of the apriori function. Minimal support and confidence values and also the minimal length are used as the parameters: datarules<-apriori(data, parameter = list(support=0.003, confidence=0.4, minlen=2)).
  4. We write the rules acquired from the previous step into the data format understandable by Power Query: output<-DATAFRAME(datarules).
If you need to input only the first N rules: output<-DATAFRAME(datarules[1:N]).
Power BI data input
All the rules are stored in the Value column, just unfold it and save the results:
table of products
LHS (left-hand-side) — the main product.
RHS (right-hand-side) — the complementary product.
lift shows the connection level between the variables. If lift<1 then the connection is negative, i.e. the products are the substitutes if lift=1 then there is no connection, and if lift>1 then the connection is positive.
If you've got meaningless rules, change the values of the minimum threshold.
What Lead Capture is, About its Channels, Mistakes, Examples

Representing the Results

After saving the acquired rules we need to represent them in a convenient way. It's better to use a graphic chart or a circular diagram tree to visualize the associative rules.
circular diagram tree visualizing associative rules
Circular diagram tree
The analysis of such a graphic chart allows highlighting the product categories beginning with the buyers' behavior. They also define the roles of the products in these categories.
The main products are the most popular products in each group. For example, in group №1 such products are a car transporter track and a Lego City set. Other products are complementary ones.
circular diagram tree with the most popular products
The mediator products are the ones that connect two groups of products between each other. The sales between groups happen exactly through such products.
circular diagram with mediator products
Victoria Ageikova
Senior Analyst
Victoria Ageikova
Senior Analyst
Get in touch
Tell us about your project and we will contact you for free consultation.