rules2groupedMatrix | R Documentation |
Converts a set of association rules into a matrix with unique LHS itemsets as columns and unique RHS itemsets as rows. The matrix cells contain a quality measure. The LHS itemsets can be grouped.
rules2groupedMatrix(
rules,
measure = "lift",
measure2 = "support",
k = 10,
aggr.fun = mean,
lhs_label_items = 2
)
rules2matrix(rules, measure = "support", reorder = "measure", ...)
rules |
a rules object. |
measure |
quality measure put in the matrix |
measure2 |
second quality measure (organized in the same way as measure). |
k |
number of LHS itemset groups. |
aggr.fun |
function to aggregate the quality measure for groups. |
lhs_label_items |
number of top items used to name LHS itemset groups (columns). |
reorder |
reorder rows and columns? Possible methods are: "none", "measure" (default), "support/confidence", "similarity". |
... |
passed on to |
rules2matrix
returns a matrix with quality values.
rules2groupedMatrix
returns a list with elements
m |
the grouped matrix for measure. |
m2 |
the grouped matrix for measure2. |
clustering_rules |
vector with group assignment for each rule. |
Michael Hahsler
Michael Hahsler and Radoslaw Karpienko. Visualizing association rules in hierarchical groups. Journal of Business Economics, 87(3):317–335, May 2016. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s11573-016-0822-8")}.
plot()
for rules using method = 'matrix'
and
method = 'grouped matrix'
.
data(Groceries)
rules <- apriori(Groceries, parameter = list(support = 0.001, confidence = 0.8))
rules
## Matrix
m <- rules2matrix(rules[1:10], measure = "lift")
m
plot(rules[1:10], method = "matrix")
## Grouped matrix
# create a matrix with LHSs grouped in k = 10 groups
gm <- rules2groupedMatrix(rules, k = 10)
gm$m
# number of rules per group
table(gm$clustering_rules)
# get rules for group 1
inspect(rules[gm$clustering_rules == 1])
# create the corresponding grouped matrix plot by passing the grouped matrix as the groups parameter
plot(rules, method = "grouped matrix", groups = gm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.