Market Basket Analysis

This report seeks to address the request by management to use data as a platform for decision makin on the acquisition of Electronidex. The specific objectives given to the data team was to

  1. use data to help them better understand the clientele that Electronidex currently is serving

  2. if the acquisition would be an optimal partnership

Specifically, the management would like us to identify purchasing patterns that will provide insight into Electronidex’s clientele.

To carry out this task we plan to conduct a Market Basket Analysis. This analysis shows any interesting relationships (or associations) between customer’s transactions and the item(s) they’ve purchased.

These associations can then be used to drive sales-oriented initiatives such as recommender systems like the ones used by Amazon and other eCommerce sites. We were provided with (30 days’ worth) of Electronidexes online transactions.

Key Questions we condisered:

• Are there any interesting patterns or item relationships within Electronidex’s transactions? • Would Blackwell benefit from selling any of Electronidex’s items? • In your opinion, should Blackwell acquire Electronidex? • If Blackwell does acquire Electronidex, do you have any recommendations for Blackwell? (Ex: cross-selling items, sale promotions, should they remove items, etc.)

Steps taken in the Market Basket Analysis

#Install and load the packages u will use to do the analysis #Note: always put the install.packages inside the console.

library(arules)
## Loading required package: Matrix
## 
## Attaching package: 'arules'
## The following objects are masked from 'package:base':
## 
##     abbreviate, write
library(arulesViz)
## Loading required package: grid
## Registered S3 method overwritten by 'seriation':
##   method         from 
##   reorder.hclust gclus

#Upload the dataset - when uploading the dataset, #Note: always assign datasets u r loading to a specific file

transaction_file <- read.transactions(
  "C:/Users/gebruiker/Desktop/ElectronidexTransactions2017.csv", 
  sep = ",")
## Warning in readLines(file, encoding = encoding): incomplete final line
## found on 'C:/Users/gebruiker/Desktop/ElectronidexTransactions2017.csv'
## Warning in asMethod(object): removing duplicated items in transactions

#summary tell u how many transactions and what they are

summary(transaction_file)
## transactions as itemMatrix in sparse format with
##  9835 rows (elements/itemsets/transactions) and
##  125 columns (items) and a density of 0.03506172 
## 
## most frequent items:
##                     iMac                HP Laptop CYBERPOWER Gamer Desktop 
##                     2519                     1909                     1809 
##            Apple Earpods        Apple MacBook Air                  (Other) 
##                     1715                     1530                    33622 
## 
## element (itemset/transaction) length distribution:
## sizes
##    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14 
##    2 2163 1647 1294 1021  856  646  540  439  353  247  171  119   77   72 
##   15   16   17   18   19   20   21   22   23   25   26   27   29   30 
##   56   41   26   20   10   10   10    5    3    1    1    3    1    1 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   2.000   3.000   4.383   6.000  30.000 
## 
## includes extended item information - examples:
##                             labels
## 1 1TB Portable External Hard Drive
## 2 2TB Portable External Hard Drive
## 3                   3-Button Mouse

#from the summary we see the density. This is the percentage of occupied cells in the matrix. this is equal to the total number of items purchased divided by total number of possible of possible items in the matrix

to calculate total number of items purchased =

#transactionitemsdensity

9835*125*0.03506172
## [1] 43104

#from the summary we can see the most frquent items sold are the imac, HP laptop, cyberpower gamer laptop, apple earpods, Apple macbook air,

#next in the summary is the item transaction nexus where we see - 2163 transactions for 1 item, 1647 transactions for 2 items and the biggest transaction being 30 items in 1 transaction

#the item freq plot should align with the summary findings on top sales itemFrequencyPlot(transaction_file, topN = 20)

#get to know the data (data exploration) - view the transaction data (did not run this because it is too large)

inspect(transaction_file)

#identify the number of transactions

length(transaction_file)
## [1] 9835

#number of items per transaction (did not run this because it is too long)

size(transaction_file)

#list the transactions ( removed from code because of the length)

LIST(transaction_file)

#to see item labels

