if (FALSE) {
library(ggplot2)
# Prepare data by partitioning numeric columns into fuzzy or crisp sets
part <- partition(iris, .breaks = 3)
# Find all antecedents with "Sepal" for rules with consequent "Species=setosa"
rules <- dig_associations(part,
antecedent = starts_with("Sepal"),
consequent = `Species=setosa`,
min_length = 0,
max_length = Inf,
min_coverage = 0,
min_support = 0,
min_confidence = 0,
measures = c("lift", "conviction"),
max_results = Inf)
# Add abbreviated labels for readability
rules$abbrev <- shorten_condition(rules$antecedent)
# Plot the lattice of rules as a diamond diagram
ggplot(rules) +
aes(condition = antecedent,
fill = confidence,
linewidth = confidence,
size = coverage,
label = abbrev) +
geom_diamond()
}
Run the code above in your browser using DataLab