Introduction

Understanding how marketing works begins with analysing customer behavior. It is important to identify the key factors that influence purchasing decisions and how, as sellers we can use these insights to optimise sales strategies. Identifying such patterns in the market can uncover valuable opportunities for sales improvement and business growth.

To achieve this, I apply association rule mining to analyse relationships between different factors. This approach helps uncover patterns in product categorization and potential market trends, allowing businesses to make data-driven decisions.

Dataset

For this analysis I used the Market Data. This dataset contains transactional data representing customer purchases, making it suitable for market basket analysis.

Each row in the dataset represents a customer’s shopping basket, containing a list of products purchased in a single transaction. By analysing these transactions, we can identify frequently bought-together products, helping businesses optimise product placement, cross-selling strategies, and targeted promotions.

Analysis

Loading useful packages.

library(arules)
library(ggplot2)
library(arulesViz)

Loading Market Data dataset.

market <- read.csv("market_new.csv")
head(market)
##   Bread Honey Bacon Toothpaste Banana Apple Hazelnut Cheese Meat Carrot
## 1     1     0     1          0      1     1        1      0    0      1
## 2     1     1     1          0      1     1        1      0    0      0
## 3     0     1     1          1      1     1        1      1    1      0
## 4     1     1     0          1      0     1        0      0    0      0
## 5     0     1     0          0      0     0        0      0    0      0
## 6     0     1     0          1      0     0        1      0    0      0
##   Cucumber Onion Milk Butter ShavingFoam Salt Flour HeavyCream Egg Olive
## 1        0     0    0      0           0    0     0          1   1     0
## 2        1     0    1      1           0    0     1          0   0     1
## 3        1     1    1      0           1    1     1          1   1     0
## 4        1     1    1      0           0    0     1          0   1     1
## 5        0     0    0      0           0    0     0          0   0     0
## 6        0     1    0      0           1    0     0          0   0     0
##   Shampoo Sugar
## 1       0     1
## 2       1     0
## 3       0     1
## 4       1     0
## 5       0     0
## 6       0     1

Checking if there are any missing values.

colSums(is.na(market))
##       Bread       Honey       Bacon  Toothpaste      Banana       Apple 
##           0           0           0           0           0           0 
##    Hazelnut      Cheese        Meat      Carrot    Cucumber       Onion 
##           0           0           0           0           0           0 
##        Milk      Butter ShavingFoam        Salt       Flour  HeavyCream 
##           0           0           0           0           0           0 
##         Egg       Olive     Shampoo       Sugar 
##           0           0           0           0

There are no missing values in the dataset, so we can proceed without any changes in dataset.

## Warning: pakiet 'arules' został zbudowany w wersji R 4.4.2
## Ładowanie wymaganego pakietu: Matrix
## 
## Dołączanie pakietu: 'arules'
## Następujące obiekty zostały zakryte z 'package:base':
## 
##     abbreviate, write

Converting dataset into transaction format.

market <- as(as.matrix(market), "transactions")
summary(market)
## transactions as itemMatrix in sparse format with
##  10464 rows (elements/itemsets/transactions) and
##  22 columns (items) and a density of 0.4945528 
## 
## most frequent items:
##   Bread   Olive  Butter   Flour    Salt (Other) 
##    5296    5235    5208    5206    5204   87701 
## 
## element (itemset/transaction) length distribution:
## sizes
##    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16 
##   19   22   14   46  112  202  436  821 1220 1579 1743 1567 1237  750  414  191 
##   17   18   19   20   21 
##   71   15    3    1    1 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    9.00   11.00   10.88   13.00   21.00 
## 
## includes extended item information - examples:
##   labels
## 1  Bread
## 2  Honey
## 3  Bacon
  • The most frequently purchased product is bread, which is expected since it is a staple food.
  • The minimum number of products per basket is 1, while the maximum is 21.
  • The most popular basket size contains 11 products.
