Assignment Version 3

Author

Ryan Hickey

library(arules)
Loading required package: Matrix

Attaching package: 'arules'
The following objects are masked from 'package:base':

    abbreviate, write

Number 1

retail_transactions <- read.transactions("retail_transactions_3.csv", sep= ",")
Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
within quoted string

Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
within quoted string

Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
within quoted string

Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
within quoted string

Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
within quoted string

Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
within quoted string

Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
within quoted string

Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
within quoted string
Warning in asMethod(object): removing duplicated items in transactions

Number 2

transactions as itemMatrix in sparse format with
 10000 rows (elements/itemsets/transactions) and
 5479 columns (items) and a density of 0.002744552 

most frequent items:
WHITE HANGING HEART T-LIGHT HOLDER           REGENCY CAKESTAND 3 TIER 
                               822                                776 
           JUMBO BAG RED RETROSPOT                      PARTY BUNTING 
                               663                                561 
     ASSORTED COLOUR BIRD ORNAMENT                            (Other) 
                               544                             147008 

element (itemset/transaction) length distribution:
sizes
   1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16 
1658  707  498  413  365  341  316  310  309  290  261  227  227  242  260  227 
  17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32 
 204  199  233  189  184  149  138  125  104  111  112   98  113   99   78   68 
  33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48 
  55   62   65   44   48   41   52   41   44   26   45   27   27   35   30   24 
  49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64 
  26   23   22   21   16   19   21   13   11   16   13   14   15   10   13   13 
  65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80 
   3   13   13    7    6    9    9    6    6    4    3    8    5    6    3    5 
  81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96 
   3    4    5    8    3    5    8    2    4    4    1    3    2    3    1    2 
  97   98  100  101  102  103  104  105  107  108  109  110  111  112  113  119 
   5    1    2    2    2    1    2    1    1    3    1    2    1    1    2    1 
 120  121  122  123  125  127  134  142  146  147  150  154  157  171  193  204 
   1    1    1    1    1    1    1    2    1    1    1    2    1    2    1    1 
 235  249 
   1    1 

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   1.00    3.00   10.00   15.04   21.00  249.00 

includes extended item information - examples:
                      labels
1                   1 HANGER
2     10 COLOUR SPACEBOY PEN
3 12 COLOURED PARTY BALLOONS

2(a)

There was 10,000 transactions within the dataset

2(b)

There was 5,479 items available for purchase

2(c)

  • Number of rows: 10,000

  • Number of columns: 5,479

  • Density: 0.002744552

  • The sparse matrix contains a total of 54,790,000 cells (10,000 rows * 5,479 columns).

  • 150,553 cells contain non-zero values.

2(d)

The largest number of items purchased in a single transaction is 249

2(e)

The mean number of items purchased in a single transaction is 15.04

Number 3

Number 4

Apriori

Parameter specification:
 confidence minval smax arem  aval originalSupport maxtime support minlen
        0.5    0.1    1 none FALSE            TRUE       5    0.01      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: 100 

set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[5479 item(s), 10000 transaction(s)] done [0.04s].
sorting and recoding items ... [384 item(s)] done [0.00s].
creating transaction tree ... done [0.00s].
checking subsets of size 1 2 3 4 done [0.00s].
writing ... [86 rule(s)] done [0.00s].
creating S4 object  ... done [0.00s].
retail_rules
set of 86 rules 

4(a)

This discovered 86 rules using a support threshold of 0.01, a confidence threshold of 0.5 and a minimum length of 2.

4(b)

A support threshold of 0.01 means the algorithm will only consider item-sets that appear together at least 1% of the time. Aiming to focus on item-sets that occur more frequently together.

4(c)

A confidence threshold of 0.5 tells us that the algorithm will only accept rules where there’s a good chance that if someone buys item A, they’ll also purchase item B.

Number 5

set of 86 rules

rule length distribution (lhs + rhs):sizes
 2  3 
47 39 

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  2.000   2.000   2.000   2.453   3.000   3.000 

