recommenderlab 包中的 R "HybridRecommender" 无法预测 "binaryRatingMatrix"
R "HybridRecommender" in recommenderlab package unable to predict "binaryRatingMatrix"
我正在尝试将 "HybridRecommender" 应用于 "binaryRatingMatrix" 类型的数据,但在尝试预测 "topNList".
时出现错误
我当前 运行ning R-64 位(版本 3.4.4)在 windows 机器上,recommenderlab 版本 0.2-2
下面是示例数据集
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" 上工作?任何评论和帮助表示赞赏。谢谢!
是最新开发版本(版本 0.2-4.1)上的错误和问题,当前可在 Github 上使用。请查看详情Here
我正在尝试将 "HybridRecommender" 应用于 "binaryRatingMatrix" 类型的数据,但在尝试预测 "topNList".
时出现错误我当前 运行ning R-64 位(版本 3.4.4)在 windows 机器上,recommenderlab 版本 0.2-2
下面是示例数据集
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" 上工作?任何评论和帮助表示赞赏。谢谢!
是最新开发版本(版本 0.2-4.1)上的错误和问题,当前可在 Github 上使用。请查看详情Here