size(market[1:100])
##   [1]  9 12 17 11  1  6  6  8 14  6 10  9 15 13 10  4  3  4 13 14  4  9 10  8  7
##  [26] 12  5  9 12  9 13 14 12 14  9 12  7  2  9  8  4  4  5 12 10  9  1 12 12 11
##  [51] 12 11  6  9 14 10  7 15  3 13  9 10  6 12 15 13 12 10 12 14 13  8 11 11  6
##  [76]  4  1 14 13 13  8  7  2  5  6  9  5 11 14  3 10  4 14 10  9  4  6 13 15  8

Dataset contains 10,464 transactions (baskets) and 22 products. This provides a good representation for analysis.

inspect(market[1:50])
##      items         
## [1]  {Bread,       
##       Bacon,       
##       Banana,      
##       Apple,       
##       Hazelnut,    
##       Carrot,      
##       HeavyCream,  
##       Egg,         
##       Sugar}       
## [2]  {Bread,       
##       Honey,       
##       Bacon,       
##       Banana,      
##       Apple,       
##       Hazelnut,    
##       Cucumber,    
##       Milk,        
##       Butter,      
##       Flour,       
##       Olive,       
##       Shampoo}     
## [3]  {Honey,       
##       Bacon,       
##       Toothpaste,  
##       Banana,      
##       Apple,       
##       Hazelnut,    
##       Cheese,      
##       Meat,        
##       Cucumber,    
##       Onion,       
##       Milk,        
##       ShavingFoam, 
##       Salt,        
##       Flour,       
##       HeavyCream,  
##       Egg,         
##       Sugar}       
## [4]  {Bread,       
##       Honey,       
##       Toothpaste,  
##       Apple,       
##       Cucumber,    
##       Onion,       
##       Milk,        
##       Flour,       
##       Egg,         
##       Olive,       
##       Shampoo}     
## [5]  {Honey}       
## [6]  {Honey,       
##       Toothpaste,  
##       Hazelnut,    
##       Onion,       
##       ShavingFoam, 
##       Sugar}       
## [7]  {Bacon,       
##       Banana,      
##       Apple,       
##       Carrot,      
##       Salt,        
##       HeavyCream}  
## [8]  {Bacon,       
##       Toothpaste,  
##       Banana,      
##       Hazelnut,    
##       Cucumber,    
##       Onion,       
##       Salt,        
##       Egg}         
## [9]  {Honey,       
##       Bacon,       
##       Banana,      
##       Apple,       
##       Hazelnut,    
##       Cheese,      
##       Meat,        
##       Carrot,      
##       Onion,       
##       Butter,      
##       ShavingFoam, 
##       HeavyCream,  
##       Egg,         
##       Olive}       
## [10] {Onion,       
##       Milk,        
##       Salt,        
##       Flour,       
##       HeavyCream,  
##       Shampoo}     
## [11] {Bacon,       
##       Toothpaste,  
##       Apple,       
##       Hazelnut,    
##       Carrot,      
##       Butter,      
##       Flour,       
##       HeavyCream,  
##       Egg,         
##       Olive}       
## [12] {Honey,       
##       Bacon,       
##       Toothpaste,  
##       Meat,        
##       Onion,       
##       Butter,      
##       Flour,       
##       HeavyCream,  
##       Sugar}       
## [13] {Bread,       
##       Honey,       
##       Bacon,       
##       Toothpaste,  
##       Banana,      
##       Apple,       
##       Meat,        
##       Carrot,      
##       Onion,       
##       Milk,        
##       ShavingFoam, 
##       Egg,         
##       Olive,       
##       Shampoo,     
##       Sugar}       
## [14] {Bread,       
##       Bacon,       
##       Toothpaste,  
##       Banana,      
##       Hazelnut,    
##       Cheese,      
##       Carrot,      
##       ShavingFoam, 
##       Salt,        
##       HeavyCream,  
##       Egg,         
##       Olive,       
##       Sugar}       
## [15] {Toothpaste,  
##       Banana,      
##       Carrot,      
##       Cucumber,    
##       ShavingFoam, 
##       Flour,       
##       Egg,         
##       Olive,       
##       Shampoo,     
##       Sugar}       
## [16] {Bacon,       
##       Milk,        
##       Flour,       
##       Shampoo}     
## [17] {Toothpaste,  
##       Cucumber,    
##       Flour}       
## [18] {Onion,       
##       ShavingFoam, 
##       Salt,        
##       Olive}       
## [19] {Bread,       
##       Honey,       
##       Bacon,       
##       Toothpaste,  
##       Hazelnut,    
##       Cheese,      
##       Meat,        
##       Carrot,      
##       Onion,       
##       Butter,      
##       ShavingFoam, 
##       Salt,        
##       Sugar}       
## [20] {Bread,       
##       Bacon,       
##       Toothpaste,  
##       Banana,      
##       Hazelnut,    
##       Cheese,      
##       Carrot,      
##       Onion,       
##       Butter,      
##       ShavingFoam, 
##       Salt,        
##       Flour,       
##       Olive,       
##       Sugar}       
## [21] {Cheese,      
##       ShavingFoam, 
##       Shampoo,     
##       Sugar}       
## [22] {Banana,      
##       Cheese,      
##       Meat,        
##       Carrot,      
##       Onion,       
##       Salt,        
##       HeavyCream,  
##       Egg,         
##       Olive}       
## [23] {Bread,       
##       Honey,       
##       Bacon,       
##       Toothpaste,  
##       Cheese,      
##       Carrot,      
##       Onion,       
##       Butter,      
##       ShavingFoam, 
##       Egg}         
## [24] {Honey,       
##       Toothpaste,  
##       Meat,        
##       Carrot,      
##       Onion,       
##       HeavyCream,  
##       Egg,         
##       Shampoo}     
## [25] {Honey,       
##       Toothpaste,  
##       Banana,      
##       Hazelnut,    
##       Cheese,      
##       HeavyCream,  
##       Olive}       
## [26] {Honey,       
##       Bacon,       
##       Apple,       
##       Hazelnut,    
##       Cheese,      
##       Meat,        
##       Onion,       
##       Butter,      
##       ShavingFoam, 
##       Salt,        
##       Shampoo,     
##       Sugar}       
## [27] {Honey,       
##       Hazelnut,    
##       Cheese,      
##       Milk,        
##       Shampoo}     
## [28] {Bread,       
##       Bacon,       
##       Toothpaste,  
##       Apple,       
##       Carrot,      
##       Butter,      
##       ShavingFoam, 
##       Shampoo,     
##       Sugar}       
## [29] {Bread,       
##       Honey,       
##       Bacon,       
##       Cheese,      
##       Meat,        
##       Cucumber,    
##       Onion,       
##       Milk,        
##       ShavingFoam, 
##       Salt,        
##       HeavyCream,  
##       Sugar}       
## [30] {Bread,       
##       Honey,       
##       Apple,       
##       Meat,        
##       Carrot,      
##       Salt,        
##       HeavyCream,  
##       Egg,         
##       Shampoo}     
## [31] {Bacon,       
##       Toothpaste,  
##       Apple,       
##       Hazelnut,    
##       Meat,        
##       Cucumber,    
##       Onion,       
##       Butter,      
##       ShavingFoam, 
##       Flour,       
##       Egg,         
##       Olive,       
##       Sugar}       
## [32] {Honey,       
##       Toothpaste,  
##       Banana,      
##       Apple,       
##       Hazelnut,    
##       Cheese,      
##       Meat,        
##       Carrot,      
##       Cucumber,    
##       Onion,       
##       Milk,        
##       Flour,       
##       Egg,         
##       Olive}       
## [33] {Bread,       
##       Honey,       
##       Toothpaste,  
##       Banana,      
##       Apple,       
##       Hazelnut,    
##       Milk,        
##       Butter,      
##       Salt,        
##       Flour,       
##       HeavyCream,  
##       Shampoo}     
## [34] {Bread,       
##       Bacon,       
##       Banana,      
##       Apple,       
##       Hazelnut,    
##       Cheese,      
##       Carrot,      
##       Cucumber,    
##       Onion,       
##       Milk,        
##       Salt,        
##       HeavyCream,  
##       Egg,         
##       Olive}       
## [35] {Bread,       
##       Bacon,       
##       Toothpaste,  
##       Banana,      
##       Hazelnut,    
##       Meat,        
##       Cucumber,    
##       Salt,        
##       Sugar}       
## [36] {Bread,       
##       Bacon,       
##       Apple,       
##       Hazelnut,    
##       Meat,        
##       Milk,        
##       Salt,        
##       Flour,       
##       HeavyCream,  
##       Olive,       
##       Shampoo,     
##       Sugar}       
## [37] {Bread,       
##       Toothpaste,  
##       Cheese,      
##       Milk,        
##       Salt,        
##       Flour,       
##       Egg}         
## [38] {Bacon,       
##       Olive}       
## [39] {Bread,       
##       Bacon,       
##       Toothpaste,  
##       Banana,      
##       Hazelnut,    
##       Carrot,      
##       Butter,      
##       ShavingFoam, 
##       Olive}       
## [40] {Banana,      
##       Apple,       
##       Hazelnut,    
##       Cheese,      
##       Meat,        
##       Cucumber,    
##       Salt,        
##       Sugar}       
## [41] {Cucumber,    
##       Salt,        
##       HeavyCream,  
##       Sugar}       
## [42] {Apple,       
##       Milk,        
##       HeavyCream,  
##       Olive}       
## [43] {Bread,       
##       Cheese,      
##       Onion,       
##       Flour,       
##       Olive}       
## [44] {Bread,       
##       Bacon,       
##       Banana,      
##       Cheese,      
##       Carrot,      
##       Cucumber,    
##       Onion,       
##       Milk,        
##       Butter,      
##       Salt,        
##       Egg,         
##       Olive}       
## [45] {Honey,       
##       Toothpaste,  
##       Banana,      
##       Apple,       
##       Meat,        
##       Carrot,      
##       Milk,        
##       Salt,        
##       Flour,       
##       Olive}       
## [46] {Bread,       
##       Honey,       
##       Hazelnut,    
##       Cheese,      
##       Meat,        
##       Carrot,      
##       Butter,      
##       ShavingFoam, 
##       Olive}       
## [47] {Bacon}       
## [48] {Bacon,       
##       Toothpaste,  
##       Banana,      
##       Apple,       
##       Hazelnut,    
##       Meat,        
##       Carrot,      
##       Salt,        
##       Flour,       
##       HeavyCream,  
##       Olive,       
##       Sugar}       
## [49] {Bacon,       
##       Toothpaste,  
##       Banana,      
##       Cheese,      
##       Meat,        
##       Carrot,      
##       Cucumber,    
##       Onion,       
##       Butter,      
##       Flour,       
##       Egg,         
##       Shampoo}     
## [50] {Bread,       
##       Honey,       
##       Toothpaste,  
##       Hazelnut,    
##       Meat,        
##       Onion,       
##       Milk,        
##       Butter,      
##       Flour,       
##       Olive,       
##       Shampoo}