summary of quality measures:
    support          confidence        coverage            lift       
 Min.   :0.01000   Min.   :0.5021   Min.   :0.01200   Min.   : 6.585  
 1st Qu.:0.01063   1st Qu.:0.5510   1st Qu.:0.01733   1st Qu.:12.347  
 Median :0.01160   Median :0.6022   Median :0.02000   Median :15.266  
 Mean   :0.01315   Mean   :0.6198   Mean   :0.02152   Mean   :17.144  
 3rd Qu.:0.01515   3rd Qu.:0.6652   3rd Qu.:0.02428   3rd Qu.:21.864  
 Max.   :0.02270   Max.   :0.8814   Max.   :0.03770   Max.   :44.055  
     count      
 Min.   :100.0  
 1st Qu.:106.2  
 Median :116.0  
 Mean   :131.5  
 3rd Qu.:151.5  
 Max.   :227.0  

mining info:
                data ntransactions support confidence
 retail_transactions         10000    0.01        0.5
                                                                                                call
 apriori(data = retail_transactions, parameter = list(support = 0.01, confidence = 0.5, minlen = 2))

5(a)

  • There are 47 rules with two items

  • And 39 rules with three items

5(b)

  • Minimum lift: 6.585

  • Maximum lift: 44.055

Number 6

6(a)

     lhs                                      rhs                                   support confidence coverage      lift count
[1]  {WOODEN STAR CHRISTMAS SCANDINAVIAN}  => {WOODEN HEART CHRISTMAS SCANDINAVIAN}  0.0113  0.7533333   0.0150 44.054581   113
[2]  {WOODEN HEART CHRISTMAS SCANDINAVIAN} => {WOODEN STAR CHRISTMAS SCANDINAVIAN}   0.0113  0.6608187   0.0171 44.054581   113
[3]  {PINK REGENCY TEACUP AND SAUCER,                                                                                          
      ROSES REGENCY TEACUP AND SAUCER}     => {GREEN REGENCY TEACUP AND SAUCER}      0.0156  0.8813559   0.0177 28.708662   156
[4]  {GREEN REGENCY TEACUP AND SAUCER,                                                                                         
      REGENCY CAKESTAND 3 TIER}            => {PINK REGENCY TEACUP AND SAUCER}       0.0102  0.6938776   0.0147 28.672626   102
[5]  {GREEN REGENCY TEACUP AND SAUCER,                                                                                         
      ROSES REGENCY TEACUP AND SAUCER}     => {PINK REGENCY TEACUP AND SAUCER}       0.0156  0.6872247   0.0227 28.397714   156
[6]  {PINK REGENCY TEACUP AND SAUCER,                                                                                          
      REGENCY CAKESTAND 3 TIER}            => {GREEN REGENCY TEACUP AND SAUCER}      0.0102  0.8500000   0.0120 27.687296   102
[7]  {GARDENERS KNEELING PAD KEEP CALM}    => {GARDENERS KNEELING PAD CUP OF TEA}    0.0163  0.5821429   0.0280 26.105061   163
[8]  {GARDENERS KNEELING PAD CUP OF TEA}   => {GARDENERS KNEELING PAD KEEP CALM}     0.0163  0.7309417   0.0223 26.105061   163
[9]  {PINK REGENCY TEACUP AND SAUCER}      => {GREEN REGENCY TEACUP AND SAUCER}      0.0192  0.7933884   0.0242 25.843271   192
[10] {GREEN REGENCY TEACUP AND SAUCER}     => {PINK REGENCY TEACUP AND SAUCER}       0.0192  0.6254072   0.0307 25.843271   192
[11] {DOLLY GIRL LUNCH BOX}                => {SPACEBOY LUNCH BOX}                   0.0138  0.6359447   0.0217 25.642931   138
[12] {SPACEBOY LUNCH BOX}                  => {DOLLY GIRL LUNCH BOX}                 0.0138  0.5564516   0.0248 25.642931   138
[13] {GREEN REGENCY TEACUP AND SAUCER,                                                                                         
      PINK REGENCY TEACUP AND SAUCER}      => {ROSES REGENCY TEACUP AND SAUCER}      0.0156  0.8125000   0.0192 24.399399   156
[14] {REGENCY CAKESTAND 3 TIER,                                                                                                
      ROSES REGENCY TEACUP AND SAUCER}     => {GREEN REGENCY TEACUP AND SAUCER}      0.0116  0.7483871   0.0155 24.377430   116
[15] {JUMBO BAG PEARS}                     => {JUMBO BAG APPLES}                     0.0111  0.6529412   0.0170 24.272906   111
[16] {GREEN REGENCY TEACUP AND SAUCER,                                                                                         
      REGENCY CAKESTAND 3 TIER}            => {ROSES REGENCY TEACUP AND SAUCER}      0.0116  0.7891156   0.0147 23.697167   116