itemLabels(transaction_file)
##   [1] "1TB Portable External Hard Drive"                     
##   [2] "2TB Portable External Hard Drive"                     
##   [3] "3-Button Mouse"                                       
##   [4] "3TB Portable External Hard Drive"                     
##   [5] "5TB Desktop Hard Drive"                               
##   [6] "Acer Aspire"                                          
##   [7] "Acer Desktop"                                         
##   [8] "Acer Monitor"                                         
##   [9] "Ailihen Stereo Headphones"                            
##  [10] "Alienware Laptop"                                     
##  [11] "AOC Monitor"                                          
##  [12] "APIE Bluetooth Headphone"                             
##  [13] "Apple Earpods"                                        
##  [14] "Apple MacBook Air"                                    
##  [15] "Apple MacBook Pro"                                    
##  [16] "Apple Magic Keyboard"                                 
##  [17] "Apple TV"                                             
##  [18] "Apple Wired Keyboard"                                 
##  [19] "Apple Wireless Keyboard"                              
##  [20] "ASUS 2 Monitor"                                       
##  [21] "ASUS Chromebook"                                      
##  [22] "ASUS Desktop"                                         
##  [23] "ASUS Monitor"                                         
##  [24] "Audio Cable"                                          
##  [25] "Backlit LED Gaming Keyboard"                          
##  [26] "Belkin Mouse Pad"                                     
##  [27] "Bose Companion Speakers"                              
##  [28] "Brother Printer"                                      
##  [29] "Brother Printer Toner"                                
##  [30] "Cambridge Bluetooth Speaker"                          
##  [31] "Canon Ink"                                            
##  [32] "Canon Office Printer"                                 
##  [33] "Computer Game"                                        
##  [34] "Cyber Acoustics"                                      
##  [35] "CYBERPOWER Gamer Desktop"                             
##  [36] "Dell 2 Desktop"                                       
##  [37] "Dell Desktop"                                         
##  [38] "Dell KM117 Wireless Keyboard & Mouse"                 
##  [39] "Dell Laptop"                                          
##  [40] "Dell Monitor"                                         
##  [41] "Dell Wired Keyboard"                                  
##  [42] "DOSS Touch Wireless Bluetooth"                        
##  [43] "DYMO Label Manker"                                    
##  [44] "DYMO Labeling Tape"                                   
##  [45] "EagleTec Wireless Combo Keyboard and Mouse"           
##  [46] "Eluktronics Pro Gaming Laptop"                        
##  [47] "Epson Black Ink"                                      
##  [48] "Epson Printer"                                        
##  [49] "Etekcity Power Extension Cord Cable"                  
##  [50] "Ethernet Cable"                                       
##  [51] "Fire HD Tablet"                                       
##  [52] "Fire TV Stick"                                        
##  [53] "Full Motion Monitor Mount"                            
##  [54] "Gaming Mouse Professional"                            
##  [55] "Generic Black 3-Button"                               
##  [56] "Google Home"                                          
##  [57] "Halter Acrylic Monitor Stand"                         
##  [58] "Halter Mesh Metal Monitor Stand"                      
##  [59] "HDMI Adapter"                                         
##  [60] "HDMI Cable 6ft"                                       
##  [61] "Height-Adjustable Standing Desk"                      
##  [62] "HP Black & Tri-color Ink"                             
##  [63] "HP Desktop"                                           
##  [64] "HP Laptop"                                            
##  [65] "HP Monitor"                                           
##  [66] "HP Notebook Touchscreen Laptop PC"                    
##  [67] "HP USB Keyboard"                                      
##  [68] "HP Wireless Mouse"                                    
##  [69] "HP Wireless Printer"                                  
##  [70] "iMac"                                                 
##  [71] "Intel Desktop"                                        
##  [72] "iPad"                                                 
##  [73] "iPad Pro"                                             
##  [74] "iPhone Charger Cable"                                 
##  [75] "JBL Splashproof Portable Bluetooth Speaker"           
##  [76] "Kensington Headphones"                                
##  [77] "Kindle"                                               
##  [78] "Koss Home Headphones"                                 
##  [79] "Large Mouse Pad"                                      
##  [80] "Lenovo Desktop Computer"                              
##  [81] "LG Monitor"                                           
##  [82] "LG Touchscreen Laptop"                                
##  [83] "Logitech 3-button Mouse"                              
##  [84] "Logitech ClearChat Headset"                           
##  [85] "Logitech Desktop MK120 Mouse and keyboard Combo"      
##  [86] "Logitech Keyboard"                                    
##  [87] "Logitech MK270 Wireless Keyboard and Mouse Combo"     
##  [88] "Logitech MK360 Wireless Keyboard and Mouse Combo"     
##  [89] "Logitech MK550 Wireless Wave Keyboard and Mouse Combo"
##  [90] "Logitech Multimedia Speakers"                         
##  [91] "Logitech Stereo Headset"                              
##  [92] "Logitech Wireless Keyboard"                           
##  [93] "Logitech Wireless Mouse"                              
##  [94] "Mackie CR Speakers"                                   
##  [95] "Microsoft Basic Optical Mouse"                        
##  [96] "Microsoft Headset"                                    
##  [97] "Microsoft Office Home and Student 2016"               
##  [98] "Microsoft Wireless Comfort Keyboard and Mouse"        
##  [99] "Microsoft Wireless Desktop Keyboard and Mouse"        
## [100] "Monster Beats By Dr Dre"                              
## [101] "Multi Media Stand"                                    
## [102] "Otium Wireless Sports Bluetooth Headphone"            
## [103] "Panasonic In-Ear Headphone"                           
## [104] "Panasonic On-Ear Stereo Headphones"                   
## [105] "PC Gaming Headset"                                    
## [106] "Philips Flexible Earhook Headphone"                   
## [107] "Redragon Gaming Mouse"                                
## [108] "Rii LED Gaming Keyboard & Mouse Combo"                
## [109] "Rii LED Keyboard"                                     
## [110] "Rokono Mini Speaker"                                  
## [111] "Roku Express"                                         
## [112] "Samsung Charging Cable"                               
## [113] "Samsung Galaxy Tablet"                                
## [114] "Samsung Monitor"                                      
## [115] "Sceptre Monitor"                                      
## [116] "Slim 2TB Portable External Hard Drive"                
## [117] "Slim Wireless Mouse"                                  
## [118] "Smart Light Bulb"                                     
## [119] "Sonos"                                                
## [120] "USB Cable"                                            
## [121] "VGA Monitor Cable"                                    
## [122] "ViewSonic Monitor"                                    
## [123] "Wireless Portable Mouse"                              
## [124] "XIBERIA Gaming Headset"                               
## [125] "Zombie Gaming Headset"

