-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy path22f-myAR1.R
41 lines (38 loc) · 1.03 KB
/
22f-myAR1.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
# Presentation to Guide
dataar1 = read.csv("./data/dar1.csv")
str(dataar1)
#?write.csv
#write.csv(dataar1,file='dar1w.csv',row.names = F)
dataar1 = dataar1[-7]
library(arules)
str(dataar1)
# change to factors for Association Rule
#dataar1 = lapply(dataar1,function(x) as.factor(x))
rules = apriori(dataar1)
inspect(rules[1:5])
rules
# more than 300 rules generated
# Refining Rules
rhsrule = c('java=Yes','cpp=Yes')
rules = apriori(dataar1, parameter = list(minlen=2,supp=.05,conf=0.8),
list(rhs=rhsrule,default="lhs"), control=list(verbose=F))
rules.sorted = sort(rules,by='lift')
inspect(rules.sorted[1:5])
# Prune Redundant Rules
sum(is.redundant(rules.sorted))
(redundant = which(is.redundant(rules.sorted)))
rulesNR <- rules[-redundant]
inspect(rulesNR[1:5])
length(rulesNR)
# Visualising
library(arulesViz)
plot(rules)
plot.new()
plot(rules,method='graph',control=list(type='items'))
plot(rules,method='paracoord',control=list(reorder=T))
# Using Weka Library ####
#Using Weka
library(RWeka)
library(rattle)
rattle()
Apriori()