[17] {GREEN REGENCY TEACUP AND SAUCER}     => {ROSES REGENCY TEACUP AND SAUCER}      0.0227  0.7394137   0.0307 22.204615   227
[18] {ROSES REGENCY TEACUP AND SAUCER}     => {GREEN REGENCY TEACUP AND SAUCER}      0.0227  0.6816817   0.0333 22.204615   227
[19] {ROUND SNACK BOXES SET OF 4 FRUITS}   => {ROUND SNACK BOXES SET OF4 WOODLAND}   0.0100  0.5524862   0.0181 22.188200   100
[20] {PINK REGENCY TEACUP AND SAUCER}      => {ROSES REGENCY TEACUP AND SAUCER}      0.0177  0.7314050   0.0242 21.964113   177
[21] {ROSES REGENCY TEACUP AND SAUCER}     => {PINK REGENCY TEACUP AND SAUCER}       0.0177  0.5315315   0.0333 21.964113   177
[22] {ALARM CLOCK BAKELIKE GREEN,                                                                                              
      ALARM CLOCK BAKELIKE PINK}           => {ALARM CLOCK BAKELIKE RED}             0.0100  0.7575758   0.0132 21.895253   100
[23] {LARGE WHITE HEART OF WICKER}         => {SMALL WHITE HEART OF WICKER}          0.0113  0.5159817   0.0219 21.771381   113
[24] {ALARM CLOCK BAKELIKE PINK,                                                                                               
      ALARM CLOCK BAKELIKE RED}            => {ALARM CLOCK BAKELIKE GREEN}           0.0100  0.6666667   0.0150 21.299255   100
[25] {CHARLOTTE BAG PINK POLKADOT}         => {RED RETROSPOT CHARLOTTE BAG}          0.0127  0.6256158   0.0203 20.923604   127
[26] {HOT WATER BOTTLE I AM SO POORLY}     => {CHOCOLATE HOT WATER BOTTLE}           0.0102  0.5454545   0.0187 20.661157   102
[27] {STRAWBERRY CHARLOTTE BAG}            => {RED RETROSPOT CHARLOTTE BAG}          0.0117  0.6157895   0.0190 20.594966   117
[28] {ALARM CLOCK BAKELIKE GREEN,                                                                                              
      ALARM CLOCK BAKELIKE RED}            => {ALARM CLOCK BAKELIKE PINK}            0.0100  0.5025126   0.0199 20.344638   100
[29] {ALARM CLOCK BAKELIKE IVORY}          => {ALARM CLOCK BAKELIKE RED}             0.0120  0.6896552   0.0174 19.932230   120
[30] {BAKING SET SPACEBOY DESIGN}          => {BAKING SET 9 PIECE RETROSPOT}         0.0115  0.6388889   0.0180 19.597819   115
[31] {ALARM CLOCK BAKELIKE GREEN}          => {ALARM CLOCK BAKELIKE RED}             0.0199  0.6357827   0.0313 18.375224   199
[32] {ALARM CLOCK BAKELIKE RED}            => {ALARM CLOCK BAKELIKE GREEN}           0.0199  0.5751445   0.0346 18.375224   199
[33] {LUNCH BAG CARS BLUE,                                                                                                     
      LUNCH BAG RED RETROSPOT}             => {LUNCH BAG WOODLAND}                   0.0101  0.5343915   0.0189 17.578669   101
[34] {ALARM CLOCK BAKELIKE PINK}           => {ALARM CLOCK BAKELIKE RED}             0.0150  0.6072874   0.0247 17.551660   150
[35] {CHARLOTTE BAG SUKI DESIGN}           => {RED RETROSPOT CHARLOTTE BAG}          0.0114  0.5181818   0.0220 17.330496   114
[36] {WOODLAND CHARLOTTE BAG}              => {RED RETROSPOT CHARLOTTE BAG}          0.0111  0.5115207   0.0217 17.107717   111
[37] {ALARM CLOCK BAKELIKE PINK}           => {ALARM CLOCK BAKELIKE GREEN}           0.0132  0.5344130   0.0247 17.073896   132
[38] {WOODEN PICTURE FRAME WHITE FINISH}   => {WOODEN FRAME ANTIQUE WHITE}           0.0197  0.5487465   0.0359 16.283279   197
[39] {WOODEN FRAME ANTIQUE WHITE}          => {WOODEN PICTURE FRAME WHITE FINISH}    0.0197  0.5845697   0.0337 16.283279   197
[40] {LUNCH BAG CARS BLUE,                                                                                                     
      LUNCH BAG RED RETROSPOT}             => {LUNCH BAG PINK POLKADOT}              0.0116  0.6137566   0.0189 16.280016   116
