Phân tích giỏ hàng trong R
Christopher Bruffaerts
Statistician
Quy tắc từ Cửa hàng tạp hóa
library(arules)
rules = apriori(data_trx,
parameter = list(
supp = 3/7, conf=0.6, minlen=2)
)
inspect(rules)
Bảng tương tác
library(arulesViz)
inspectDT(rules)
Bảng HTML
Kiểm tra quy tắc
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
Biểu đồ phân tán từ arulesViz
plot(rules)

Tùy chọn của hàm plot
plot(rulesObject, measure, shading, method)
rulesObject: đối tượng quy tắc cần vẽmeasure: thước đo độ thú vị của quy tắc (Support, Confidence, lift,...)shading: thước đo dùng để tô màu điểmmethod: phương pháp trực quan hóa ("scatterplot", "matrix", "two-key plot", "matrix3D")Ví dụ
plot(rules, measure = c("confidence", "lift"),
shading = "support",
method = "scatterplot")

Biểu đồ hai khóa
plot(rules, method = "two-key plot")

Không rung điểm (jitter)
plot(rules, method = "two-key plot")

Có rung điểm (jitter)
plot(rules, method = "two-key plot",jitter = 2)

Quy tắc tương tác
plot(rules, engine = "plotly")
Từ tĩnh sang tương tác

Phân tích giỏ hàng trong R