Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
Coding the Matrix!
Divya Padmanabhan
Intelligent Systems Lab,Dept. of CSA,
Indian Institute of Science,Bangalore
June 28, 2013
Divya Padmanabhan Coding the Matrix! June 28, 2013 1
How does the most popular search engine work?
Google it!
Search more than 8 billion pages ..
Results in less than a second..
How is it possible???
What is Google doing in that 1 second?
Divya Padmanabhan Coding the Matrix! June 28, 2013 2
How does Facebook manage information about you?
Friend network matrixU1 · · · Un
U1 · · ·U2 · · ·...Un · · ·
Divya Padmanabhan Coding the Matrix! June 28, 2013 3
How does Flipkart recommend products for you?
How does Flipkart know what you require?
How does Flipkart keep track of so many users and find theirinterests?
Divya Padmanabhan Coding the Matrix! June 28, 2013 4
Some BASICS!!!
Divya Padmanabhan Coding the Matrix! June 28, 2013 5
Preliminaries
Vectors
eg. How well can you sing? paint? play? ..
Professional singer :(1 · · · )
. Amateur :(0.1 · · · )
Norm |~x | =√x21 + x22 + · · ·+ x2n
Dot product ~x .~y = |~x ||~y | cos θ = x1y1 + x2y2 + · · ·+ xnyn
Divya Padmanabhan Coding the Matrix! June 28, 2013 6
Preliminaries
Vectors
eg. How well can you sing? paint? play? ..
Professional singer :(1 · · · )
. Amateur :(0.1 · · · )
Norm |~x | =√x21 + x22 + · · ·+ x2n
Dot product ~x .~y = |~x ||~y | cos θ = x1y1 + x2y2 + · · ·+ xnyn
Divya Padmanabhan Coding the Matrix! June 28, 2013 6
Orthogonality and Projections
Figure: Orthogonal vectors ~xT~y = ||x ||||y || cos θ = 0
~x
~y
θ
Figure: Projection of ~x on ~y = ~x.~y||~y ||
O
Z
~x
~y
~x.~y||y||
Divya Padmanabhan Coding the Matrix! June 28, 2013 7
Orthogonality and Projections
Figure: Orthogonal vectors ~xT~y = ||x ||||y || cos θ = 0
~x
~y
θ
Figure: Projection of ~x on ~y = ~x.~y||~y ||
O
Z
~x
~y
~x.~y||y||
Divya Padmanabhan Coding the Matrix! June 28, 2013 7
Linear Combination and Independence
Linear Combination
c1~x + c2~y , c1 ∈ R, c2 ∈ R
Linear Independence of vectors ~x and ~y
c1~x + c2~y = 0⇒ c1 = 0, c2 = 0
Can’t express ~x in terms of ~y .
Eg.
[10
],
[23
], c1 = 0, c2 = 0
Linearly dependent :[12
],
[24
], c1 = 2, c2 = −1
Divya Padmanabhan Coding the Matrix! June 28, 2013 8
Linear Combination and Independence
Linear Combination
c1~x + c2~y , c1 ∈ R, c2 ∈ R
Linear Independence of vectors ~x and ~y
c1~x + c2~y = 0⇒ c1 = 0, c2 = 0
Can’t express ~x in terms of ~y .
Eg.
[10
],
[23
], c1 = 0, c2 = 0
Linearly dependent :[12
],
[24
], c1 = 2, c2 = −1
Divya Padmanabhan Coding the Matrix! June 28, 2013 8
Linear Combination and Independence
Linear Combination
c1~x + c2~y , c1 ∈ R, c2 ∈ R
Linear Independence of vectors ~x and ~y
c1~x + c2~y = 0⇒ c1 = 0, c2 = 0
Can’t express ~x in terms of ~y .
Eg.
[10
],
[23
], c1 = 0, c2 = 0
Linearly dependent :[12
],
[24
], c1 = 2, c2 = −1
Divya Padmanabhan Coding the Matrix! June 28, 2013 8
Matrix Multiplication
A︷ ︸︸ ︷[2 34 5
] B︷︸︸︷[12
]=
C︷︸︸︷[8
14
]
1
[24
]+ 2
[35
]=
[8
14
]
Divya Padmanabhan Coding the Matrix! June 28, 2013 9
Matrix Multiplication
A︷ ︸︸ ︷[2 34 5
] B︷︸︸︷[12
]=
C︷︸︸︷[8
14
]
1
[24
]+ 2
[35
]=
[8
14
]
Divya Padmanabhan Coding the Matrix! June 28, 2013 9
Row and column vectors
A =
[2 1 03 −1 4
]
Row vectors =
r1 =
210
, r2 =
3−14
Column vectors =
{c1 =
[23
], c2 =
[1−1
], c3 =
[04
]}
Divya Padmanabhan Coding the Matrix! June 28, 2013 10
Row and column vectors
A =
[2 1 03 −1 4
]Row vectors =
r1 =
210
, r2 =
3−14
Column vectors =
{c1 =
[23
], c2 =
[1−1
], c3 =
[04
]}
Divya Padmanabhan Coding the Matrix! June 28, 2013 10
Row and column vectors
A =
[2 1 03 −1 4
]Row vectors =
r1 =
210
, r2 =
3−14
Column vectors =
{c1 =
[23
], c2 =
[1−1
], c3 =
[04
]}
Divya Padmanabhan Coding the Matrix! June 28, 2013 10
Fundamental spaces
Row space and column space of A
Row Space: Linear combination of r1, r2.
Column space : Linear combination of c1, c2, c3
Null space: Vectors orthogonal to row space of A.
Row Space (A) = Col space (AT )
Divya Padmanabhan Coding the Matrix! June 28, 2013 11
Representatives of a space
Basis and dimensions of a space
Basis : Smallest no. of linearly independent vectors whose linearcombination gives the entire space.
[−21
]= −2
[10
]+ 1
[01
]Dimension : No. of vectors in the basis.
Divya Padmanabhan Coding the Matrix! June 28, 2013 12
Redundancy elimination
Rank and nullity of matrix A
Rank(A)= no. of linearly independent column vectors of A.
Nullity(A) = dimension of nullspace of A.
Rank measures redundancy in the matrix.
[1 0 −4 −28 −150 1 −1 −2 −6
]Rank-Nullity Theorem: Rank(A) + Nullity(A) = n
Divya Padmanabhan Coding the Matrix! June 28, 2013 13
Redundancy elimination
Rank and nullity of matrix A
Rank(A)= no. of linearly independent column vectors of A.
Nullity(A) = dimension of nullspace of A.
Rank measures redundancy in the matrix.[1 0 −4 −28 −150 1 −1 −2 −6
]
Rank-Nullity Theorem: Rank(A) + Nullity(A) = n
Divya Padmanabhan Coding the Matrix! June 28, 2013 13
Redundancy elimination
Rank and nullity of matrix A
Rank(A)= no. of linearly independent column vectors of A.
Nullity(A) = dimension of nullspace of A.
Rank measures redundancy in the matrix.[1 0 −4 −28 −150 1 −1 −2 −6
]Rank-Nullity Theorem: Rank(A) + Nullity(A) = n
Divya Padmanabhan Coding the Matrix! June 28, 2013 13
Eigen values and eigen vectors
x
Resear h
1
0.8
Publi
Speaking
A2×2−−−→x
Ax = λx
Resear h
Publi
Speaking
1
0.8
2
1.6
How do you determine the x and λ given a matrix A?
Ax = λx , x 6= ~0 ( or xTAT = λxT , x 6= ~0 )(A− λI )x = 0det(A− λI ) = 0
Divya Padmanabhan Coding the Matrix! June 28, 2013 14
Eigen values and eigen vectors
x
Resear h
1
0.8
Publi
Speaking
A2×2−−−→
x
Ax = λx
Resear h
Publi
Speaking
1
0.8
2
1.6
How do you determine the x and λ given a matrix A?
Ax = λx , x 6= ~0 ( or xTAT = λxT , x 6= ~0 )(A− λI )x = 0det(A− λI ) = 0
Divya Padmanabhan Coding the Matrix! June 28, 2013 14
Eigen values and eigen vectors
x
Resear h
1
0.8
Publi
Speaking
A2×2−−−→x
Ax = λx
Resear h
Publi
Speaking
1
0.8
2
1.6
How do you determine the x and λ given a matrix A?
Ax = λx , x 6= ~0 ( or xTAT = λxT , x 6= ~0 )(A− λI )x = 0det(A− λI ) = 0
Divya Padmanabhan Coding the Matrix! June 28, 2013 14
Eigen values and eigen vectors
x
Resear h
1
0.8
Publi
Speaking
A2×2−−−→x
Ax = λx
Resear h
Publi
Speaking
1
0.8
2
1.6
How do you determine the x and λ given a matrix A?
Ax = λx , x 6= ~0 ( or xTAT = λxT , x 6= ~0 )
(A− λI )x = 0det(A− λI ) = 0
Divya Padmanabhan Coding the Matrix! June 28, 2013 14
Eigen values and eigen vectors
x
Resear h
1
0.8
Publi
Speaking
A2×2−−−→x
Ax = λx
Resear h
Publi
Speaking
1
0.8
2
1.6
How do you determine the x and λ given a matrix A?
Ax = λx , x 6= ~0 ( or xTAT = λxT , x 6= ~0 )(A− λI )x = 0
det(A− λI ) = 0
Divya Padmanabhan Coding the Matrix! June 28, 2013 14
Eigen values and eigen vectors
x
Resear h
1
0.8
Publi
Speaking
A2×2−−−→x
Ax = λx
Resear h
Publi
Speaking
1
0.8
2
1.6
How do you determine the x and λ given a matrix A?
Ax = λx , x 6= ~0 ( or xTAT = λxT , x 6= ~0 )(A− λI )x = 0det(A− λI ) = 0
Divya Padmanabhan Coding the Matrix! June 28, 2013 14
Eigen values and eigen vectors
x
Resear h
1
0.8
Publi
Speaking
A2×2−−−→x
Ax = λx
Resear h
Publi
Speaking
1
0.8
2
1.6
How do you determine the x and λ given a matrix A?
Ax = λx , x 6= ~0 ( or xTAT = λxT , x 6= ~0 )(A− λI )x = 0det(A− λI ) = 0
Divya Padmanabhan Coding the Matrix! June 28, 2013 14
Now for the FUN stuff!!!
Divya Padmanabhan Coding the Matrix! June 28, 2013 15
A Typical Search Activity : Random surfer
Jump−−−→
Divya Padmanabhan Coding the Matrix! June 28, 2013 16
A Typical Search Activity : Random surfer
Jump−−−→
Divya Padmanabhan Coding the Matrix! June 28, 2013 16
Importance of pages
Divya Padmanabhan Coding the Matrix! June 28, 2013 17
Importance of pages
Divya Padmanabhan Coding the Matrix! June 28, 2013 17
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Anything particular about H?
H : row stochastic
Vt(A) : Probability of being at page A at time tVt : row vector. eg.
[0.1 0.3 · · ·
]Vt(A) = Vt−1(A)HAA + Vt−1(B)HBA + . . .
Vt = Vt−1H
Divya Padmanabhan Coding the Matrix! June 28, 2013 18
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Anything particular about H?
H : row stochastic
Vt(A) : Probability of being at page A at time tVt : row vector. eg.
[0.1 0.3 · · ·
]Vt(A) = Vt−1(A)HAA + Vt−1(B)HBA + . . .
Vt = Vt−1H
Divya Padmanabhan Coding the Matrix! June 28, 2013 18
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Anything particular about H?
H : row stochastic
Vt(A) : Probability of being at page A at time tVt : row vector. eg.
[0.1 0.3 · · ·
]Vt(A) = Vt−1(A)HAA + Vt−1(B)HBA + . . .
Vt = Vt−1H
Divya Padmanabhan Coding the Matrix! June 28, 2013 18
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Anything particular about H?
H : row stochastic
Vt(A) : Probability of being at page A at time tVt : row vector. eg.
[0.1 0.3 · · ·
]Vt(A) = Vt−1(A)HAA + Vt−1(B)HBA + . . .
Vt = Vt−1H
Divya Padmanabhan Coding the Matrix! June 28, 2013 18
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Anything particular about H?
H : row stochastic
Vt(A) : Probability of being at page A at time tVt : row vector. eg.
[0.1 0.3 · · ·
]
Vt(A) = Vt−1(A)HAA + Vt−1(B)HBA + . . .
Vt = Vt−1H
Divya Padmanabhan Coding the Matrix! June 28, 2013 18
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Anything particular about H?
H : row stochastic
Vt(A) : Probability of being at page A at time tVt : row vector. eg.
[0.1 0.3 · · ·
]Vt(A) = Vt−1(A)HAA + Vt−1(B)HBA + . . .
Vt = Vt−1H
Divya Padmanabhan Coding the Matrix! June 28, 2013 18
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Anything particular about H?
H : row stochastic
Vt(A) : Probability of being at page A at time tVt : row vector. eg.
[0.1 0.3 · · ·
]Vt(A) = Vt−1(A)HAA + Vt−1(B)HBA + . . .
Vt = Vt−1H
Divya Padmanabhan Coding the Matrix! June 28, 2013 18
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
H : row stochastic, guaranteed to have eigen value 1, under someconditions.
V0 =
1/41/41/41/4
,
V1 = V0H =
9/245/245/245/24
, V2 = V1H =
15/4811/4811/4811/48
Divya Padmanabhan Coding the Matrix! June 28, 2013 19
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
H : row stochastic, guaranteed to have eigen value 1, under someconditions.
V0 =
1/41/41/41/4
, V1 = V0H =
9/245/245/245/24
,
V2 = V1H =
15/4811/4811/4811/48
Divya Padmanabhan Coding the Matrix! June 28, 2013 19
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
H : row stochastic, guaranteed to have eigen value 1, under someconditions.
V0 =
1/41/41/41/4
, V1 = V0H =
9/245/245/245/24
, V2 = V1H =
15/4811/4811/4811/48
Divya Padmanabhan Coding the Matrix! June 28, 2013 19
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
H : row stochastic, guaranteed to have eigen value 1, under someconditions.
...Vn = Vn−1H
...
vH = 1v
v is the eigen vector of H corresponding to eigen value 1 !!!
Divya Padmanabhan Coding the Matrix! June 28, 2013 20
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
H : row stochastic, guaranteed to have eigen value 1, under someconditions.
...Vn = Vn−1H
...
vH = 1v
v is the eigen vector of H corresponding to eigen value 1 !!!
Divya Padmanabhan Coding the Matrix! June 28, 2013 20
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
H : row stochastic, guaranteed to have eigen value 1, under someconditions.
...Vn = Vn−1H
...
vH = 1v
v is the eigen vector of H corresponding to eigen value 1 !!!
Divya Padmanabhan Coding the Matrix! June 28, 2013 20
Page Rank Algorithm
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
H : row stochastic, guaranteed to have eigen value 1, under someconditions.
...Vn = Vn−1H
...
vH = 1v
v is the eigen vector of H corresponding to eigen value 1 !!!Divya Padmanabhan Coding the Matrix! June 28, 2013 20
Page Rank Algorithm - conditions on H
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Row stochastic
Irreducible :Possible to reach a page from any other page.
Aperiodic : Not periodic
Divya Padmanabhan Coding the Matrix! June 28, 2013 21
Page Rank Algorithm - conditions on H
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Row stochastic
Irreducible :Possible to reach a page from any other page.
Aperiodic : Not periodic
Divya Padmanabhan Coding the Matrix! June 28, 2013 21
Page Rank Algorithm - conditions on H
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Row stochastic
Irreducible :Possible to reach a page from any other page.
Aperiodic : Not periodic
Divya Padmanabhan Coding the Matrix! June 28, 2013 21
Page Rank Algorithm - conditions on H
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1 0 0 0D 0 1
212 0
Row stochastic
Irreducible :Possible to reach a page from any other page.
Aperiodic : Not periodic
Divya Padmanabhan Coding the Matrix! June 28, 2013 21
Page Rank Algorithm - Dangling nodes
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1
2 0 0 12
D 0 0 0 0
S = H + Y
=
A B C D
A 0 13
13
13
B 12 0 0 1
2
C 12 0 0 1
2
D 14
14
14
14
Divya Padmanabhan Coding the Matrix! June 28, 2013 22
Page Rank Algorithm - Dangling nodes
Transition Matrix HA B C D
A 0 13
13
13
B 12 0 0 1
2C 1
2 0 0 12
D 0 0 0 0
S = H + Y
=
A B C D
A 0 13
13
13
B 12 0 0 1
2
C 12 0 0 1
2
D 14
14
14
14
Divya Padmanabhan Coding the Matrix! June 28, 2013 22
Page Rank Algorithm - Entering a new destination
S =
A B C D
A 0 13
13
13
B 12 0 0 1
2C 1
2 0 0 12
D 14
14
14
14
B :
1/n · · · 1/n· · ·
1/n · · · 1/n
n×n
Google matrix!
Surfer follows the link structure 60 % of timeOtherwise to a random page!
G = αS + (1− α)B
Divya Padmanabhan Coding the Matrix! June 28, 2013 23
Page Rank Algorithm
Search Engines
Get pages containing query words.
Use page rank to determine the order of pagesto be displayed.
Ford 0.1Maruti 0.7Volkswagen 0.05Hyundai 0.15
Divya Padmanabhan Coding the Matrix! June 28, 2013 24
Page Rank Algorithm
Search Engines
Get pages containing query words.
Use page rank to determine the order of pagesto be displayed.
Ford 0.1Maruti 0.7Volkswagen 0.05Hyundai 0.15
Divya Padmanabhan Coding the Matrix! June 28, 2013 24
Recommender Systems
Divya Padmanabhan Coding the Matrix! June 28, 2013 25
Recommender Systems
Matrix Factorization
Original matrix Xd×n (d users, n movies)
X ≈ X̂ = Md×k × Hk×n
Find M,H.
Divya Padmanabhan Coding the Matrix! June 28, 2013 26
References
1 Gilbert Strang, “Linear Algebra and its Applications”, Fourth Edition.
2 Langville and Meyer,“Google’s PageRank and Beyond”.
3 Gene H. Golub, Charles F. Van Loan, “Matrix Computations”.
4 Howard Anton, Chris Rorres, “Elementary Linear Algebra”.
Divya Padmanabhan Coding the Matrix! June 28, 2013 27
THANK YOU!
Divya Padmanabhan Coding the Matrix! June 28, 2013 28