- First, load the library and dataset:
> library(recommenderlab) > library(ggplot2) > data(MovieLense)
- Next, preprocess the dataset to create a new dataset containing relevant users and movies:
> ratings_movies <- MovieLense[rowCounts(MovieLense) > 50, colCounts(MovieLense)>100] > ratings_movies
There are 560 users and 332 ratings with 560 x 332 dimensional rating matrix of class realRatingMatrix with 55298 ratings.
- Prepare the data for validation using the k-fold approach:
> n_fold <- 4 > items_to_keep <- 15 > rating_threshold <- 3 > eval_sets <- evaluationScheme(data = ratings_movies, method = "cross-validation",k = n_fold, given = items_to_keep, goodRating = rating_threshold)
- Count the number of items that we have ...