[41] {LUNCH BAG  BLACK SKULL,                                                                                                  
      LUNCH BAG CARS BLUE}                 => {LUNCH BAG PINK POLKADOT}              0.0108  0.6000000   0.0180 15.915119   108
[42] {LUNCH BAG RED RETROSPOT,                                                                                                 
      LUNCH BAG SUKI DESIGN}               => {LUNCH BAG PINK POLKADOT}              0.0103  0.5953757   0.0173 15.792459   103
[43] {LUNCH BAG RED RETROSPOT,                                                                                                 
      LUNCH BAG WOODLAND}                  => {LUNCH BAG CARS BLUE}                  0.0101  0.5906433   0.0171 15.301639   101
[44] {LUNCH BAG  BLACK SKULL,                                                                                                  
      LUNCH BAG RED RETROSPOT}             => {LUNCH BAG PINK POLKADOT}              0.0120  0.5741627   0.0209 15.229779   120
[45] {LUNCH BAG DOLLY GIRL DESIGN}         => {LUNCH BAG SPACEBOY DESIGN}            0.0131  0.5796460   0.0226 15.213806   131
[46] {LUNCH BAG  BLACK SKULL,                                                                                                  
      LUNCH BAG PINK POLKADOT}             => {LUNCH BAG CARS BLUE}                  0.0108  0.5775401   0.0187 14.962179   108
[47] {LUNCH BAG CARS BLUE,                                                                                                     
      LUNCH BAG RED RETROSPOT}             => {LUNCH BAG  BLACK SKULL}               0.0118  0.6243386   0.0189 14.829896   118
[48] {LUNCH BAG RED RETROSPOT,                                                                                                 
      LUNCH BAG SPACEBOY DESIGN}           => {LUNCH BAG PINK POLKADOT}              0.0101  0.5580110   0.0181 14.801354   101
[49] {LUNCH BAG PINK POLKADOT,                                                                                                 
      LUNCH BAG RED RETROSPOT}             => {LUNCH BAG CARS BLUE}                  0.0116  0.5686275   0.0204 14.731281   116
[50] {LUNCH BAG  BLACK SKULL,                                                                                                  
      LUNCH BAG RED RETROSPOT}             => {LUNCH BAG CARS BLUE}                  0.0118  0.5645933   0.0209 14.626769   118
[51] {LUNCH BAG CARS BLUE,                                                                                                     
      LUNCH BAG PINK POLKADOT}             => {LUNCH BAG  BLACK SKULL}               0.0108  0.6101695   0.0177 14.493337   108
[52] {LUNCH BAG VINTAGE LEAF DESIGN}       => {LUNCH BAG APPLE DESIGN}               0.0122  0.5020576   0.0243 14.468519   122
[53] {LUNCH BAG RED RETROSPOT,                                                                                                 
      LUNCH BAG WOODLAND}                  => {LUNCH BAG  BLACK SKULL}               0.0102  0.5964912   0.0171 14.168438   102
[54] {LUNCH BAG PINK POLKADOT,                                                                                                 
      LUNCH BAG RED RETROSPOT}             => {LUNCH BAG SUKI DESIGN}                0.0103  0.5049020   0.0204 14.064121   103
[55] {LUNCH BAG RED RETROSPOT,                                                                                                 
      LUNCH BAG SPACEBOY DESIGN}           => {LUNCH BAG  BLACK SKULL}               0.0107  0.5911602   0.0181 14.041810   107
[56] {LUNCH BAG RED RETROSPOT,                                                                                                 
      LUNCH BAG SUKI DESIGN}               => {LUNCH BAG  BLACK SKULL}               0.0102  0.5895954   0.0173 14.004641   102
[57] {LUNCH BAG PINK POLKADOT,                                                                                                 
      LUNCH BAG RED RETROSPOT}             => {LUNCH BAG  BLACK SKULL}               0.0120  0.5882353   0.0204 13.972335   120
[58] {LUNCH BAG CARS BLUE,                                                                                                     
      LUNCH BAG WOODLAND}                  => {LUNCH BAG RED RETROSPOT}              0.0101  0.7266187   0.0139 13.735703   101
