install.packages("arules")
library(arules)
#Discretization is necessary:
for(j in 1:ncol(Dane)) Dane[,j] =as.factor(Dane[,j])
# as()´Â ÀÓÀÇÀÇ Å¬¶ó½º·Î º¯°æÇÏ·Á°í ÇÒ ¶§ »ç¿ëÇÏ´Â °Í
Dane1 = as(Dane,"transactions")
# Vizualize data (do not run for large tables!)
image(Dane1)
#Itemsets:
itemFrequencyPlot(Dane1)
#Itemsets with support >=0.1
itemFrequencyPlot(Dane1, support = 0.1, cex.names = 0.8)
#Association rules:
rules <- apriori(Dane1, parameter = list(support = 0.01, confidence = 0.6))
summary(rules)
#Rules with specified rhs.
rulesClassmalignant <- subset(rules, subset = rhs %in% "Class=malignant" & lift > 1.2)
#Sort the results:
inspect(head(sort(rulesClassmalignant, by = "confidence"), n = 3))