compare_rules {RulesTools} | R Documentation |
Compare Association Rule Sets and Find Their Intersections
Description
Compares multiple sets of association rules, identifies intersections, and optionally displays the results or writes them to a CSV file.
Usage
compare_rules(..., display = TRUE, filename = NULL)
Arguments
... |
Named association rule sets (objects of class |
display |
Logical. If |
filename |
Character string. If provided, writes the results to a CSV file. Default is |
Value
A list containing the intersections of the provided rule sets.
Examples
library(arules)
data(BrookTrout)
# Discretize the BrookTrout dataset
discrete_bt <- dtize_df(BrookTrout, cutoff = "mean")
# Generate the first set of rules with a confidence threshold of 0.5
rules1 <- apriori(
discrete_bt,
parameter = list(supp = 0.01, conf = 0.5, target = "rules")
)
# Generate the second set of rules with a higher confidence threshold of 0.6
rules2 <- apriori(
discrete_bt,
parameter = list(supp = 0.01, conf = 0.6, target = "rules")
)
# Compare the two sets of rules and display the intersections
compare_rules(
r1 = rules1,
r2 = rules2,
display = TRUE
)
# If `filename = "intersections.csv"`, the data is saved in a .csv file
[Package RulesTools version 0.1.1 Index]