R包'推荐器'的预测函数输出错误?

时间:2014-05-18 15:45:28

标签: r recommendation-engine collaborative-filtering

我需要根据Yelp数据库制作推荐人,我已经过滤了商家评论和用户,并为各个商家创建了一个realRatingMatrix用户评分。即使矩阵是巨大的,我也只是先使用一个非常小的矩阵(mdat矩阵)进行测试。

#learning matrix
learningM <- as(mdat[1:8,],"realRatingMatrix")

# matrix to predict user recommendations
testM <- as(mdat[9:10,],"realRatingMatrix")

#using the learning matrix to create a UBCF recommender
rec <- Recommender(learningM, method = "UBCF")

#function that should output 2 business recommendations to users of testM
pre <- predict(rec, testM, n=2)

相反,我会收到这样的输出:

> as(pre,"list")
[[1]]
character(0)

[[2]]
character(0)

为什么我得到这个输出? predict函数是否计算出错误的结果,从而提供错误的输出,或者我的业务列名称是不同的文本类型,因此他无法正确输出?

根据要求修改:mdat矩阵,抱歉没有把它放在第一位。

> dput(mdat)
structure(c(1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 4, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 5, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, 4, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, 4, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
3, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 5, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, 5), .Dim = c(10L, 10L), .Dimnames = list(
c("jqhP9mV2rYvmPdKvlOfp0g", "tqkkmL2NB19Sxeg1AaXnSA", "cNMJxBzmXA9N7krLvlrzlA", 
"9v3uIUTitC043Y4Qs54K1g", "nLUwyI34R-cAHLnmEGeLIg", "6SUSTwhfSFva9nbIDmoN7Q", 
"iCppbv3C7XvCyzIZnNQ7fg", "MUo7TLgR7sy1ob0MvxyPHQ", "GMVQyHMHNGplG3aof8jMcA", 
"VNGevHJuTxcou-Nhm8Q5RQ"), c("iZYDZvXoIT648EZOnEP0pQ", "HQJjHA6BRcRD0vR5askdkQ", 
"bul_5Ahk_QYLUAJ4Od27jg", "EOoj2h1Brzk1AhqScvIHDA", "roEQNfyPi3jRv3WFFr-f_g", 
"ffp58kYSK7dJGs5ER-5txw", "pvlM--HZY1a8SqMXiwEz1A", "mta3FuoNzjjGWQr9TCHGhA", 
"QeK3lOP-CTZS72YgeXiiqA", "57VozB9tq5SbNst9nO-jxA")))

1 个答案:

答案 0 :(得分:1)

As explained by the vignette, recommenderlab正试图解决稀疏矩阵回归问题。但是,如果来自新用户的测试推荐集不是与训练集相同的空间值集,则对于具有旧用户的新用户,不能构建任何类型的相似性度量。该算法需要找到一些与新用户评级相同项目的旧用户,然后才能从其他旧用户评级中提供更多项目。

简单的群体推荐不需要找到与新用户分享评分的任何评分子集。