【发布时间】:2017-07-25 12:23:58
【问题描述】:
我正在尝试测试我使用 recommenderlab 包创建的二进制推荐系统。当我运行 calcPredictionAccuracy 函数时,出现以下错误:
.local(x, data, ...) 中的错误: 您需要指定为预测提供了多少项目! 我进行了多次搜索,似乎找不到任何解决此问题的方法。如果我尝试添加给定的参数,错误将变为:
error.ubcf
快速浏览一下我的代码:
我的数据集是 binary.watch.ratings
affinity.matrix <- as(binary.watch.ratings,"binaryRatingMatrix")
test_index <- evaluationScheme(affinity.matrix[1:1000], method="split",
train=0.9, given=1)
# creation of recommender model based on ubcf
Rec.ubcf <- Recommender(getData(test_index, "train"), "UBCF")
# creation of recommender model based on ibcf for comparison
Rec.ibcf <- Recommender(getData(test_index, "train"), "IBCF")
# making predictions on the test data set
p.ubcf <- predict(Rec.ubcf, getData(test_index, "known"), type="topNList")
# making predictions on the test data set
p.ibcf <- predict(Rec.ibcf, getData(test_index, "known"), type="topNList")
# obtaining the error metrics for both approaches and comparing them
##error occurs with the following two lines
error.ubcf<-calcPredictionAccuracy(p.ubcf, getData(test_index, "unknown"))
error.ibcf<-calcPredictionAccuracy(p.ibcf, getData(test_index, "unknown"))
error <- rbind(error.ubcf,error.ibcf)
rownames(error) <- c("UBCF","IBCF")
这会产生以下错误:
error.ubcf
我的问题是,我必须在代码中的哪一点指定为预测提供多少项?这个问题是否与我的数据是二进制的事实有关?
谢谢
罗伯特
【问题讨论】:
标签: r function recommendation-engine mahout-recommender