Market Basket-analyse in R
Christopher Bruffaerts
Statistician
Regels uit de supermarkt
library(arules)
rules = apriori(data_trx,
parameter = list(
supp = 3/7, conf=0.6, minlen=2)
)
inspect(rules)
Interactieve tabel
library(arulesViz)
inspectDT(rules)
HTML-tabel
Regels inspecteren
inspect(rules)
lhs rhs support confidence lift count
[1] {Bread} => {Butter} 0.4285714 1.0000000 1.1666667 3
[2] {Cheese} => {Wine} 0.4285714 0.7500000 1.0500000 3
[3] {Wine} => {Cheese} 0.4285714 0.6000000 1.0500000 3
[4] {Cheese} => {Butter} 0.4285714 0.7500000 0.8750000 3
[5] {Wine} => {Butter} 0.5714286 0.8000000 0.9333333 4
[6] {Butter} => {Wine} 0.5714286 0.6666667 0.9333333 4
Scatterplot uit arulesViz
plot(rules)

Plotopties
plot(rulesObject, measure, shading, method)
rulesObject: het rules-object om te plottenmeasure: Maten voor regelinteressantheid (support, confidence, lift, ...)shading: Maat voor puntkleuringmethod: Te gebruiken visualisatie ("scatterplot", "matrix", "two-key plot", "matrix3D")Voorbeeld
plot(rules, measure = c("confidence", "lift"),
shading = "support",
method = "scatterplot")

Two-key-plot
plot(rules, method = "two-key plot")

Zonder jitter
plot(rules, method = "two-key plot")

Met jitter
plot(rules, method = "two-key plot",jitter = 2)

Interactieve regels
plot(rules, engine = "plotly")
Van statisch naar interactief

Market Basket-analyse in R