[59] {LUNCH BAG  BLACK SKULL,                                                                                                  
      LUNCH BAG WOODLAND}                  => {LUNCH BAG RED RETROSPOT}              0.0102  0.7183099   0.0142 13.578636   102
[60] {LUNCH BAG  BLACK SKULL,                                                                                                  
      LUNCH BAG RED RETROSPOT}             => {LUNCH BAG SPACEBOY DESIGN}            0.0107  0.5119617   0.0209 13.437316   107
[61] {LUNCH BAG PINK POLKADOT,                                                                                                 
      LUNCH BAG SPACEBOY DESIGN}           => {LUNCH BAG RED RETROSPOT}              0.0101  0.7013889   0.0144 13.258769   101
[62] {PAINTED METAL PEARS ASSORTED}        => {ASSORTED COLOUR BIRD ORNAMENT}        0.0106  0.7210884   0.0147 13.255302   106
[63] {LUNCH BAG  BLACK SKULL,                                                                                                  
      LUNCH BAG CARS BLUE}                 => {LUNCH BAG RED RETROSPOT}              0.0118  0.6555556   0.0180 12.392355   118
[64] {LUNCH BAG CARS BLUE,                                                                                                     
      LUNCH BAG PINK POLKADOT}             => {LUNCH BAG RED RETROSPOT}              0.0116  0.6553672   0.0177 12.388795   116
[65] {LUNCH BAG  BLACK SKULL,                                                                                                  
      LUNCH BAG SPACEBOY DESIGN}           => {LUNCH BAG RED RETROSPOT}              0.0107  0.6524390   0.0164 12.333441   107
[66] {LUNCH BAG PINK POLKADOT,                                                                                                 
      LUNCH BAG SUKI DESIGN}               => {LUNCH BAG RED RETROSPOT}              0.0103  0.6518987   0.0158 12.323227   103
[67] {60 TEATIME FAIRY CAKE CASES}         => {PACK OF 72 RETROSPOT CAKE CASES}      0.0134  0.5056604   0.0265 12.184587   134
[68] {LUNCH BAG  BLACK SKULL,                                                                                                  
      LUNCH BAG PINK POLKADOT}             => {LUNCH BAG RED RETROSPOT}              0.0120  0.6417112   0.0187 12.130647   120
[69] {LUNCH BAG  BLACK SKULL,                                                                                                  
      LUNCH BAG SUKI DESIGN}               => {LUNCH BAG RED RETROSPOT}              0.0102  0.6144578   0.0166 11.615460   102
[70] {LUNCH BAG WOODLAND}                  => {LUNCH BAG RED RETROSPOT}              0.0171  0.5625000   0.0304 10.633270   171
[71] {LUNCH BAG PINK POLKADOT}             => {LUNCH BAG RED RETROSPOT}              0.0204  0.5411141   0.0377 10.228999   204
[72] {LUNCH BAG DOLLY GIRL DESIGN}         => {LUNCH BAG RED RETROSPOT}              0.0121  0.5353982   0.0226 10.120950   121
[73] {JUMBO BAG STRAWBERRY}                => {JUMBO BAG RED RETROSPOT}              0.0172  0.6515152   0.0264  9.826775   172
[74] {JUMBO BAG SCANDINAVIAN BLUE PAISLEY} => {JUMBO BAG RED RETROSPOT}              0.0108  0.6352941   0.0170  9.582113   108
[75] {JUMBO BAG PINK POLKADOT}             => {JUMBO BAG RED RETROSPOT}              0.0223  0.6043360   0.0369  9.115174   223
[76] {CANDLEHOLDER PINK HANGING HEART}     => {WHITE HANGING HEART T-LIGHT HOLDER}   0.0111  0.7449664   0.0149  9.062852   111
[77] {JUMBO BAG SPACEBOY DESIGN}           => {JUMBO BAG RED RETROSPOT}              0.0113  0.5978836   0.0189  9.017852   113
[78] {JUMBO STORAGE BAG SUKI}              => {JUMBO BAG RED RETROSPOT}              0.0186  0.5904762   0.0315  8.906127   186
[79] {RED HANGING HEART T-LIGHT HOLDER}    => {WHITE HANGING HEART T-LIGHT HOLDER}   0.0186  0.6888889   0.0270  8.380643   186
[80] {JUMBO  BAG BAROQUE BLACK WHITE}      => {JUMBO BAG RED RETROSPOT}              0.0147  0.5505618   0.0267  8.304100   147
[81] {JUMBO BAG PINK VINTAGE PAISLEY}      => {JUMBO BAG RED RETROSPOT}              0.0128  0.5493562   0.0233  8.285916   128
[82] {JUMBO BAG VINTAGE DOILY}             => {JUMBO BAG RED RETROSPOT}              0.0116  0.5155556   0.0225  7.776102   116
[83] {JUMBO SHOPPER VINTAGE RED PAISLEY}   => {JUMBO BAG RED RETROSPOT}              0.0152  0.5033113   0.0302  7.591422   152
[84] {JUMBO BAG WOODLAND ANIMALS}          => {JUMBO BAG RED RETROSPOT}              0.0101  0.5024876   0.0201  7.578998   101
[85] {GREEN REGENCY TEACUP AND SAUCER,                                                                                         
      PINK REGENCY TEACUP AND SAUCER}      => {REGENCY CAKESTAND 3 TIER}             0.0102  0.5312500   0.0192  6.846005   102
