library(rjson)
jsondata <- '[{"rating1": [126,5]}, {"rating2": [156,3]}, {"rating3": [566,2]}]'
rjsonData <- fromJSON(jsondata)
frame <- as.data.frame(rjsonData)
matrix <- as.matrix(frame)
matrix
movieIds <- matrix[1,]
ratings <- matrix[2,]
numberMovieIds <- length(movieIds)
numberMovieIds
i <- rep.int(1, numberMovieIds)
sparseMatrix <- sparseMatrix(i, movieIds, x = ratings, dims=c(1,8552))
r <- new("realRatingMatrix", data = sparseMatrix)
summary(r)
str(r)
load("data/recommender.rda")
# make a topN prediction for user1 and N = 10
user1topN <- predict(recommender, r, n = 10)
user1topN@items[[1]]
## now get the movie names from movies.csv
movies <- read.csv("small/movies.csv")
## have a look at some data
?subset
subset.data.frame(movies, movieId < 10)
## lets have a quick look at %in%
1 %in% c(1,2)
subset.data.frame(movies, movieId %in% c(1,2))
expression(330 %in% user1topN@items[[1]])
## recommended movies for user1
user1topN@items[[1]]
subset.data.frame(movies, movieId %in% user1topN@items[[1]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.