0

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

我目前正在使用推荐实验室版本 0.2-2 的 Windows 机器上运行 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")

计算混合推荐器

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”上工作?任何评论和帮助表示赞赏。谢谢!

4

1 回答 1

0

是一个错误,问题在最新开发版本(版本 0.2-4.1)上已解决,目前在 Github 上可用。请在此处查看详细信息

于 2019-04-07T01:28:47.960 回答