包推荐实验室做你想做的(减去显示的信心)。下面是一些代码(改编自 recommenerlab 的文档),它从 Groceries 数据集中学习推荐模型并将其应用于前 10 笔交易:
library(recommenderlab)
data(Groceries)
dat <- as(Groceries, "binaryRatingMatrix")
rec <- Recommender(dat, method = "AR",
parameter=list(support = 0.0005, conf = 0.5, maxlen = 5))
getModel(rec)
$description
[1] "AR: rule base"
$rule_base
set of 38365 rules
$support
[1] 5e-04
$confidence
[1] 0.5
$maxlen
[1] 5
$measure
[1] "confidence"
$verbose
[1] FALSE
$decreasing
[1] TRUE
pred <- predict(rec, dat[1:5,])
as(pred, "list")
[[1]]
[1] "whole milk" "rolls/buns" "tropical fruit"
[[2]]
[1] "whole milk"
[[3]]
character(0)
[[4]]
[1] "yogurt" "whole milk" "cream cheese " "soda"
[[5]]
[1] "whole milk"
以下是您在创建推荐器时可以使用的参数。
recommenderRegistry$get_entry("AR", dataType = "binaryRatingMatrix")
Recommender method: AR
Description: Recommender based on association rules.
Parameters:
support confidence maxlen measure verbose decreasing
1 0.1 0.3 2 confidence FALSE TRUE