-
Notifications
You must be signed in to change notification settings - Fork 1
/
assignment6.Rmd
37 lines (31 loc) · 959 Bytes
/
assignment6.Rmd
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
30
31
32
33
34
35
36
37
---
title: "Assignment6_SVD"
output: html_document
---
```{r read items}
items_raw <- read.csv2("./assignment6_items.csv", check.names = F)[,1:17]
feature_weight <- items_raw[1, c(-1,-2)]
items <- items_raw[c(-1,-2), c(-1,-2)]
movie_ids <- items_raw[c(-1,-2), 1]
movie_names <- items_raw[c(-1,-2), 2]
rownames(items) <- movie_ids
feature <- diag(feature_weight)
movie_ids[order(items[,1], decreasing=T)[1:5]]
movie_ids[order(items[,2], decreasing=T)[1:5]]
```
```{r read users}
users_raw <- read.csv2("./assignment6_users.csv", check.names = F)[,1:16]
user_names <- users_raw[,1]
users <- users_raw[,-1]
rownames(users) <- user_names
```
top 5 movies for user 4469
Movie score: s_ui = SUM_f a_uf sigma_f b_if
s_ui =
sigma_f = singular value feature f
a_uf = user weight for feature f
b_if = item weight for feature f
```{r}
movie_user <- as.matrix(items) %*% as.matrix(feature) %*% t(users)
movie_ids[order(movie_user[,"4469"], decreasing=T)][1:5]
```