[86] {GREEN REGENCY TEACUP AND SAUCER,                                                                                         
      ROSES REGENCY TEACUP AND SAUCER}     => {REGENCY CAKESTAND 3 TIER}             0.0116  0.5110132   0.0227  6.585222   116

6(i)

The rule “{WOODEN STAR CHRISTMAS SCANDINAVIAN} => {WOODEN HEART CHRISTMAS SCANDINAVIAN}” tells us that customers who purchase “Wooden Star Christmas Scandinavian” are also very likely to purchase “Wooden Heart Christmas Scandinavian”.

6(ii)

  • With a support of 0.0113, it tells us that 1.13% of all transactions include both “Wooden Star Christmas Scandinavian” and “Wooden Heart Christmas Scandinavian”.

  • While with a confidence value of 0.75, we know that 75% of all transactions that contain specifically “Wooden Star Christmas Scandinavian” also contain “Wooden Heart Christmas Scandinavian”.

6(iii)

With a lift of 44.05, we can tell that customers who purchase “Wooden Star Christmas Scandinavian” are 44 times more likely to also purchase “Wooden Heart Christmas Scandinavian”. This tells us these two products have a very strong relationship.

6(c)

The rule “{ALARM CLOCK BAKELIKE GREEN} => {ALARM CLOCK BAKELIKE RED}“ is trivial as it states that consumers that purchase a green alarm clock are also likely to purchase a red one. This does not give us much insight as it is the same product in a different color variation. While the type of product tells us that once customers purchase one version of the product they’re not likely to need a second. This is creating a rule based off of the idea that the consumer required the alarm clock product. However, this rule is telling us they’re likely to purchase two. Although this is not the common case.

Another example of a similarly trivial rule is “{LUNCH BAG RED RETROSPOT} => {LUNCH BAG PINK POLKADOT}“. This is trivial for similar reasons to the above. The rule does not seem to give us anything actionable as it is stating that customers will purchase two variations of the same product. If this was a food item situation this could make sense as customers may consider purchasing two different types of berries for example. As they’re both berries the rule would group them together as likely to be purchased together. However, this rule does not seem to take into account the type of product and how it would be purchased. Consumers would search for one variation of a lunch bag and purchase one lunch bag as they would rarely have a need for two. Decreasing the chances of a customer purchasing two lunch bags within the same transaction.

6(d)

I believe the rule “{GARDENERS KNEELING PAD KEEP CALM} => {GARDENERS KNEELING PAD CUP OF TEA}” is actionable as management could sell these products in bundles to consumers that have a”green thumb”. Targeting household gardeners with a product bundle, a buy one get one half price offer or a pop up showcasing “customers who bought GARDENERS KNEELING PAD KEEP CALM also bought GARDENERS KNEELING PAD CUP OF TEA”. Aiming to get their garden back in order for the Summer.

Another similarly actionable rule is “{WOODEN PICTURE FRAME WHITE FINISH} => {WOODEN FRAME ANTIQUE WHITE}”. These products could be marketed in a home decor renovation bundle. Pushing the specifically white variables of products to consumers. Where these products differ from the non actionable trivial products above is the fact that consumers will have multiple photo frames around their homes. Instead of just one, so offering them variation while still sticking to the same theme of white can boost online sales.

7

