inst/createModel.R

library(recommenderlab)
library(reshape2)

ratings <- read.csv("inst/ratings.csv")
movies <- read.csv("inst/movies.csv")
movieIds <- movies$movieId

# remove timestamp column
ratings <- ratings[,-c(4)]

# convert to realRatingsMatrix -- userId X movieId
ratingMatrix <- acast(ratings, userId ~ movieId)
realRatingMatrix <- as(ratingMatrix, "realRatingMatrix")
exampleRRMrow <- realRatingMatrix[1]


# build the model
recommender = Recommender(
  realRatingMatrix[1:nrow(realRatingMatrix)], method = "UBCF",
  param = list(
    normalize = "Z-score", method = "Cosine",nn = 5, minRating = 1
  )
)

save(recommender, file="data/recommender.rda")
# probably not needed
# save(movieIds, file="data/movieIds.rda")
paulij/recommendMovies documentation built on May 24, 2017, 1:40 a.m.