Item frequency

itemFrequency(market, type = "absolute")
##       Bread       Honey       Bacon  Toothpaste      Banana       Apple 
##        5296        5127        5196        5072        5167        5092 
##    Hazelnut      Cheese        Meat      Carrot    Cucumber       Onion 
##        5133        5158        5172        5109        5189        5198 
##        Milk      Butter ShavingFoam        Salt       Flour  HeavyCream 
##        5185        5208        5193        5204        5206        5194 
##         Egg       Olive     Shampoo       Sugar 
##        5202        5235        5154        5160
itemFrequency(market, type ="relative")
##       Bread       Honey       Bacon  Toothpaste      Banana       Apple 
##   0.5061162   0.4899656   0.4965596   0.4847095   0.4937882   0.4866208 
##    Hazelnut      Cheese        Meat      Carrot    Cucumber       Onion 
##   0.4905390   0.4929281   0.4942661   0.4882454   0.4958907   0.4967508 
##        Milk      Butter ShavingFoam        Salt       Flour  HeavyCream 
##   0.4955084   0.4977064   0.4962729   0.4973242   0.4975153   0.4963685 
##         Egg       Olive     Shampoo       Sugar 
##   0.4971330   0.5002867   0.4925459   0.4931193
itemFrequencyPlot(market, topN = 10, ylab = "Item frequency [relative]", type = "relative", col = "darkseagreen3") 