print(rose_rules_sorted)
set of 10 rules 
inspect(rose_rules_sorted)
     lhs                                   rhs                               support confidence coverage      lift count
[1]  {PINK REGENCY TEACUP AND SAUCER,                                                                                   
      ROSES REGENCY TEACUP AND SAUCER}  => {GREEN REGENCY TEACUP AND SAUCER}  0.0156  0.8813559   0.0177 28.708662   156
[2]  {GREEN REGENCY TEACUP AND SAUCER,                                                                                  
      ROSES REGENCY TEACUP AND SAUCER}  => {PINK REGENCY TEACUP AND SAUCER}   0.0156  0.6872247   0.0227 28.397714   156
[3]  {GREEN REGENCY TEACUP AND SAUCER,                                                                                  
      PINK REGENCY TEACUP AND SAUCER}   => {ROSES REGENCY TEACUP AND SAUCER}  0.0156  0.8125000   0.0192 24.399399   156
[4]  {REGENCY CAKESTAND 3 TIER,                                                                                         
      ROSES REGENCY TEACUP AND SAUCER}  => {GREEN REGENCY TEACUP AND SAUCER}  0.0116  0.7483871   0.0155 24.377430   116
[5]  {GREEN REGENCY TEACUP AND SAUCER,                                                                                  
      REGENCY CAKESTAND 3 TIER}         => {ROSES REGENCY TEACUP AND SAUCER}  0.0116  0.7891156   0.0147 23.697167   116
[6]  {GREEN REGENCY TEACUP AND SAUCER}  => {ROSES REGENCY TEACUP AND SAUCER}  0.0227  0.7394137   0.0307 22.204615   227
[7]  {ROSES REGENCY TEACUP AND SAUCER}  => {GREEN REGENCY TEACUP AND SAUCER}  0.0227  0.6816817   0.0333 22.204615   227
[8]  {PINK REGENCY TEACUP AND SAUCER}   => {ROSES REGENCY TEACUP AND SAUCER}  0.0177  0.7314050   0.0242 21.964113   177
[9]  {ROSES REGENCY TEACUP AND SAUCER}  => {PINK REGENCY TEACUP AND SAUCER}   0.0177  0.5315315   0.0333 21.964113   177
[10] {GREEN REGENCY TEACUP AND SAUCER,                                                                                  
      ROSES REGENCY TEACUP AND SAUCER}  => {REGENCY CAKESTAND 3 TIER}         0.0116  0.5110132   0.0227  6.585222   116
  • The code above produces all 10 rules involving “ROSES REGENCY TEACUP AND SAUCER”.

  • If a customer purchases “ROSES REGENCY TEACUP AND SAUCER”, they are most likely to purchase “GREEN REGENCY TEACUP AND SAUCER”, “PINK REGENCY TEACUP AND SAUCER” or “REGENCY CAKESTAND 3 TIER”.

Collaborative Filtering

Number 1

library(tidyverse)
library(recommenderlab)
library(dplyr)
library(ggplot2)
library(tibble)

Number 2

steam_ratings <- read_csv("steam_ratings.csv")
Warning: One or more parsing issues, call `problems()` on your data frame for details,
e.g.:
  dat <- vroom(...)
  problems(dat)
steam_ratings <- as(steam_ratings, "matrix")
steam_ratings <- as(steam_ratings, "realRatingMatrix")

Number 3

3(a)

vector_ratings
      0       1       2       3       4       5 
3236066    4773   12500   19762   10655    4724 
  • We can see that 3,236,066 have a rating of 0 meaning that they actually have a missing rating. With a rating of 3 being the most common and a rating of 5 being the least common.

3(b)

Warning: Removed 2 rows containing non-finite values (`stat_bin()`).

  • We can see from our graph above that the majority of ratings fall between 2-4.

3(c)

user_game_counts <- rowCounts(steam_ratings)
ggplot(data = data.frame(game_count = user_game_counts), aes(x = game_count)) +
      geom_histogram(binwidth = 20, fill = "skyblue", color = "black") +
      labs(title = "Games Rated per User", x = "Total Games Rated", y = "Frequency")

  • We can see from the above graph that most users have rated between 1-40 games.

  • However this histogram is skewed due to some outliers who have rated up to 300 games.

Number 4

In an attempt to tidy the data we’re going to do the following.

  1. Remove Less Popular Games: Exclude games with less than 6 ratings. This ensures we focus on games with enough ratings for meaningful recommendations.

  2. Filter Out Less Active Users: Remove users who have rated fewer than 5 games. Users with limited ratings may not provide sufficient information for accurate recommendations

