user_item_matrix.Rd
Create the user_item matrix from the given data. We use `adding_row = TRUE` for the user based recommendation to be able to add the user selected data to the table
user_item_matrix( data = anime_with_ratings, adding_row = FALSE, row_data = NULL )
data | data having the user ratings per anime |
---|---|
adding_row | Variable that is either TRUE if you want the matrix for the user-based recommendation or FALSE if you want the matrix for the item-based recommendation |
row_data | table created by the function `user_data()` |
Return a matrix where the x axis include the item_id and the y axis include the user_id. Each line is the score per item per user
Marie Bellier, Massimo Finini, Meri Likoska, Vania Rodrigues Telo Ramos, Xavier Renger
#import datasets from the package anime_with_ratings <- tibble::tibble(ProjectG5::anime_with_ratings) anime <- tibble::tibble(ProjectG5::anime) #creation of the matrix without adding rows x <- user_item_matrix(anime_with_ratings, adding_row = FALSE) #not printed there output would be too long #creation of a table to add rows, userid high on a voluntary basis #selection of the user example names_selected <- c("Death Note", "Naruto") score_entered <- c(10,7) temp_tibble <- tibble::tibble(Name = names_selected, rating = score_entered) anime_selected <- dplyr::left_join(anime, temp_tibble, by = c("Name" = "Name")) anime_selected <- dplyr::filter(anime_selected, Name %in% names_selected) anime_selected <- dplyr::mutate(anime_selected, user_id = 999999999) #creation of the matrix while adding rows z <- user_item_matrix(anime_with_ratings, adding_row = TRUE, row_data = anime_selected) #not printed here, output would be too long