Association Rules:: Books Data Set
Association Rules:: Books Data Set
summary(books)
ChildBks YouthBks CookBks DoItYBks
Min. :0.000 Min. :0.0000 Min. :0.000 Min. :0.000
1st Qu.:0.000 1st Qu.:0.0000 1st Qu.:0.000 1st Qu.:0.000
Median :0.000 Median :0.0000 Median :0.000 Median :0.000
Mean :0.423 Mean :0.2475 Mean :0.431 Mean :0.282
3rd Qu.:1.000 3rd Qu.:0.0000 3rd Qu.:1.000 3rd Qu.:1.000
Max. :1.000 Max. :1.0000 Max. :1.000 Max. :1.000
RefBks ArtBks GeogBks ItalCook
Min. :0.0000 Min. :0.000 Min. :0.000 Min. :0.0000
1st Qu.:0.0000 1st Qu.:0.000 1st Qu.:0.000 1st Qu.:0.0000
Median :0.0000 Median :0.000 Median :0.000 Median :0.0000
Mean :0.2145 Mean :0.241 Mean :0.276 Mean :0.1135
3rd Qu.:0.0000 3rd Qu.:0.000 3rd Qu.:1.000 3rd Qu.:0.0000
Max. :1.0000 Max. :1.000 Max. :1.000 Max. :1.0000
ItalAtlas ItalArt Florence
Min. :0.000 Min. :0.0000 Min. :0.0000
1st Qu.:0.000 1st Qu.:0.0000 1st Qu.:0.0000
Median :0.000 Median :0.0000 Median :0.0000
Mean :0.037 Mean :0.0485 Mean :0.1085
3rd Qu.:0.000 3rd Qu.:0.0000 3rd Qu.:0.0000
# Overall quality
head(quality(arules)
# install.packages("arueslViz")
Installing the packages for better visualization
library("arulesViz") # for visualizing rules
Invoking the library
=> plot(arules[1:10], method = "graph") # for good visualization try plotting only few rules
=> Saving the data
write(arules, file = "a_rules.csv", sep = ",")
getwd()
install.packages("arules")
=>Installing the packages
library("arules")
=>Used for building association rules ( apriori algorithm)
=>Loading the data set
phone<-read.csv(file.choose())
inspect(phone[1:5])
Summarizing the data for check min max values
class(phone)
summary(phone)
V1 V2 V3
Length:11 Length:11 Length:11
Class :character Class :character Class :character
Mode :character Mode :character Mode :character
red white green
Min. :0.0000 Min. :0.0000 Min. :0.0000
1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000
Median :1.0000 Median :1.0000 Median :0.0000
Mean :0.5455 Mean :0.6364 Mean :0.1818
3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:0.0000
Max. :1.0000 Max. :1.0000 Max. :1.0000
head(quality(arules))
support confidence coverage lift count
1 1.00000000 1 1.00000000 1.0 11
2 1.00000000 1 1.00000000 1.0 11
3 1.00000000 1 1.00000000 1.0 11
4 1.00000000 1 1.00000000 1.0 11
5 1.00000000 1 1.00000000 1.0 11
6 0.09090909 1 0.09090909 5.5 1
windows()
plot(arules, method = "grouped")
plot(arules[1:5], method = "graph") # for good visualization try plotting only few rules
=>Saving the data
write(arules, file = "a_rules.csv", sep = ",")
getwd()
Movie data set :
install.packages("arules")
inspect(movie[1:10])
class(movie)
Creating data frame
summary(movie)
V1 V2 V3
Length:10 Length:10 Length:10
Class :character Class :character Class :character
Mode :character Mode :character Mode :character
V4 V5 Sixth.Sense
Length:10 Length:10 Min. :0.0
Class :character Class :character 1st Qu.:0.0
Mode :character Mode :character Median :1.0
Mean :0.6
3rd Qu.:1.0
Max. :1.0
Gladiator LOTR1 Harry.Potter1 Patriot
Min. :0.00 Min. :0.0 Min. :0.0 Min. :0.0
1st Qu.:0.25 1st Qu.:0.0 1st Qu.:0.0 1st Qu.:0.0
Median :1.00 Median :0.0 Median :0.0 Median :1.0
Mean :0.70 Mean :0.2 Mean :0.2 Mean :0.6
3rd Qu.:1.00 3rd Qu.:0.0 3rd Qu.:0.0 3rd Qu.:1.0
Max. :1.00 Max. :1.0 Max. :1.0 Max. :1.0
LOTR2 Harry.Potter2 LOTR Braveheart
Min. :0.0 Min. :0.0 Min. :0.0 Min. :0.0
1st Qu.:0.0 1st Qu.:0.0 1st Qu.:0.0 1st Qu.:0.0
Median :0.0 Median :0.0 Median :0.0 Median :0.0
Mean :0.2 Mean :0.1 Mean :0.1 Mean :0.1
3rd Qu.:0.0 3rd Qu.:0.0 3rd Qu.:0.0 3rd Qu.:0.0
Max. :1.0 Max. :1.0 Max. :1.0 Max. :1.0
Green.Mile
Min. :0.0
1st Qu.:0.0
Median :0.0
Mean :0.2
3rd Qu.:0.0
Max. :1.0
Parameter specification:
confidence minval smax arem aval originalSupport maxtime support
0.7 0.1 1 none FALSE TRUE 5 0.004
Minlen maxlen target ext
1 10 rules TRUE
head(quality(arules))
support confidence coverage lift count
1 0.8 0.8 1 1 8
2 0.9 0.9 1 1 9
3 1.0 1.0 1 1 10
4 1.0 1.0 1 1 10
5 1.0 1.0 1 1 10
6 1.0 1.0 1 1 10
plot(arules[1:10], method = "graph") # for good visualization try plotting only few rules
=>Saving the data
write(arules, file = "a_rules.csv", sep = ",")
getwd()
install.packages("arules")
=>Loading the data set
inspect(tr[1:5])
class(tr)
summary(tr)
X.HANGING. X.HEART. X.HOLDER.
Length:557040 Length:557040 Length:557040
Class :character Class :character Class :character
Mode :character Mode :character Mode :character
X.T.LIGHT. X.WHITE. NA.
Length:557040 Length:557040 Length:557040
Class :character Class :character Class :character
Mode :character Mode :character Mode :character
# making rules using apriori algorithm
Apriori
Parameter specification:
confidence minval smax arem aval originalSupport maxtime support
0.7 0.1 1 none FALSE TRUE 5 0.004
Minlen maxlen target ext
1 10 rules TRUE
Absolute minimum support count: 2228
windows()
plot(arules, method = "grouped")
plot(arules[1:5], method = "graph") # for good visualization try plotting only few rules
=>Saving the data
write(arules, file = "a_rules.csv", sep = ",")
getwd()