#to get the top 10 items - # to visualize the item frequencies (top 10) use the function below. If u want to see all just remove the step above and remove the top 10

itemFrequencyPlot(transaction_file, topN = 20)

to visualize all the transactions in the dataset use

image(transaction_file, topN = 20)

#to visualize your transactions is to use the sample() function with the image () function. The sample() function will create a sample that contains a random set of transactions. Below is the code and after that the implementation for this task #image(sample(DatasetName, # of Transactions you’d like to plot))

image(sample(transaction_file, 500))

#The Apriori algorithm is helpful when working with large datasets and is used to uncover insights pertaining to transactional datasets. It is based on item frequency.

#We use the Apriori algorithm in Arules library to mine frequent itemsets and association rules. The algorithm employs level-wise search for frequent itemsets - see above

#Apriori algorithm assesses association rules using two types of measurements namely; #a) Support measurement, which measures itemsets or rules frequency within your dataset.

#b)Confidence measurement, which measures the accuracy of the rules.

#Please note: When analyzing the Confidence measurement, keep in mind that correlation does not imply causation. For example: {Item 1} -> {Item 2} is NOT the same as {Item 2} -> {Item 1}.

How to read the result: A rule that measures high in both support and confidence is known as a strong rule

#How does the Apriori function work? - #it will perform two steps before creating its association rules.

