Recommendationerlab软件包中的R“ HybridRecommender”无法预测“ binaryRatingMatrix”

时间:2019-04-04 03:24:33

标签: r recommenderlab

我正在尝试在“ binaryRatingMatrix”类型数据上应用“ HybridRecommender”,但是在尝试预测“ topNList”时出现错误。

我当前在Windows机器上运行带有推荐器版本0.2-2的R-64bit(版本3.4.4)

下面是示例数据集

m <- matrix(sample(c(0,1), 50, replace=TRUE), nrow=5, ncol=10,
            dimnames=list(users=paste("u", 1:5, sep=''),
                           items=paste("i", 1:10, sep='')))

将矩阵转换为binaryRatingMatrix

b <- as(m, "binaryRatingMatrix")

计算HybridRecommender

system.time(
     recom <- recommenderlab::HybridRecommender(
         Recommender(b, method = "AR"),
         Recommender(b, method = "IBCF"),
         Recommender(b, method = "POPULAR"),
         Recommender(b, method = "UBCF"),
         weights = c(.25, .25, .25, .25))
)

计算预测的推荐项目“ topNList”(有错误)

as(predict(recom, 1, newdata = b, type = "topNList", n = 10), "list")

Error in match.arg(type) : 'arg' should be one of “topNList”

我的预期结果将与以下相同,我尝试在单个推荐程序上运行,并且效果很好

r <- Recommender(b, method = "AR")
as(predict(r, 1, newdata = b, type = "topNList", n = 10), "list")

$u1
character(0)

$u2
[1] "i10" "i2"  "i5"  "i6"  "i9"  "i8" 

$u3
[1] "i4" "i6" "i9" "i8" "i3"

$u4
[1] "i9" "i8"

$u5
[1] "i7"  "i3"  "i2"  "i10" "i4"  "i5"  "i6"  "i1"

新编辑:在“ realRatingMatrix”上尝试了“ HybridRecommender”,它可以正常工作

data(Jester5k)

class(Jester5k)
[1] "realRatingMatrix"
attr(,"package")
[1] "recommenderlab"

system.time(
  recom <- HybridRecommender(
      Recommender(Jester5k, method = "POPULAR"),
      Recommender(Jester5k, method = "IBCF"),
      Recommender(Jester5k, method = "SVDF"),
      Recommender(Jester5k, method = "UBCF"),
      weights = c(.25, .25, .25, .25))
)

getList(predict(recom, 1:5, Jester5k, n = 5))

[[1]]
[1] "j84" "j85" "j83" "j82" "j81"

[[2]]
[1] "j89" "j93" "j76" "j81" "j88"

[[3]]
character(0)

[[4]]
character(0)

[[5]]
[1] "j80"  "j81"  "j100" "j72"  "j89" 

问题:我很好奇为什么为什么预测无法在“ HybridRecommender”上运行,而同时在单个“ Recommender”和“ realRatingMatrix”上运行呢?任何意见和帮助表示赞赏。谢谢!

1 个答案:

答案 0 :(得分:0)

是一个错误,最新的开发版本(0.2-4.1版)已解决了该问题,最新版本已在Github上提供。请检查详细信息Here