Open gjwgit opened 19 hours ago
#======================================================================= # Rattle timestamp: 2024-10-01 13:38:24.888792 x86_64-pc-linux-gnu # Association Rules # The 'arules' package provides the 'arules' function. library(arules, quietly=TRUE) # Generate a transactions dataset. crs$transactions <- as(crs$dataset[crs$train, crs$categoric], "transactions") # Generate the association rules. crs$apriori <- apriori(crs$transactions, parameter = list(support=0.100, confidence=0.100, minlen=2)) # Summarise the resulting rule set. generateAprioriSummary(crs$apriori) # Time taken: 0.03 secs #======================================================================= # Rattle timestamp: 2024-10-01 13:40:18.248229 x86_64-pc-linux-gnu # Relative Frequencies Plot # Association rules are implemented in the 'arules' package. library(arules, quietly=TRUE) # Generate a transactions dataset. crs$transactions <- as(crs$dataset[crs$train,c(8, 10:11, 22)], "transactions") # Plot the relative frequencies. itemFrequencyPlot(crs$transactions, support=0.1, cex=0.8) # List rules. inspect(sort(crs$apriori, by="support")) # Interesting Measures. interestMeasure(sort(crs$apriori, by="support"), c("chiSquare", "hyperLift", "hyperConfidence", "leverage", "oddsRatio", "phi"), crs$transactions) #======================================================================= # Rattle timestamp: 2024-10-01 13:40:32.252009 x86_64-pc-linux-gnu # Graph of Rules # Use 'arulesViz' to plot a graph representing the rules. library(arulesViz, quietly=TRUE) # Display a graph representing the rules. plot(crs$apriori, method="graph")