#The first step is analyzing all itemsets that meet the support measurement requirement, which occurs in multiple phases.

#Each phase involves analyzing a different number of total items in an itemset.

#the second step analyzes all of the itemsets to determine which meet the confidence measurement requirement.

#itemsets/rules that do not meet this requirement are removed.

#the apriori function can be seen below - apriori function is used to create the rules - note that supp must be = 0.1% = 0.001 and conf = 0.8 or 80%

#run the apriori function on the transaction file

transaction_file_apriori<- apriori (transaction_file, parameter = list(supp = 0.001, conf = 0.8))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.8    0.1    1 none FALSE            TRUE       5   0.001      1
##  maxlen target   ext
##      10  rules FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 9 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[125 item(s), 9835 transaction(s)] done [0.00s].
## sorting and recoding items ... [125 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 5 6 done [0.01s].
## writing ... [635 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].

#we can sort the outcome of the rule (apiriori function) by decreasing confidence

transaction_file_apriori <- sort(transaction_file_apriori, by = "confidence", decreasing = TRUE)

#then u can use summary() to see the outcome

summary(transaction_file_apriori)
## set of 635 rules
## 
## rule length distribution (lhs + rhs):sizes
##   3   4   5   6 
##  30 303 269  33 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    3.00    4.00    4.00    4.48    5.00    6.00 
## 
## summary of quality measures:
##     support           confidence          lift            count      
##  Min.   :0.001017   Min.   :0.8000   Min.   : 3.123   Min.   :10.00  
##  1st Qu.:0.001017   1st Qu.:0.8333   1st Qu.: 3.304   1st Qu.:10.00  
##  Median :0.001118   Median :0.8462   Median : 3.579   Median :11.00  
##  Mean   :0.001268   Mean   :0.8661   Mean   : 4.042   Mean   :12.47  
##  3rd Qu.:0.001322   3rd Qu.:0.9091   3rd Qu.: 4.416   3rd Qu.:13.00  
##  Max.   :0.005287   Max.   :1.0000   Max.   :10.069   Max.   :52.00  
## 
## mining info:
##              data ntransactions support confidence
##  transaction_file          9835   0.001        0.8

Finding:

#there are 635 rules #4 items have the most rules :303

#These parameters are requesting that the rules cover 10% of the transactions and are 80% correct.

#to view the rules you use the inspect function (did not run this because it is too large)

inspect(transaction_file_apriori)

#important facts to note: #if the values are too high, then u will recieve no rules or non-helpful rules

#If the values are too low, your computational time/memory will suffer, or you’ll receive too many rules

#To get ‘strong’ rules, increase the value of ‘conf’ parameter.

#Evaluating your model # U use the summary function to view an overview of the rules metric

#please note: 1) If the support and confidence are near the thresholds that you chose, you might have to adjust your values.

#2)Lift measures the importance of a rule. A high value for lift strongly indicates that the rule is important. Unlike the Confidence measurement, {Item 1} -> {Item 2} is the same as {Item 2} -> {Item 1} in the context of the lift measurement.

#the code below gives an overview of the rules metric using the summary function

summary(transaction_file_apriori)
## set of 635 rules
## 
## rule length distribution (lhs + rhs):sizes
##   3   4   5   6 
##  30 303 269  33 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    3.00    4.00    4.00    4.48    5.00    6.00 
## 
## summary of quality measures:
##     support           confidence          lift            count      
##  Min.   :0.001017   Min.   :0.8000   Min.   : 3.123   Min.   :10.00  
##  1st Qu.:0.001017   1st Qu.:0.8333   1st Qu.: 3.304   1st Qu.:10.00  
##  Median :0.001118   Median :0.8462   Median : 3.579   Median :11.00  
##  Mean   :0.001268   Mean   :0.8661   Mean   : 4.042   Mean   :12.47  
##  3rd Qu.:0.001322   3rd Qu.:0.9091   3rd Qu.: 4.416   3rd Qu.:13.00  
##  Max.   :0.005287   Max.   :1.0000   Max.   :10.069   Max.   :52.00  
## 
## mining info:
##              data ntransactions support confidence
##  transaction_file          9835   0.001        0.8