There is similar frequency for all of this ten transactions, probably it is caused by the fact, that the most frequent basket is for 11 products (it is half of all factors from datasets).

Visualising transactions

image(sample(market, 100))

image(sample(market, 150))

It is difficult to identify strong item relationships visually because of the large baskets, so we will search for the relations by applying association rule mining using the Apriori algorithm.

Apriori algorithm

The Apriori algorithm is used to discover relationships between products in shopping baskets. It uses the following key metrics: - Support: The frequency of an itemset appearing in transactions. - Confidence: The probability of purchasing an item given another item is purchased. - Lift: The strength of an association compared to a random occurrence.

We set the parameters as follows: - Support = 0.2 (The itemset appears in at least 20% of transactions). - Confidence = 0.5 (The association holds at least 50% of the time). - Minlen = 2 (Rules must contain at least 2 items).

I have decided to choose these high support and confidence values because our dataset has large baskets compared to the number of factors. When I used lower values, thousands of rules were generated, making interpretation more difficult.

market_rules <- apriori(market, parameter = list(support = 0.2, confidence = 0.5, minlen = 2))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.5    0.1    1 none FALSE            TRUE       5     0.2      2
##  maxlen target  ext
##      10  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 2092 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[22 item(s), 10464 transaction(s)] done [0.01s].
## sorting and recoding items ... [22 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 done [0.01s].
## writing ... [168 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
market_rules
## set of 168 rules

