Matrix Factorization and Collaborative Filtering MF Readings: - - PowerPoint PPT Presentation

matrix factorization and collaborative filtering
SMART_READER_LITE
LIVE PREVIEW

Matrix Factorization and Collaborative Filtering MF Readings: - - PowerPoint PPT Presentation

10-601 Introduction to Machine Learning Machine Learning Department School of Computer Science Carnegie Mellon University Matrix Factorization and Collaborative Filtering MF Readings: Matt Gormley (Koren


slide-1
SLIDE 1

Matrix ¡Factorization and Collaborative ¡Filtering

1

10-­‑601 ¡Introduction ¡to ¡Machine ¡Learning

Matt ¡Gormley Lecture ¡25 April ¡19, ¡2017

Machine ¡Learning ¡Department School ¡of ¡Computer ¡Science Carnegie ¡Mellon ¡University MF ¡Readings: (Koren et ¡al., ¡2009)

slide-2
SLIDE 2

Reminders

  • Homework 8: ¡Graphical Models

– Release: ¡Mon, ¡Apr. ¡17 – Due: ¡Mon, ¡Apr. ¡24 ¡at ¡11:59pm

  • Homework 9: ¡Applications of ¡ML

– Release: ¡Mon, ¡Apr. ¡24 – Due: ¡Wed, ¡May 3 ¡at ¡11:59pm

2

slide-3
SLIDE 3

Outline

  • Recommender ¡Systems

– Content ¡Filtering – Collaborative ¡Filtering ¡(CF) – CF: ¡Neighborhood ¡Methods – CF: ¡Latent ¡Factor ¡Methods

  • Matrix ¡Factorization

– Background: ¡Low-­‑rank ¡Factorizations – Residual ¡matrix – Unconstrained ¡Matrix ¡Factorization

  • Optimization ¡problem
  • Gradient ¡Descent, ¡SGD, ¡Alternating ¡Least ¡Squares
  • User/item ¡bias ¡terms ¡(matrix ¡trick)

– Singular ¡Value ¡Decomposition ¡(SVD) – Non-­‑negative ¡Matrix ¡Factorization

  • Extra: ¡Matrix ¡Multiplication ¡in ¡ML

– Matrix ¡Factorization – Linear ¡Regression – PCA – (Autoencoders) – K-­‑means

7

slide-4
SLIDE 4

RECOMMENDER ¡SYSTEMS

8

slide-5
SLIDE 5

Recommender ¡Systems

A ¡Common ¡Challenge:

– Assume ¡you’re ¡a ¡company ¡ selling ¡items of ¡some ¡sort: ¡ movies, ¡songs, ¡products, ¡ etc. – Company ¡collects ¡millions ¡

  • f ¡ratings from ¡users of ¡

their ¡items – To ¡maximize ¡profit ¡/ ¡user ¡ happiness, ¡you ¡want ¡to ¡ recommend items ¡that ¡ users ¡are ¡likely ¡to ¡want

9

slide-6
SLIDE 6

Recommender ¡Systems

10

slide-7
SLIDE 7

Recommender ¡Systems

11

slide-8
SLIDE 8

Recommender ¡Systems

12

slide-9
SLIDE 9

Recommender ¡Systems

13

Problem ¡Setup

  • 500,000 ¡users
  • 20,000 ¡movies
  • 100 ¡million ¡ratings
  • Goal: ¡To ¡obtain ¡lower ¡root ¡mean ¡squared ¡error ¡

(RMSE) ¡than ¡Netflix’s ¡existing ¡system ¡on ¡3 ¡million ¡ held ¡out ¡ratings ¡

slide-10
SLIDE 10

Recommender ¡Systems

14

slide-11
SLIDE 11

Recommender ¡Systems

  • Setup:

– Items: ¡ movies, ¡songs, ¡products, ¡etc. (often ¡many ¡thousands) – Users: ¡ watchers, ¡listeners, ¡purchasers, ¡etc. (often ¡many ¡millions) – Feedback: ¡ 5-­‑star ¡ratings, ¡not-­‑clicking ¡‘next’, ¡ purchases, ¡etc.

  • Key ¡Assumptions:

– Can ¡represent ¡ratings ¡numerically ¡ as ¡a ¡user/item ¡matrix – Users ¡only ¡rate ¡a ¡small ¡number ¡of ¡ items ¡(the ¡matrix ¡is ¡sparse)

15

Doctor ¡ Strange Star ¡Trek: ¡ Beyond Zootopia Alice 1 5 Bob 3 4 Charlie 3 5 2

slide-12
SLIDE 12

Recommender ¡Systems

16

slide-13
SLIDE 13

Two ¡Types ¡of ¡Recommender ¡Systems

Content ¡Filtering

  • Example: ¡Pandora.com

music ¡recommendations ¡ (Music ¡Genome ¡Project)

  • Con: Assumes ¡access ¡to ¡

side ¡information ¡about ¡ items ¡(e.g. ¡properties ¡of ¡a ¡ song)

  • Pro: ¡Got ¡a ¡new ¡item ¡to ¡

add? ¡No ¡problem, ¡just ¡be ¡ sure ¡to ¡include ¡the ¡side ¡ information Collaborative ¡Filtering

  • Example: ¡Netflix movie ¡

recommendations

  • Pro: ¡Does ¡not ¡assume ¡

access ¡to ¡side ¡information ¡ about ¡items ¡(e.g. ¡does ¡not ¡ need ¡to ¡know ¡about ¡movie ¡ genres)

  • Con: ¡Does ¡not work ¡on ¡

new ¡items ¡that ¡have ¡no ¡ ratings

17

slide-14
SLIDE 14

COLLABORATIVE ¡FILTERING

19

slide-15
SLIDE 15

Collaborative ¡Filtering

  • Everyday ¡Examples ¡of ¡Collaborative ¡Filtering...

– Bestseller ¡lists – Top ¡40 ¡music ¡lists – The ¡“recent ¡returns” ¡shelf ¡at ¡the ¡library – Unmarked ¡but ¡well-­‑used ¡paths ¡thru ¡the ¡woods – The ¡printer ¡room ¡at ¡work – “Read ¡any ¡good ¡books ¡lately?” – …

  • Common ¡insight: ¡personal ¡tastes ¡are ¡correlated

– If ¡Alice ¡and ¡Bob ¡both ¡like ¡X ¡and ¡Alice ¡likes ¡Y ¡then ¡ Bob ¡is ¡more ¡likely ¡to ¡like ¡Y – especially ¡(perhaps) ¡if ¡Bob ¡knows ¡Alice

20

Slide ¡from ¡William ¡Cohen

slide-16
SLIDE 16

Two ¡Types ¡of ¡Collaborative ¡Filtering

  • 1. ¡Neighborhood ¡Methods
  • 2. ¡Latent ¡Factor ¡Methods

21

Figures ¡from ¡Koren et ¡al. ¡(2009)

slide-17
SLIDE 17

Two ¡Types ¡of ¡Collaborative ¡Filtering

  • 1. ¡Neighborhood ¡Methods

22

In ¡the ¡figure, ¡assume ¡that ¡ a ¡green ¡line ¡indicates ¡the ¡ movie ¡was ¡watched Algorithm: 1. Find neighbors based ¡

  • n ¡similarity ¡of ¡movie ¡

preferences

  • 2. Recommend movies ¡

that ¡those ¡neighbors ¡ watched

Figures ¡from ¡Koren et ¡al. ¡(2009)

slide-18
SLIDE 18

Two ¡Types ¡of ¡Collaborative ¡Filtering

  • 2. ¡Latent ¡Factor ¡Methods

23

Figures ¡from ¡Koren et ¡al. ¡(2009)

  • Assume ¡that ¡both ¡

movies ¡and ¡users ¡ live ¡in ¡some ¡low-­‑ dimensional ¡ space ¡describing ¡ their ¡properties

  • Recommend a ¡

movie ¡based ¡on ¡ its ¡proximity to ¡ the ¡user ¡in ¡the ¡ latent ¡space

slide-19
SLIDE 19

MATRIX ¡FACTORIZATION

24

slide-20
SLIDE 20

Matrix ¡Factorization

  • Many ¡different ¡ways ¡of ¡factorizing ¡a ¡matrix
  • We’ll ¡consider ¡three:

1. Unconstrained ¡Matrix ¡Factorization 2. Singular ¡Value ¡Decomposition 3. Non-­‑negative ¡Matrix ¡Factorization

  • MF ¡is ¡just ¡another ¡example ¡of ¡a ¡common ¡

recipe:

1. define ¡a ¡model 2. define ¡an ¡objective ¡function 3.

  • ptimize ¡with ¡SGD

25

slide-21
SLIDE 21

Matrix ¡Factorization

Whiteboard

– Background: ¡Low-­‑rank ¡Factorizations – Residual ¡matrix

27

slide-22
SLIDE 22

Example: ¡MF ¡for ¡Netflix ¡Problem

28

Figures ¡from ¡Aggarwal ¡(2016)

ATTLE N O US CAESAR OPA TRA PLESS IN SEA TTY WOMAN ABLANCA NERO JULIU CLEO SLEEP PRET CASA 1 BOTH HISTORY 1 2 3 4 ROMANCE 1 1 1 5 6 1

R

7

(b) Residual matrix 1 2 3 4 5 6 7 HISTORY ROMANCE

X

HISTORY ROMANCE ROMANCE BOTH HISTORY 1 1 1 1 1 1 1 1 1

  • 1
  • 1
  • 1
  • 1
  • 1
  • 1 - 1 - 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 NERO JULIUS CAESAR CLEOPA TRA SLEEPLESS IN SEA TTLE PRETTY WOMAN CASABLANCA

R U VT

NERO JULIUS CAESAR CLEOPA TRA SLEEPLESS IN SEA TTLE PRETTY WOMAN CASABLANCA

  • 1
  • 1
  • 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 6 7 5 4 3 2 1 E

(a) Example of rank-2 matrix factorization

slide-23
SLIDE 23

Regression ¡vs. ¡Collaborative ¡Filtering

29 TRAINING ROWS TEST ROWS INDEPENDENT VARIABLES DEPENDENT VARIABLE NO DEMARCATION BETWEEN TRAINING AND TEST ROWS NO DEMARCATION BETWEEN DEPENDENT AND INDEPENDENT VARIABLES

Figures ¡from ¡Aggarwal ¡(2016)

Regression Collaborative ¡Filtering

slide-24
SLIDE 24

UNCONSTRAINED ¡MATRIX ¡ FACTORIZATION

30

slide-25
SLIDE 25

Unconstrained ¡Matrix ¡Factorization

Whiteboard

– Optimization ¡problem – SGD – SGD ¡with ¡Regularization – Alternating ¡Least ¡Squares – User/item ¡bias ¡terms ¡(matrix ¡trick)

31

slide-26
SLIDE 26

Unconstrained ¡Matrix ¡Factorization

In-­‑Class ¡Exercise Derive ¡a ¡block ¡coordinate ¡descent ¡algorithm ¡ for ¡the ¡Unconstrained ¡Matrix ¡Factorization ¡ problem.

32

  • User ¡vectors:
  • Item ¡vectors:
  • Rating ¡prediction:

u ∈ Rr i ∈ Rr vui = T

u i

  • Set ¡of ¡non-­‑missing ¡entries:
  • Objective:
  • ,
  • (u,i)∈Z

(vui − T

u i)2

slide-27
SLIDE 27

Matrix ¡Factorization

  • User ¡vectors:
  • Item ¡vectors:
  • Rating ¡prediction:

33

Figures ¡from ¡Koren et ¡al. ¡(2009)

H∗i ∈ Rr (Wu∗)T ∈ Rr

Figures ¡from ¡Gemulla et ¡al. ¡(2011)

Vui = Wu∗H∗i = [WH]ui

(with ¡matrices)

slide-28
SLIDE 28
  • User ¡vectors:
  • Item ¡vectors:
  • Rating ¡prediction:

Matrix ¡Factorization

(with ¡vectors)

34

Figures ¡from ¡Koren et ¡al. ¡(2009)

u ∈ Rr i ∈ Rr vui = T

u i

slide-29
SLIDE 29

Matrix ¡Factorization

  • Set ¡of ¡non-­‑missing ¡entries:
  • Objective:

35

Figures ¡from ¡Koren et ¡al. ¡(2009)

  • ,
  • (u,i)∈Z

(vui − T

u i)2

(with ¡vectors)

slide-30
SLIDE 30

Matrix ¡Factorization

  • Regularized ¡Objective:
  • SGD ¡update ¡for ¡random ¡(u,i):

36

Figures ¡from ¡Koren et ¡al. ¡(2009)

(with ¡vectors)

  • ,
  • (u,i)∈Z

(vui − T

u i)2

+ λ(

  • i

||i||2 +

  • u

||u||2)

slide-31
SLIDE 31

Matrix ¡Factorization

  • Regularized ¡Objective:
  • SGD ¡update ¡for ¡random ¡(u,i):

37

Figures ¡from ¡Koren et ¡al. ¡(2009)

(with ¡vectors)

eui ← vui − T

u i

u ← u + γ(euii − λu) i ← i + γ(euiu − λi)

  • ,
  • (u,i)∈Z

(vui − T

u i)2

+ λ(

  • i

||i||2 +

  • u

||u||2)

slide-32
SLIDE 32

Matrix ¡Factorization

  • User ¡vectors:
  • Item ¡vectors:
  • Rating ¡prediction:

38

Figures ¡from ¡Koren et ¡al. ¡(2009)

H∗i ∈ Rr (Wu∗)T ∈ Rr

Figures ¡from ¡Gemulla et ¡al. ¡(2011)

Vui = Wu∗H∗i = [WH]ui

(with ¡matrices)

slide-33
SLIDE 33

Matrix ¡Factorization

  • SGD

39

Figures ¡from ¡Koren et ¡al. ¡(2009) Figure ¡from ¡Gemulla et ¡al. ¡(2011)

(with ¡matrices)

Matrix$factorization$as$SGD$V$ V$why$does$ th this$wo $work? k?

step size

Figure ¡from ¡Gemulla et ¡al. ¡(2011)

slide-34
SLIDE 34

Matrix ¡Factorization

40

–1.5 –1.0 –0.5 0.0 0.5 1.0 –1.5 –1.0 –0.5 0.0 0.5 1.0 1.5 Factor vector 1 Factor vector 2

Freddy Got Fingered Freddy vs. Jason Half Baked Road Trip The Sound of Music Sophie’s Choice Moonstruck Maid in Manhattan The Way We Were Runaway Bride Coyote Ugly The Royal Tenenbaums Punch-Drunk Love I Heart Huckabees Armageddon Citizen Kane The Waltons: Season 1 Stepmom Julien Donkey-Boy Sister Act The Fast and the Furious The Wizard of Oz Kill Bill: Vol. 1 Scarface Natural Born Killers Annie Hall Belle de Jour Lost in Translation The Longest Yard Being John Malkovich Catwoman

Figure 3. The fjrst two vectors from a matrix decomposition of the Netfmix Prize

  • data. Selected movies are placed at the appropriate spot based on their factor

vectors in two dimensions. The plot reveals distinct genres, including clusters of movies with strong female leads, fraternity humor, and quirky independent fjlms.

Figure ¡from ¡Koren et ¡al. ¡(2009)

Example ¡ Factors

slide-35
SLIDE 35

Matrix ¡Factorization

41

ALS = alternating least squares

Comparison ¡

  • f ¡

Optimization ¡ Algorithms

Figure ¡from ¡Gemulla et ¡al. ¡(2011)

slide-36
SLIDE 36

SVD ¡FOR ¡COLLABORATIVE ¡ FILTERING

42

slide-37
SLIDE 37

Singular ¡Value ¡Decomposition for ¡Collaborative ¡Filtering

Whiteboard

– Optimization ¡problem – Equivalence ¡to ¡Unconstrained ¡Matrix ¡ Factorization ¡(fully ¡specified, ¡no ¡regularization)

43

slide-38
SLIDE 38

NON-­‑NEGATIVE ¡MATRIX ¡ FACTORIZATION

44

slide-39
SLIDE 39

Implicit ¡Feedback ¡Datasets

  • What ¡information ¡does ¡a ¡five-­‑star ¡rating ¡contain?
  • Implicit ¡Feedback ¡Datasets:

– In ¡many ¡settings, ¡users ¡don’t ¡have ¡a ¡way ¡of ¡expressing ¡dislike for ¡an ¡ item ¡(e.g. ¡can’t ¡provide ¡negative ¡ratings) – The ¡only ¡mechanism ¡for ¡feedback ¡is ¡to ¡“like” ¡something

  • Examples:

– Facebook ¡has ¡a ¡“Like” ¡button, ¡but ¡no ¡“Dislike” ¡button – Google’s ¡ ¡“+1” ¡button – Pinterest ¡pins – Purchasing ¡an ¡item ¡on ¡Amazon ¡indicates ¡a ¡preference ¡for ¡it, ¡but ¡ there ¡are ¡many ¡reasons ¡you ¡might ¡not purchase ¡an ¡item ¡(besides ¡ dislike) – Search ¡engines ¡collect ¡click ¡data ¡but ¡don’t ¡have ¡a ¡clear ¡mechanism ¡ for ¡observing ¡dislike ¡of ¡a ¡webpage

45

Examples ¡from ¡Aggarwal ¡(2016)

slide-40
SLIDE 40

Non-­‑negative ¡Matrix ¡Factorization

Whiteboard

– Optimization ¡problem – Multiplicative ¡updates

46

slide-41
SLIDE 41

Summary

  • Recommender ¡systems ¡solve ¡many ¡real-­‑

world ¡(*large-­‑scale) ¡problems

  • Collaborative ¡filtering ¡by ¡Matrix ¡

Factorization ¡(MF) ¡is ¡an ¡efficient and ¡ effective approach

  • MF ¡is ¡just ¡another ¡example ¡of ¡a ¡common ¡

recipe:

1. define ¡a ¡model 2. define ¡an ¡objective ¡function 3.

  • ptimize ¡with ¡SGD

55