Data <- read.csv("D:\\DataScience\\Assignments\\AssociationRules\\myphonedata1.csv")
library(car)
## Warning: package 'car' was built under R version 3.5.1
## Loading required package: carData
library(carData)
library(arules)
## Warning: package 'arules' was built under R version 3.5.1
## Loading required package: Matrix
## 
## Attaching package: 'arules'
## The following object is masked from 'package:car':
## 
##     recode
## The following objects are masked from 'package:base':
## 
##     abbreviate, write
library(arulesViz)
## Warning: package 'arulesViz' was built under R version 3.5.1
## Loading required package: grid
library(mvinfluence)
## Warning: package 'mvinfluence' was built under R version 3.5.1
## Loading required package: heplots
## Warning: package 'heplots' was built under R version 3.5.1
Data1 <- as(Data,"transactions")
# Item Frequency plot
itemFrequencyPlot(Data1,topN=25)

Phone_apriori <- apriori(Data1, parameter = list(supp=0.005, conf=0.45, minlen=2, maxlen=4))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##        0.45    0.1    1 none FALSE            TRUE       5   0.005      2
##  maxlen target   ext
##       4  rules FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 0 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[11 item(s), 10 transaction(s)] done [0.00s].
## sorting and recoding items ... [11 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 done [0.00s].
## writing ... [41 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
Phone_apriori
## set of 41 rules
inspect(head(sort(Phone_apriori),n=20))
##      lhs                         rhs           support confidence lift    
## [1]  {white=blue}             => {green=}      0.4     1.0000000  1.428571
## [2]  {green=}                 => {white=blue}  0.4     0.5714286  1.428571
## [3]  {red=white}              => {green=}      0.3     1.0000000  1.428571
## [4]  {white=white}            => {red=red}     0.3     1.0000000  2.000000
## [5]  {red=red}                => {white=white} 0.3     0.6000000  2.000000
## [6]  {green=blue}             => {white=white} 0.2     1.0000000  3.333333
## [7]  {white=white}            => {green=blue}  0.2     0.6666667  3.333333
## [8]  {green=blue}             => {red=red}     0.2     1.0000000  2.000000
## [9]  {white=}                 => {green=}      0.2     1.0000000  1.428571
## [10] {red=white}              => {white=blue}  0.2     0.6666667  1.666667
## [11] {white=blue}             => {red=white}   0.2     0.5000000  1.666667
## [12] {white=blue}             => {red=red}     0.2     0.5000000  1.000000
## [13] {white=white,green=blue} => {red=red}     0.2     1.0000000  2.000000
## [14] {red=red,green=blue}     => {white=white} 0.2     1.0000000  3.333333
## [15] {red=red,white=white}    => {green=blue}  0.2     0.6666667  3.333333
## [16] {red=white,white=blue}   => {green=}      0.2     1.0000000  1.428571
## [17] {red=white,green=}       => {white=blue}  0.2     0.6666667  1.666667
## [18] {white=blue,green=}      => {red=white}   0.2     0.5000000  1.666667
## [19] {red=red,white=blue}     => {green=}      0.2     1.0000000  1.428571
## [20] {white=blue,green=}      => {red=red}     0.2     0.5000000  1.000000
##      count
## [1]  4    
## [2]  4    
## [3]  3    
## [4]  3    
## [5]  3    
## [6]  2    
## [7]  2    
## [8]  2    
## [9]  2    
## [10] 2    
## [11] 2    
## [12] 2    
## [13] 2    
## [14] 2    
## [15] 2    
## [16] 2    
## [17] 2    
## [18] 2    
## [19] 2    
## [20] 2
inspect(tail(sort(Phone_apriori),n=20))
##      lhs                           rhs           support confidence
## [1]  {white=orange}             => {red=white}   0.1     1.0       
## [2]  {white=orange}             => {green=}      0.1     1.0       
## [3]  {green=orange}             => {white=white} 0.1     1.0       
## [4]  {green=orange}             => {red=red}     0.1     1.0       
## [5]  {red=green}                => {white=}      0.1     1.0       
## [6]  {white=}                   => {red=green}   0.1     0.5       
## [7]  {red=green}                => {green=}      0.1     1.0       
## [8]  {red=yellow}               => {white=}      0.1     1.0       
## [9]  {white=}                   => {red=yellow}  0.1     0.5       
## [10] {red=yellow}               => {green=}      0.1     1.0       
## [11] {red=white,white=orange}   => {green=}      0.1     1.0       
## [12] {white=orange,green=}      => {red=white}   0.1     1.0       
## [13] {white=white,green=orange} => {red=red}     0.1     1.0       
## [14] {red=red,green=orange}     => {white=white} 0.1     1.0       
## [15] {red=green,white=}         => {green=}      0.1     1.0       
## [16] {red=green,green=}         => {white=}      0.1     1.0       
## [17] {white=,green=}            => {red=green}   0.1     0.5       
## [18] {red=yellow,white=}        => {green=}      0.1     1.0       
## [19] {red=yellow,green=}        => {white=}      0.1     1.0       
## [20] {white=,green=}            => {red=yellow}  0.1     0.5       
##      lift     count
## [1]  3.333333 1    
## [2]  1.428571 1    
## [3]  3.333333 1    
## [4]  2.000000 1    
## [5]  5.000000 1    
## [6]  5.000000 1    
## [7]  1.428571 1    
## [8]  5.000000 1    
## [9]  5.000000 1    
## [10] 1.428571 1    
## [11] 1.428571 1    
## [12] 3.333333 1    
## [13] 2.000000 1    
## [14] 3.333333 1    
## [15] 1.428571 1    
## [16] 5.000000 1    
## [17] 5.000000 1    
## [18] 1.428571 1    
## [19] 5.000000 1    
## [20] 5.000000 1
plot(head(sort(Phone_apriori),n=20), method="graph", control=list(cex=0.70))

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