We have 168 rules determined by algorithm.

Top 10 strongest rules

  • Lift shows the strongest product relationships.
  • Support highlights the most frequent product combinations.
  • Confidence shows the probability of an item being bought when another is purchased.
inspect(sort(market_rules, by = "lift")[1:10])
##      lhs              rhs           support   confidence coverage  lift    
## [1]  {Cucumber}    => {Onion}       0.2546827 0.5135864  0.4958907 1.033892
## [2]  {Onion}       => {Cucumber}    0.2546827 0.5126972  0.4967508 1.033892
## [3]  {Bread}       => {Salt}        0.2594610 0.5126511  0.5061162 1.030819
## [4]  {Salt}        => {Bread}       0.2594610 0.5217141  0.4973242 1.030819
## [5]  {Sugar}       => {Meat}        0.2511468 0.5093023  0.4931193 1.030421
## [6]  {Meat}        => {Sugar}       0.2511468 0.5081206  0.4942661 1.030421
## [7]  {Apple}       => {Meat}        0.2467508 0.5070699  0.4866208 1.025905
## [8]  {ShavingFoam} => {HeavyCream}  0.2524847 0.5087618  0.4962729 1.024968
## [9]  {HeavyCream}  => {ShavingFoam} 0.2524847 0.5086638  0.4963685 1.024968
## [10] {Apple}       => {Banana}      0.2461774 0.5058916  0.4866208 1.024511
##      count
## [1]  2665 
## [2]  2665 
## [3]  2715 
## [4]  2715 
## [5]  2628 
## [6]  2628 
## [7]  2582 
## [8]  2642 
## [9]  2642 
## [10] 2576
inspect(sort(market_rules, by = "support")[1:10])
##      lhs             rhs          support   confidence coverage  lift     count
## [1]  {Salt}       => {Bread}      0.2594610 0.5217141  0.4973242 1.030819 2715 
## [2]  {Bread}      => {Salt}       0.2594610 0.5126511  0.5061162 1.030819 2715 
## [3]  {HeavyCream} => {Bread}      0.2553517 0.5144397  0.4963685 1.016446 2672 
## [4]  {Bread}      => {HeavyCream} 0.2553517 0.5045317  0.5061162 1.016446 2672 
## [5]  {Egg}        => {Bread}      0.2550650 0.5130719  0.4971330 1.013743 2669 
## [6]  {Bread}      => {Egg}        0.2550650 0.5039653  0.5061162 1.013743 2669 
## [7]  {Cucumber}   => {Onion}      0.2546827 0.5135864  0.4958907 1.033892 2665 
## [8]  {Onion}      => {Cucumber}   0.2546827 0.5126972  0.4967508 1.033892 2665 
## [9]  {Olive}      => {Bread}      0.2545872 0.5088825  0.5002867 1.005466 2664 
## [10] {Bread}      => {Olive}      0.2545872 0.5030211  0.5061162 1.005466 2664