#this shows the rules (removed from code because of the length of the code)

inspect(transaction_file_apriori)

to improve the model

below we see some functions that can be used to improve the set of association

#to sort rules by their measurements - use the function: inspect(sort( DatasetName, by = “Type of Measurement”)). but note, this depends on high support, confidence or lift values

inspect(sort(transaction_file_apriori[1:10], by = "lift"))
##      lhs                                         rhs             support confidence     lift count
## [1]  {Acer Aspire,                                                                                
##       Koss Home Headphones,                                                                       
##       ViewSonic Monitor}                      => {HP Laptop} 0.001220132          1 5.151912    12
## [2]  {Dell Desktop,                                                                               
##       Koss Home Headphones,                                                                       
##       ViewSonic Monitor}                      => {HP Laptop} 0.001118454          1 5.151912    11
## [3]  {Brother Printer,                                                                            
##       Halter Acrylic Monitor Stand}           => {iMac}      0.001118454          1 3.904327    11
## [4]  {ASUS Monitor,                                                                               
##       Mackie CR Speakers,                                                                         
##       ViewSonic Monitor}                      => {iMac}      0.001016777          1 3.904327    10
## [5]  {Apple Magic Keyboard,                                                                       
##       Rii LED Gaming Keyboard & Mouse Combo,                                                      
##       ViewSonic Monitor}                      => {iMac}      0.001728521          1 3.904327    17
## [6]  {ASUS Monitor,                                                                               
##       Koss Home Headphones,                                                                       
##       Microsoft Office Home and Student 2016} => {iMac}      0.001016777          1 3.904327    10
## [7]  {ASUS 2 Monitor,                                                                             
##       Dell Desktop,                                                                               
##       Logitech Keyboard}                      => {iMac}      0.001016777          1 3.904327    10
## [8]  {Alienware Laptop,                                                                           
##       ASUS Desktop,                                                                               
##       Lenovo Desktop Computer}                => {iMac}      0.001016777          1 3.904327    10
## [9]  {Brother Printer,                                                                            
##       Dell Desktop,                                                                               
##       Epson Printer}                          => {iMac}      0.001118454          1 3.904327    11
## [10] {Apple Magic Keyboard,                                                                       
##       Brother Printer,                                                                            
##       ViewSonic Monitor}                      => {iMac}      0.001016777          1 3.904327    10

#to see a specific items rules

ItemRules <- subset(transaction_file_apriori, items %in% "Kindle")

#to call the instruction

ItemRules
## set of 0 rules

#to remove redundant rules use the is.redundant function

transaction_file_redundant <- is.redundant(transaction_file_apriori)

#to call the instruction

transaction_file_redundant
##   [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [12] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [23]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [34] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE  TRUE FALSE FALSE
##  [45] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
##  [56]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [67] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [78] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##  [89] FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [100] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [111] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [122] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [133] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [144] FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE
## [155] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [166] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [177] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE
## [188] FALSE FALSE  TRUE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
## [199] FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [210] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [221] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [232] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [243] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [254] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [265] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [276]  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [287] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [298] FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
## [309] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [320] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [331] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [342] FALSE FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
## [353] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [364] FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE
## [375] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [386] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [397] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [408] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [419] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [430] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [441] FALSE FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE  TRUE  TRUE FALSE
## [452]  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE  TRUE
## [463] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE
## [474] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [485] FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE
## [496] FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [507] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [518] FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [529] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [540] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [551] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE
## [562] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [573] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [584] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [595] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [606] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [617] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [628] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE

#to see the top 10 associations

