data("Adult")
## Mine rules
rules <- apriori(Adult, parameter = list(support = 0.3))
rules
## Select a subset of rules using partial matching on the items
## in the right-hand-side and a quality measure
rules.sub <- subset(rules, subset = rhs %pin% "sex" & lift > 1.3)
## Display the top 3 support rules
inspect(head(rules.sub, n = 3, by = "support"))
## Display the first 3 rules
inspect(rules.sub[1:3])
## Get labels for the first 3 rules
labels(rules.sub[1:3])
labels(rules.sub[1:3], itemSep = " + ", setStart = "", setEnd="",
ruleSep = " ---> ")
## Manually create rules using the item coding in Adult and calculate some interest measures
twoRules <- rules(
lhs = list(
c("age=Young", "relationship=Unmarried"),
c("age=Old")
),
rhs = list(
c("income=small"),
c("income=large")
),
itemLabels = Adult
)
quality(twoRules) <- interestMeasure(twoRules,
measure = c("support", "confidence", "lift"), transactions = Adult)
inspect(twoRules)
Run the code above in your browser using DataLab