-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharules.R
158 lines (107 loc) · 4.9 KB
/
arules.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
### R code from vignette source 'arulesViz.Rnw'
###################################################
### code chunk number 1: arulesViz.Rnw:75-76
###################################################
options(width = 75)
###################################################
### code chunk number 2: arulesViz.Rnw:236-238
###################################################
options(digits = 2)
set.seed(1234)
###################################################
### code chunk number 3: arulesViz.Rnw:248-250
###################################################
library("arulesViz")
data("Groceries")
###################################################
### code chunk number 4: arulesViz.Rnw:260-261
###################################################
summary(Groceries)
###################################################
### code chunk number 5: arulesViz.Rnw:267-269
###################################################
rules <- apriori(Groceries, parameter=list(support=0.001, confidence=0.5))
rules
###################################################
### code chunk number 6: arulesViz.Rnw:277-278
###################################################
inspect(head(rules, n = 3, by ="lift"))
###################################################
### code chunk number 7: arulesViz.Rnw:288-289
###################################################
args(getS3method("plot", "rules"))
###################################################
### code chunk number 8: scatterplot1
###################################################
plot(rules)
###################################################
### code chunk number 9: arulesViz.Rnw:347-348
###################################################
head(quality(rules))
###################################################
### code chunk number 10: scatterplot2
###################################################
plot(rules, measure = c("support", "lift"), shading = "confidence")
###################################################
### code chunk number 11: scatterplot3
###################################################
plot(rules, method = "two-key plot")
###################################################
### code chunk number 12: arulesViz.Rnw:402-404 (eval = FALSE)
###################################################
## sel <- plot(rules, measure=c("support", "lift"), shading = "confidence",
## interactive = TRUE)
###################################################
### code chunk number 13: arulesViz.Rnw:481-483
###################################################
subrules <- rules[quality(rules)$confidence > 0.8]
subrules
###################################################
### code chunk number 14: matrix1
###################################################
plot(subrules, method = "matrix", measure = "lift")
###################################################
### code chunk number 15: matrix3D1
###################################################
plot(subrules, method = "matrix", engine = "3d", measure = "lift")
###################################################
### code chunk number 16: clusterplot1
###################################################
plot(rules, method = "grouped")
###################################################
### code chunk number 17: clusterplot2
###################################################
plot(rules, method = "grouped", control = list(k = 50))
###################################################
### code chunk number 18: arulesViz.Rnw:744-745 (eval = FALSE)
###################################################
## sel <- plot(rules, method = "grouped", interactive = TRUE)
###################################################
### code chunk number 19: arulesViz.Rnw:768-769
###################################################
subrules2 <- head(rules, n = 10, by = "lift")
###################################################
### code chunk number 20: graph1
###################################################
plot(subrules2, method = "graph")
###################################################
### code chunk number 21: arulesViz.Rnw:813-814 (eval = FALSE)
###################################################
## saveAsGraph(head(rules, n = 1000, by = "lift"), file = "rules.graphml")
###################################################
### code chunk number 22: pc1
###################################################
plot(subrules2, method = "paracoord")
###################################################
### code chunk number 23: pc2
###################################################
plot(subrules2, method = "paracoord", control = list(reorder = TRUE))
###################################################
### code chunk number 24: arulesViz.Rnw:913-915
###################################################
oneRule <- sample(rules, 1)
inspect(oneRule)
###################################################
### code chunk number 25: doubledecker1
###################################################
plot(oneRule, method = "doubledecker", data = Groceries)