To capture the different set of rule values for Movies Dataset using apriori algorithm.

Also Observe the change in number of rules for different support,confidence values

install.packages("rmarkdown",repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/tswaminathan/Documents/R/win-library/3.5'
## (as 'lib' is unspecified)
## package 'rmarkdown' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\tswaminathan\AppData\Local\Temp\Rtmps9fHBf\downloaded_packages
install.packages("arules",repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/tswaminathan/Documents/R/win-library/3.5'
## (as 'lib' is unspecified)
## package 'arules' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\tswaminathan\AppData\Local\Temp\Rtmps9fHBf\downloaded_packages
install.packages("arulesViz",repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/tswaminathan/Documents/R/win-library/3.5'
## (as 'lib' is unspecified)
## package 'arulesViz' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\tswaminathan\AppData\Local\Temp\Rtmps9fHBf\downloaded_packages
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
mymovies <- read.csv(file.choose())

View(mymovies)

rules <- apriori(as.matrix(mymovies[,6:15],parameter=list(support=0.2, confidence = 0.5,minlen=5)))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.8    0.1    1 none FALSE            TRUE       5     0.1      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: 1 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[10 item(s), 10 transaction(s)] done [0.00s].
## sorting and recoding items ... [10 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 5 done [0.00s].
## writing ... [77 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
# Provided the rules with 2% Support, 50 % Confidence and watched a minimum of 2 movies

rules
## set of 77 rules
inspect(head(sort(rules, by = "lift")))  
##     lhs                                   rhs             support
## [1] {Gladiator,Green.Mile}             => {LOTR}          0.1    
## [2] {Sixth.Sense,Gladiator,Green.Mile} => {LOTR}          0.1    
## [3] {Harry.Potter2}                    => {Harry.Potter1} 0.1    
## [4] {LOTR}                             => {Green.Mile}    0.1    
## [5] {LOTR1}                            => {LOTR2}         0.2    
## [6] {LOTR2}                            => {LOTR1}         0.2    
##     confidence lift count
## [1] 1          10   1    
## [2] 1          10   1    
## [3] 1           5   1    
## [4] 1           5   1    
## [5] 1           5   2    
## [6] 1           5   2
head(quality(rules))
##   support confidence     lift count
## 1     0.1          1 5.000000     1
## 2     0.1          1 1.666667     1
## 3     0.1          1 1.428571     1
## 4     0.1          1 5.000000     1
## 5     0.1          1 1.428571     1
## 6     0.1          1 1.666667     1
plot(rules,method = "scatterplot")
## To reduce overplotting, jitter is added! Use jitter = 0 to prevent jitter.

plot(rules, method = "grouped")

# It looks ike most of them has wateched Lord of the rings movies along with Gladiator and Greenville
# Also most of them has watched Gladiator, Sixth sense along with Patrioit
# Patriot ,Braveheart and other three items along with Gladiator. 
plot(rules,method = "graph")