user_item_matrix: Score per anime per user

Description Usage Arguments Value Author(s) Examples

View source: R/anime_functions.R

Description

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

Usage

1
2
3
4
5
user_item_matrix(
  data = anime_with_ratings,
  adding_row = FALSE,
  row_data = NULL
)

Arguments

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()'

Value

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

Author(s)

Marie Bellier, Massimo Finini, Meri Likoska, Vania Rodrigues Telo Ramos, Xavier Renger

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#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

ptds2021/project--G5 documentation built on Dec. 22, 2021, 9:59 a.m.