plot(head(sort(Phone_apriori),n=10), method="grouped", control=list(cex=0.2))
## Warning: Unknown control parameters: cex
## Available control parameters (with default values):
## main  =  Grouped Matrix for 10 Rules
## k     =  20
## rhs_max   =  10
## lhs_items     =  2
## aggr.fun  =  function (x, ...)  UseMethod("mean")
## col   =  c("#EE0000FF", "#EE0303FF", "#EE0606FF", "#EE0909FF", "#EE0C0CFF", "#EE0F0FFF", "#EE1212FF", "#EE1515FF", "#EE1818FF", "#EE1B1BFF", "#EE1E1EFF", "#EE2222FF", "#EE2525FF", "#EE2828FF", "#EE2B2BFF", "#EE2E2EFF", "#EE3131FF", "#EE3434FF", "#EE3737FF", "#EE3A3AFF", "#EE3D3DFF", "#EE4040FF", "#EE4444FF", "#EE4747FF", "#EE4A4AFF", "#EE4D4DFF", "#EE5050FF", "#EE5353FF", "#EE5656FF", "#EE5959FF", "#EE5C5CFF", "#EE5F5FFF", "#EE6262FF", "#EE6666FF", "#EE6969FF", "#EE6C6CFF", "#EE6F6FFF", "#EE7272FF", "#EE7575FF",  "#EE7878FF", "#EE7B7BFF", "#EE7E7EFF", "#EE8181FF", "#EE8484FF", "#EE8888FF", "#EE8B8BFF", "#EE8E8EFF", "#EE9191FF", "#EE9494FF", "#EE9797FF", "#EE9999FF", "#EE9B9BFF", "#EE9D9DFF", "#EE9F9FFF", "#EEA0A0FF", "#EEA2A2FF", "#EEA4A4FF", "#EEA5A5FF", "#EEA7A7FF", "#EEA9A9FF", "#EEABABFF", "#EEACACFF", "#EEAEAEFF", "#EEB0B0FF", "#EEB1B1FF", "#EEB3B3FF", "#EEB5B5FF", "#EEB7B7FF", "#EEB8B8FF", "#EEBABAFF", "#EEBCBCFF", "#EEBDBDFF", "#EEBFBFFF", "#EEC1C1FF", "#EEC3C3FF", "#EEC4C4FF", "#EEC6C6FF", "#EEC8C8FF",  "#EEC9C9FF", "#EECBCBFF", "#EECDCDFF", "#EECFCFFF", "#EED0D0FF", "#EED2D2FF", "#EED4D4FF", "#EED5D5FF", "#EED7D7FF", "#EED9D9FF", "#EEDBDBFF", "#EEDCDCFF", "#EEDEDEFF", "#EEE0E0FF", "#EEE1E1FF", "#EEE3E3FF", "#EEE5E5FF", "#EEE7E7FF", "#EEE8E8FF", "#EEEAEAFF", "#EEECECFF", "#EEEEEEFF")
## reverse   =  TRUE
## xlab  =  NULL
## ylab  =  NULL
## legend    =  Size: support  Color: lift
## spacing   =  -1
## panel.function    =  function (row, size, shading, spacing)  {     size[size == 0] <- NA     shading[is.na(shading)] <- 1     grid.circle(x = c(1:length(size)), y = row, r = size/2 * (1 - spacing), default.units = "native", gp = gpar(fill = shading, col = shading, alpha = 0.9)) }
## gp_main   =  list(cex = 1.2, fontface = "bold", font = c(bold = 2))
## gp_labels     =  list(cex = 0.8)
## gp_labs   =  list(cex = 1.2, fontface = "bold", font = c(bold = 2))
## gp_lines  =  list(col = "gray", lty = 3)
## newpage   =  TRUE
## max.shading   =  NA
## engine    =  default
## verbose   =  FALSE