Following the table, bread and salt are the most popular products in the market and are most often bought together.

inspect(sort(market_rules, by = "confidence")[1:10])
##      lhs             rhs        support   confidence coverage  lift     count
## [1]  {Salt}       => {Bread}    0.2594610 0.5217141  0.4973242 1.030819 2715 
## [2]  {HeavyCream} => {Bread}    0.2553517 0.5144397  0.4963685 1.016446 2672 
## [3]  {Carrot}     => {Bread}    0.2511468 0.5143864  0.4882454 1.016340 2628 
## [4]  {Cucumber}   => {Onion}    0.2546827 0.5135864  0.4958907 1.033892 2665 
## [5]  {Egg}        => {Bread}    0.2550650 0.5130719  0.4971330 1.013743 2669 
## [6]  {Onion}      => {Cucumber} 0.2546827 0.5126972  0.4967508 1.033892 2665 
## [7]  {Bread}      => {Salt}     0.2594610 0.5126511  0.5061162 1.030819 2715 
## [8]  {Toothpaste} => {Olive}    0.2483754 0.5124211  0.4847095 1.024255 2599 
## [9]  {Bacon}      => {Bread}    0.2541093 0.5117398  0.4965596 1.011111 2659 
## [10] {Hazelnut}   => {Bread}    0.2508601 0.5113968  0.4905390 1.010434 2625

Following the table, bread is most likely to be bought with salt, heavy cream or carrot (with probability 52.17%, 51.44%, 51.43 %).

Visualisation of association rules

## Warning: pakiet 'arulesViz' został zbudowany w wersji R 4.4.2
plot(market_rules, colors = c("tomato1", "darkseagreen4"))

plot(market_rules, method = "grouped", control=list(col = c("tomato1", "darkseagreen4")))

plot(market_rules, method = "graph", colors = c("tomato1", "darkseagreen4"))

Following the plot, larger nodes indicate higher support, and colour intensity indicate the strength of association - lift.

Bread and salt with sugar and cucumber, shows strong relation, suggesting key shopping patterns for sellers.

plot(market_rules, method = "paracoord", control = list(reorder = TRUE))

Analysis of rules for bread

Since the bread is the most frequently purchased product it is worth to look closely into its analysis.

rules_bread <- apriori(data = market, parameter = list(supp = 0.01,conf = 0.005), 
                       appearance =list(default ="lhs", rhs = "Bread"), control = list(verbose = F)) 