inspect(transaction_file_apriori[1:10])
##      lhs                                         rhs             support confidence     lift count
## [1]  {Brother Printer,                                                                            
##       Halter Acrylic Monitor Stand}           => {iMac}      0.001118454          1 3.904327    11
## [2]  {ASUS Monitor,                                                                               
##       Mackie CR Speakers,                                                                         
##       ViewSonic Monitor}                      => {iMac}      0.001016777          1 3.904327    10
## [3]  {Apple Magic Keyboard,                                                                       
##       Rii LED Gaming Keyboard & Mouse Combo,                                                      
##       ViewSonic Monitor}                      => {iMac}      0.001728521          1 3.904327    17
## [4]  {ASUS Monitor,                                                                               
##       Koss Home Headphones,                                                                       
##       Microsoft Office Home and Student 2016} => {iMac}      0.001016777          1 3.904327    10
## [5]  {Acer Aspire,                                                                                
##       Koss Home Headphones,                                                                       
##       ViewSonic Monitor}                      => {HP Laptop} 0.001220132          1 5.151912    12
## [6]  {Dell Desktop,                                                                               
##       Koss Home Headphones,                                                                       
##       ViewSonic Monitor}                      => {HP Laptop} 0.001118454          1 5.151912    11
## [7]  {ASUS 2 Monitor,                                                                             
##       Dell Desktop,                                                                               
##       Logitech Keyboard}                      => {iMac}      0.001016777          1 3.904327    10
## [8]  {Alienware Laptop,                                                                           
##       ASUS Desktop,                                                                               
##       Lenovo Desktop Computer}                => {iMac}      0.001016777          1 3.904327    10
## [9]  {Brother Printer,                                                                            
##       Dell Desktop,                                                                               
##       Epson Printer}                          => {iMac}      0.001118454          1 3.904327    11
## [10] {Apple Magic Keyboard,                                                                       
##       Brother Printer,                                                                            
##       ViewSonic Monitor}                      => {iMac}      0.001016777          1 3.904327    10

#to plot the top ten associations - u can assign the top 10 items to the variable top10

top10 <- transaction_file_apriori[1:10]

#to visualize the results, u can use the plot function. However to see how to use the plot function, use the code below: ?plot

#because the ggplot2 is not running try the code below as advised by stack overflow. The other option is to reinstall and load ggplot2

dev.off()
## null device 
##           1

#here we plot the top 10 findings made using the apiriori model as a scatterplot

plot(top10)
## To reduce overplotting, jitter is added! Use jitter = 0 to prevent jitter.

#here we plot the top 10 as a graph

plot(top10, method = "graph")

#this plot shows findings based on groups for the top 10 products

plot(top10, method = "grouped")

#Scatterplot

## S3 method for class 'rules' - this is the code for plotting
plot(top10, method = NULL, measure = "support", shading = "lift", 
     interactive = NULL, engine = "default", data = NULL, control = NULL)
## To reduce overplotting, jitter is added! Use jitter = 0 to prevent jitter.

KEY FINDINGS

The most frequent items that was procured was the imac at 2519, the HP laptop at 1909 and the Cyber Power gamer desktop at 1809 There was a gradual decline in transactions with increase in the number of itemsets procured. The highest transactions for itemsets was 2163 for 1 itemset. 1647 transactions were carried out for 2 itemsets, 1294 for 3 itemsets, while 30 itemsets attracted only 1 transaction, 23 itemsets attracted 3 transactions etc.

from the model we oberve that there were 635 rules. Rules with 4 itemsets were the most at 303. More details about the top 10 transactions can be gotten above

The question of acquisition of electronidex and selling of electronidex items would depend on the marketing strategy blackwell may be willing to implement going forward. Normally, it is unlikely to find individuals that would procure many computers at a go. The level of sales of computers during a single purchase may indicate that, the purchases are being done by big cooperations and not by individuals. On the other hand, blackwell’s focus is basically on individuals and not cooperations.

Recommendation

While some of the sales levels of Electronidex on some itemsets seem to be high and sales to cooperations may yeild benefits, there is still need for some more data if a concrete decision needs to be made. Data required would include; financial data - that may give some information on the true state of profits and losses from these transactions. This way a categorical decision can be made. pending this i would recommend Blackwell should not buy Electronidex until all the needed data is gotten, which can guide a more concrete decision.