我正在使用recommenderlab来获得来自UBCF和IBCF模型的建议,而且一切看起来都很好(我得到了建议,它们似乎是有意义的)。我想解释为什么会产生每个建议,所以我想了解用户(UBCF)和项目(IBCF)之间的相似之处。
我是IBCF推荐程序,我可以看到这些相似之处存储在推荐结构(aux_recommneder@model$sim)中,但是我不知道如何正确地提取它们,我想选择一个特定的条目,并得到最上面的x个最相似的条目(用于构建推荐),.With,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 )。我需要知道这些东西是什么吗?我如何知道第102项是因为第1项和第250项而被推荐的?我需要相同的用户在UBCF模型。
我会感谢你的帮助。
发布于 2015-07-22 20:06:58
不确定是否为时已晚,但您可以使用以下代码来确定IBCF的相似性:
similarity <- as.matrix(aux_recommender@model$sim)https://stackoverflow.com/questions/27968106
复制相似问题