steam_small <- steam_ratings[rowCounts(steam_ratings) >= 5, ]

steam_small <- steam_small[, colCounts(steam_small) >= 6]

steam_small_matrix <- as(steam_small, "matrix")

4(a)

set.seed(101)

4(b)

eval_steam <- evaluationScheme(data = steam_small,
      method = "split",
      train = 0.8,
      given = 6,
      goodRating = 3)
Warning in .local(data, ...): Dropping these users from the evaluation since they have fewer rating than specified in given!
These users are 400, 423, 620, 670, 681, 683, 863, 1363, 1391, 1624, 1649, 1735, 1832, 1912, 1966, 2016, 2054

4(c)

  • train <- getData(eval_steam, "train")
    known <- getData(eval_steam, "known")
    unknown <- getData(eval_steam, "unknown")

Number 5

ubcf_model <- Recommender(data = train, 
       method = "UBCF", 
       parameter = list(normalize = "center", method = "Cosine"))
ubcf_predict <- predict(object = ubcf_model, 
      newdata = known, 
      type = "ratings")
ubcf_eval <- calcPredictionAccuracy(x = ubcf_predict, 
      data = unknown)
ubcf_eval
     RMSE       MSE       MAE 
1.1887736 1.4131826 0.9272125 
  • The MAE is 0.9145851

    • This tells us that on average, the predicted ratings are off by approximately 0.91 of a rating.

Number 6

ibcf_model <- Recommender(data = train,
      method = "IBCF", 
      parameter = list(normalize = "center", method = "Cosine"))
ibcf_predict <- predict(object = ibcf_model,
       newdata = known, 
       type = "ratings")
ibcf_eval <- calcPredictionAccuracy(x = ibcf_predict,
       data = unknown)
ibcf_eval
    RMSE      MSE      MAE 
1.492958 2.228922 1.167412 
  • The MAE is 1.148418.

    • This tells us that on average the predicted ratings are off by approximately 1.15 of a rating.

Number 7

We can tell that the UBCF model is more accurate than the IBCF model as the MAE for the UBFC model is 0.91, and the IBCF model’s MAE is 1.14. Making the UBCF model more accurate.

ubcf_recs <- predict(object = ubcf_model,
      newdata = known,
      type = "topNList",
      n = 3)
ubcf_recs <- predict(object = ubcf_model,
      newdata = known,
      type = "topNList",
      n = 3)

ubcf_recs_list <- as(ubcf_recs, "list")

for (i in 1:5) {print(paste("Recommendations for user", i))
     print(ubcf_recs_list[[i]])}
[1] "Recommendations for user 1"
[1] "Hitman Blood Money" "Half-Life 2"        "Pid"               
[1] "Recommendations for user 2"
[1] "Cry of Fear" "SMITE"       "NBA 2K14"   
[1] "Recommendations for user 3"
[1] "Hitman Blood Money" "Hazard Ops"         "Time Clickers"     
[1] "Recommendations for user 4"
[1] "Hitman Blood Money" "Time Clickers"      "X-COM UFO Defense" 
[1] "Recommendations for user 5"
[1] "Hitman Blood Money" "Time Clickers"      "Town of Salem"     

Recommendations for user 1

  • God Mode

  • Haunted Memories

  • Bulletstorm

Recommendations for user 2

  • God Mode

  • Half-Life 2 Deathmatch

  • Hurtworld

Recommendations for user 3

  • Scania Truck Driving Simulator

  • The Ultimate DOOM

  • Gotham City Impostors Free To Play

Recommendations for user 4

  • Brothers - A Tale of Two Sons

  • Defense Grid 2

  • God Mode

Recommendations for user 5

  • Brothers - A Tale of Two Sons

  • Grimoire Manastorm

  • RPG MO

Number 8

Steam could use the UBCF collaborative filtering model in a number of ways.

  1. The most obvious way is to suggest these games to the relative users as “Suggestions for you” in order to increase sales.

  2. Steam could offer users 3 day free trials to users of the recommended games. Giving the user the opportunity to use the game and get “hooked” to a point where at the end of their free trial they’re encouraged to purchase the game.

  3. Another way is to bundle the recommended games into “Sale Packages” that will be advertised to the users in a campaign. With the idea of the campaign being “Buy one get one half price”