plot(rules_bread, method = "graph", colors = c("tomato1", "darkseagreen4"))

inspect(sort(rules_bread, by = "lift")[1:10])
##      lhs               rhs        support confidence   coverage     lift count
## [1]  {Bacon,                                                                  
##       Hazelnut,                                                               
##       Carrot,                                                                 
##       Cucumber,                                                               
##       Milk,                                                                   
##       Salt}         => {Bread} 0.01032110  0.6625767 0.01557722 1.309139   108
## [2]  {Honey,                                                                  
##       Hazelnut,                                                               
##       Onion,                                                                  
##       HeavyCream,                                                             
##       Egg,                                                                    
##       Shampoo}      => {Bread} 0.01118119  0.6536313 0.01710627 1.291465   117
## [3]  {Honey,                                                                  
##       Bacon,                                                                  
##       Hazelnut,                                                               
##       Carrot,                                                                 
##       Milk,                                                                   
##       Salt}         => {Bread} 0.01012997  0.6463415 0.01567278 1.277061   106
## [4]  {Bacon,                                                                  
##       Hazelnut,                                                               
##       Carrot,                                                                 
##       Cucumber,                                                               
##       Salt,                                                                   
##       Shampoo}      => {Bread} 0.01012997  0.6424242 0.01576835 1.269322   106
## [5]  {Banana,                                                                 
##       Apple,                                                                  
##       Milk,                                                                   
##       ShavingFoam,                                                            
##       Salt,                                                                   
##       Flour}        => {Bread} 0.01051223  0.6395349 0.01643731 1.263613   110
## [6]  {Honey,                                                                  
##       Hazelnut,                                                               
##       Onion,                                                                  
##       Salt,                                                                   
##       HeavyCream,                                                             
##       Shampoo}      => {Bread} 0.01089450  0.6333333 0.01720183 1.251360   114
## [7]  {Bacon,                                                                  
##       Apple,                                                                  
##       Hazelnut,                                                               
##       Carrot,                                                                 
##       Cucumber,                                                               
##       Salt}         => {Bread} 0.01032110  0.6279070 0.01643731 1.240638   108
## [8]  {Hazelnut,                                                               
##       Onion,                                                                  
##       Milk,                                                                   
##       Salt,                                                                   
##       HeavyCream,                                                             
##       Egg}          => {Bread} 0.01012997  0.6272189 0.01615061 1.239278   106
## [9]  {Honey,                                                                  
##       Banana,                                                                 
##       Hazelnut,                                                               
##       Cheese,                                                                 
##       Cucumber,                                                               
##       HeavyCream}   => {Bread} 0.01041667  0.6228571 0.01672401 1.230660   109
## [10] {Honey,                                                                  
##       Hazelnut,                                                               
##       Cucumber,                                                               
##       Onion,                                                                  
##       HeavyCream,                                                             
##       Shampoo}      => {Bread} 0.01041667  0.6228571 0.01672401 1.230660   109
inspect(sort(rules_bread, by = "support")[1:10])
##      lhs              rhs     support   confidence coverage  lift     count
## [1]  {}            => {Bread} 0.5061162 0.5061162  1.0000000 1.000000 5296 
## [2]  {Salt}        => {Bread} 0.2594610 0.5217141  0.4973242 1.030819 2715 
## [3]  {HeavyCream}  => {Bread} 0.2553517 0.5144397  0.4963685 1.016446 2672 
## [4]  {Egg}         => {Bread} 0.2550650 0.5130719  0.4971330 1.013743 2669 
## [5]  {Olive}       => {Bread} 0.2545872 0.5088825  0.5002867 1.005466 2664 
## [6]  {Bacon}       => {Bread} 0.2541093 0.5117398  0.4965596 1.011111 2659 
## [7]  {Butter}      => {Bread} 0.2532492 0.5088326  0.4977064 1.005367 2650 
## [8]  {Onion}       => {Bread} 0.2526758 0.5086572  0.4967508 1.005021 2644 
## [9]  {Milk}        => {Bread} 0.2521024 0.5087753  0.4955084 1.005254 2638 
## [10] {ShavingFoam} => {Bread} 0.2517202 0.5072213  0.4962729 1.002183 2634
inspect(sort(rules_bread, by = "confidence")[1:10])
##      lhs               rhs        support confidence   coverage     lift count
## [1]  {Bacon,                                                                  
##       Hazelnut,                                                               
##       Carrot,                                                                 
##       Cucumber,                                                               
##       Milk,                                                                   
##       Salt}         => {Bread} 0.01032110  0.6625767 0.01557722 1.309139   108
## [2]  {Honey,                                                                  
##       Hazelnut,                                                               
##       Onion,                                                                  
##       HeavyCream,                                                             
##       Egg,                                                                    
##       Shampoo}      => {Bread} 0.01118119  0.6536313 0.01710627 1.291465   117
## [3]  {Honey,                                                                  
##       Bacon,                                                                  
##       Hazelnut,                                                               
##       Carrot,                                                                 
##       Milk,                                                                   
##       Salt}         => {Bread} 0.01012997  0.6463415 0.01567278 1.277061   106
## [4]  {Bacon,                                                                  
##       Hazelnut,                                                               
##       Carrot,                                                                 
##       Cucumber,                                                               
##       Salt,                                                                   
##       Shampoo}      => {Bread} 0.01012997  0.6424242 0.01576835 1.269322   106
## [5]  {Banana,                                                                 
##       Apple,                                                                  
##       Milk,                                                                   
##       ShavingFoam,                                                            
##       Salt,                                                                   
##       Flour}        => {Bread} 0.01051223  0.6395349 0.01643731 1.263613   110
## [6]  {Honey,                                                                  
##       Hazelnut,                                                               
##       Onion,                                                                  
##       Salt,                                                                   
##       HeavyCream,                                                             
##       Shampoo}      => {Bread} 0.01089450  0.6333333 0.01720183 1.251360   114
## [7]  {Bacon,                                                                  
##       Apple,                                                                  
##       Hazelnut,                                                               
##       Carrot,                                                                 
##       Cucumber,                                                               
##       Salt}         => {Bread} 0.01032110  0.6279070 0.01643731 1.240638   108
## [8]  {Hazelnut,                                                               
##       Onion,                                                                  
##       Milk,                                                                   
##       Salt,                                                                   
##       HeavyCream,                                                             
##       Egg}          => {Bread} 0.01012997  0.6272189 0.01615061 1.239278   106
## [9]  {Honey,                                                                  
##       Banana,                                                                 
##       Hazelnut,                                                               
##       Cheese,                                                                 
##       Cucumber,                                                               
##       HeavyCream}   => {Bread} 0.01041667  0.6228571 0.01672401 1.230660   109
## [10] {Honey,                                                                  
##       Hazelnut,                                                               
##       Cucumber,                                                               
##       Onion,                                                                  
##       HeavyCream,                                                             
##       Shampoo}      => {Bread} 0.01041667  0.6228571 0.01672401 1.230660   109

Looking at the above tables there is clearly strong relation between bread and others products.

Conclusions

Bread is the most frequently purchased item, confirming its role as a staple in most households. The analysis also reveals that most baskets contain 11 products, indicating a common shopping pattern among customers. Through the Apriori algorithm, strong associations between various items have been uncovered, which can be used for effective cross-selling strategies. Additionally, the strongest rules suggest that bundling specific products together could enhance marketing strategies and increase sales.

To gain deeper insights, future research could explore different support and confidence thresholds to refine the association rules further. Analysing seasonal trends in product purchases may also reveal fluctuations in buying behavior throughout the year. Lastly, comparing this dataset with other retail datasets could provide a broader understanding of consumer purchasing habits across different markets.