# Prepare the data
cars <- mtcars |>
partition(cyl, vs:gear, .method = "dummy") |>
partition(carb, .method = "crisp", .breaks = c(0, 3, 10)) |>
partition(mpg, disp:qsec, .method = "triangle", .breaks = 3)
# Search for associations
rules <- dig_associations(cars,
antecedent = everything(),
consequent = everything(),
max_length = 3,
min_support = 0.2,
measures = c("lift", "conviction"))
# Cluster the found rules
clu <- cluster_associations(rules, 10, "lift")
if (FALSE) {
# Plot the clustered rules
library(ggplot2)
ggplot(clu) +
aes(x = cluster_label, y = consequent, color = lift, size = support) +
geom_point() +
xlab("predicates in antecedent groups") +
scale_y_discrete(limits = rev) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
}
Run the code above in your browser using DataLab