【发布时间】:2015-01-15 16:23:59
【问题描述】:
我正在使用推荐实验室从 UBCF 和 IBCF 模型中获取推荐,并且一切似乎都运行良好(我得到了推荐,它们似乎很有意义)。我想解释为什么要生成每个推荐,因此我想了解用户之间 (UBCF) 和项目之间 (IBCF) 之间的相似性。
我是 IBCF 推荐者,我可以看到相似之处存储在推荐者结构中 (aux_recommneder@model$sim),但我不知道如何正确提取它们。我想选择一个特定项目并获得顶部 x最相似的项目(用于构建推荐)。通过 UBCF,我想选择一个特定的用户并让他们获得最相似的用户。
我的 IBCF 推荐结构如下:
> str(aux_recommender)
Formal class 'Recommender' [package "recommenderlab"] with 5 slots
..@ method : chr "IBCF"
..@ dataType: atomic [1:1] realRatingMatrix
.. ..- attr(*, "package")= chr "recommenderlab"
..@ ntrain : int 7106
..@ model :List of 9
.. ..$ description : chr "IBCF: Reduced similarity matrix"
.. ..$ sim :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..@ i : int [1:2644] 12 105 649 705 1207 1282 555 62 365 485 ...
.. .. .. ..@ p : int [1:1323] 0 6 6 7 7 7 7 12 13 13 ...
.. .. .. ..@ Dim : int [1:2] 1322 1322
.. .. .. ..@ Dimnames:List of 2
.. .. .. .. ..$ : chr [1:1322] "1" "19" "22" "41" ...
.. .. .. .. ..$ : chr [1:1322] "1" "19" "22" "41" ...
.. .. .. ..@ x : num [1:2644] 0.71 0.766 0.834 0.663 0.919 ...
.. .. .. ..@ factors : list()
.. ..$ k : num 2
.. ..$ method : chr "Pearson"
.. ..$ normalize : chr "Z-score"
.. ..$ normalize_sim_matrix: logi FALSE
.. ..$ alpha : num 0.5
.. ..$ na_as_zero : logi FALSE
.. ..$ minRating : num 2
..@ predict :function (model, newdata, n = 10, data = NULL, type = c("topNList", ratings"), ...)
在我的 UBCF 中,我什至无法发现相似之处的存储位置(如果有的话)。
我的 UBCF 结构是:
> str(rec_ub)
Formal class 'Recommender' [package "recommenderlab"] with 5 slots
..@ method : chr "UBCF"
..@ dataType: atomic [1:1] realRatingMatrix
.. ..- attr(*, "package")= chr "recommenderlab"
..@ ntrain : int 7106
..@ model :List of 7
.. ..$ description: chr "UBCF-Real data: contains full or sample of data set"
.. ..$ data :Formal class 'realRatingMatrix' [package "recommenderlab"] with 2 slots
.. .. .. ..@ data :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. .. .. ..@ i : int [1:2103234] 0 1 2 3 4 5 6 7 8 9 ...
.. .. .. .. .. ..@ p : int [1:1323] 0 6908 8602 9037 9546 14311 17869 18006 23693 24432 ...
.. .. .. .. .. ..@ Dim : int [1:2] 7106 1322
.. .. .. .. .. ..@ Dimnames:List of 2
.. .. .. .. .. .. ..$ : chr [1:7106] "10034" "10042" "10048" "10069" ...
.. .. .. .. .. .. ..$ : chr [1:1322] "1" "19" "22" "41" ...
.. .. .. .. .. ..@ x : num [1:2103234] -0.371 0.465 -0.174 0.188 0.27 ...
.. .. .. .. .. ..@ factors : list()
.. .. .. ..@ normalize:List of 3
.. .. .. .. ..$ method : chr "Z-score"
.. .. .. .. ..$ row : logi TRUE
.. .. .. .. ..$ factors:List of 2
.. .. .. .. .. ..$ means: Named num [1:7106] 2.48 1.57 2.2 1.82 2.63 ...
.. .. .. .. .. .. ..- attr(*, "names")= chr [1:7106] "10034" "10042" "10048" "10069" ...
.. .. .. .. .. ..$ sds : Named num [1:7106] 1.287 0.928 1.134 0.934 1.377 ...
.. .. .. .. .. .. ..- attr(*, "names")= chr [1:7106] "10034" "10042" "10048" "10069" ...
.. ..$ method : chr "Pearson"
.. ..$ nn : num 2
.. ..$ sample : logi FALSE
.. ..$ normalize : chr "Z-score"
.. ..$ minRating : num 2
..@ predict :function (model, newdata, n = 10, data = NULL, type = c("topNList", "ratings"), ...)
我需要知道的是为什么,例如,项目 102 被推荐给用户 10034。在 IBCF 中应该是因为项目 102 与用户高度评价的其他项目相似(例如项目 1 和 250如果我们正在考虑 2 个社区)。我需要知道这些物品是什么吗?我怎么知道第 102 项是因为第 1 项和第 250 项而被推荐的?对于 UBCF 模型中的用户,我需要相同的内容。
我将不胜感激。
【问题讨论】:
标签: r matrix sparse-matrix recommendation-engine