り 譬 伎..R襦 蟾 覓 襴. SSAS data mining朱 伎 蟆.
http://prdeepakbabu.wordpress.com/2010/11/13/market-basket-analysisassociation-rule-mining-using-r-package-arules/
transaction.csv
===========
1001,Choclates
1001,Pencil
1001,Marker
1002,Pencil
1002,Choclates
1003,Pencil
1003,Coke
1003,Eraser
1004,Pencil
1004,Choclates
1004,Cookies
1005,Marker
1006,Pencil
1006,Marker
1007,Pencil
1007,Choclates
#install.packages("arules")
library("arules")
tr = read.transactions(file="c:\\rdata\\transaction.csv", rm.duplicates= FALSE, format="single",sep="," ,cols =c(1,2));
basket_rules <- apriori(tr,parameter = list(sup = 0.5, conf = 0.9,target="rules"))
inspect(basket_rules)
rules.sorted <- sort(basket_rules, by="lift")
inspect(rules.sorted)
#install.packages("arulesViz")
library(arulesViz)
plot(basket_rules)
plot(basket_rules, method="graph", control=list(type="items"))
plot(basket_rules, method="paracoord", control=list(reorder=TRUE))
r <- sqlQuery(conn, "
select tid, items
from trnsaction_table
")
r.u <- unique(r)
head(r.u)
r.u <- sapply(r.u, unique)
names(r.u) <- paste("Tr", 1:length(r.u), sep="")
str(r.u)
ru.tr <- as(r.u, "transactions")
rules <- apriori(ru.tr,
parameter = list(supp = 0.5, conf = 0.9,
target = "rules"))