°øÀ¯ÀÚ·á HOME > ÀÚ·á½Ç > °øÀ¯ÀÚ·á
 
[Á¤º¸±â¼úÈ°¿ë¿¬±¸] ¿¬°üºÐ¼® R ÄÚµå
°ü¸®ÀÚ 16-05-17 09:41 1,525
install.packages("arules")
library(arules)
#Breast Cancer Winconsin dataset:
Dane = read.table("http://www.ipipan.eu/~teisseyrep/TEACHING/DM/DANE/breast-cancer-wisconsin.data",h=T,sep=",")
Dane = Dane[,-1]
#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))