Predicting & recommending

Once a model has been trained rrecsys may be used to generate either recommendation or predictions.

The prediction method will generate a new rating matrix with estimations on the missing ratings. Let’s predict using two models trained in the previous vignettes:

pSVD <- predict(svd)
pIB <- predict(ibknn)
# Lets compare predicted results for user 1, 4 and 7 on two movies:
pSVD[c(1,4,6), c("Jumanji (1995)", "GoldenEye (1995)")]
##      Jumanji (1995) GoldenEye (1995)
## [1,]      2.6229342        2.9577780
## [2,]      1.2022907        1.3334926
## [3,]      0.7943465        0.8768874
pIB[c(1,4,6), c("Jumanji (1995)", "GoldenEye (1995)")]
##      Jumanji (1995) GoldenEye (1995)
## [1,]       3.013517         3.685114
## [2,]       3.000000         3.289993
## [3,]       3.830333         3.830333

The predict method has a second argument, Round that rounds predicted values to the scale and binds them to the domain of the data set.

The recommend method generates a top-N list for each user:

rSVD <- recommend(svd, topN = 3)
rIB <- recommend(ibknn, topN = 3)
# Let’s compare results on user 3:
rSVD[4]
## [[1]]
## [1] "Pulp Fiction (1994)"                      
## [2] "Star Wars: Episode IV - A New Hope (1977)"
## [3] "Forrest Gump (1994)"
rIB[4]
## [[1]]
## [1] "Star Wars: Episode IV - A New Hope (1977)"            
## [2] "Forrest Gump (1994)"                                  
## [3] "Star Wars: Episode V - The Empire Strikes Back (1980)"

The topN argument specifies the length of the recommended list for each user.