Beruflich Dokumente
Kultur Dokumente
1/26/2015
http://cs246.stanford.edu
1/26/2015
Why? The first two rows are linearly independent, so the rank is at least
2, but all three rows are linearly dependent (the first is equal to the sum
of the second and third) so the rank must be less than 3.
B
C
1/26/2015
1/26/2015
1/26/2015
: Singular values
VT
1/26/2015
10
1u1v1
2u2v2
+
i scalar
ui vector
vi vector
1/26/2015
11
: diagonal
12
Serenity
Casablanca
Amelie
Romnce
Alien
SciFi
Matrix
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
1/26/2015
VT
Concepts
AKA Latent dimensions
AKA Latent factors
13
Serenity
Casablanca
Amelie
Romnce
Alien
SciFi
Matrix
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
12.4 0 0
0
9.5 0
0
0 1.3
14
Serenity
Casablanca
Amelie
Romnce
Alien
SciFi
Matrix
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
SciFi-concept
Romance-concept
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
12.4 0 0
0
9.5 0
0
0 1.3
15
Serenity
Casablanca
Amelie
Romnce
Alien
SciFi
A = U VT - example:
Matrix
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
SciFi-concept
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
U is user-to-concept
similarity matrix
Romance-concept
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
12.4 0 0
0
9.5 0
0
0 1.3
16
Serenity
Casablanca
Amelie
Romnce
Alien
SciFi
A = U VT - example:
Matrix
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
SciFi-concept
strength of the SciFi-concept
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
12.4 0 0
0
9.5 0
0
0 1.3
17
Serenity
Casablanca
Amelie
Romnce
Alien
SciFi
A = U VT - example:
Matrix
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
SciFi-concept
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
SciFi-concept
1/26/2015
V is movie-to-concept
similarity matrix
12.4 0 0
0
9.5 0
0
0 1.3
1/26/2015
19
Movie 2 rating
first right
singular vector
v1
Movie 1 rating
1/26/2015
21
Movie 2 rating
=1 =1
where are the old and are the
new coordinates
first right
singular
vector
v1
Movie 1 rating
1/26/2015
22
A = U VT - example:
V: movie-to-concept matrix
U: user-to-concept matrix
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1/26/2015
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
Movie 2 rating
first right
singular
vector
v1
Movie 1 rating
12.4 0 0
0
9.5 0
0
0 1.3
A = U VT - example:
variance (spread)
on the v1 axis
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1/26/2015
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
Movie 2 rating
first right
singular
vector
v1
Movie 1 rating
12.4 0 0
0
9.5 0
0
0 1.3
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1/26/2015
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
Projection of users
on the Sci-Fi axis
(U ) :
Movie 2 rating
A = U VT - example:
first right
singular
vector
v1
Movie 1 rating
1.61
5.08
6.82
8.43
1.86
0.86
0.86
0.19
0.66
0.85
1.04
-5.60
-6.93
-2.75
-0.01
-0.03
-0.05
-0.06
0.84
-0.87
0.41
25
More details
Q: How exactly is dim. reduction done?
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1/26/2015
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
12.4 0 0
0
9.5 0
0
0 1.3
More details
Q: How exactly is dim. reduction done?
A: Set smallest singular values to zero
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1/26/2015
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
12.4 0 0
0
9.5 0
0
0 1.3
More details
Q: How exactly is dim. reduction done?
A: Set smallest singular values to zero
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1/26/2015
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
12.4 0 0
0
9.5 0
0
0 1.3
This is Rank 2
approximation to A.
We could also do
Rank 1 approx.
The larger the rank
the more accurate
the approximation.
More details
Q: How exactly is dim. reduction done?
A: Set smallest singular values to zero
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1/26/2015
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05
0.65
-0.67
0.32
12.4 0 0
0
9.5 0
0
0 1.3
This is Rank 2
approximation to A.
We could also do
Rank 1 approx.
The larger the rank
the more accurate
the approximation.
More details
Q: How exactly is dim. reduction done?
A: Set smallest singular values to zero
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1/26/2015
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
12.4 0
0
9.5
This is Rank 2
approximation to A.
We could also do
Rank 1 approx.
The larger the rank
the more accurate
the approximation
More details
Q: How exactly is dim. reduction done?
A: Set smallest singular values to zero
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
0.92
2.91
3.90
4.82
0.70
-0.69
0.32
0.95
3.01
4.04
5.00
0.53
1.34
0.23
0.92
2.91
3.90
4.82
0.70
-0.69
0.32
Frobenius norm:
MF = ij Mij2
1/26/2015
0.01
-0.01
0.01
0.03
4.11
4.78
2.01
0.01
-0.01
0.01
0.03
4.11
4.78
2.01
A-BF = ij (Aij-Bij)2
is small
31
Sigma
VT
B is best approximation of A
Sigma
1/26/2015
VT
32
Theorem:
Let A = U VT and B = U S VT where
S = diagonal rxr matrix with si=i (i=1k) else si=0
then B is a best rank(B)=k approx. to A
2
33
Equivalent:
spectral decomposition of the matrix:
1
3
4
5
0
0
0
1/26/2015
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
u1
u2
x
2
v1
v2
37
Equivalent:
spectral decomposition of the matrix
m
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
k terms
u1 vT1 +
nx1
u2 vT2 +...
1xm
Assume: 1 2 3 ... 0
38
1
3
4
5
0
0
0
1/26/2015
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
u1 vT1 +
u2 vT2 +...
Assume: 1 2 3 ...
39
To compute SVD:
O(nm2) or O(n2m) (whichever is less)
But:
1/26/2015
40
Dimensionality reduction:
Keep the few largest singular values
(80-90% of energy)
SVD: picks up linear correlations
1/26/2015
41
Serenity
Casablanca
Amelie
Romnce
Alien
SciFi
Matrix
1
3
4
5
0
0
0
1
3
4
5
2
0
1
1
3
4
5
0
0
0
0
0
0
0
4
5
2
0
0
0
0
4
5
2
1/26/2015
0.13
0.41
0.55
0.68
0.15
0.07
0.07
0.02
0.07
0.09
0.11
-0.59
-0.73
-0.29
-0.01
-0.03
-0.04
-0.05 x
0.65
-0.67
0.32 0.56
0.12
0.40
12.4 0 0
0
9.5 0
0
0 1.3
Alien
Amelie
Casablanca
Serenity
Alien
Matrix
q= 5 0 0 0 0
v2
v1
Matrix
47
Alien
Amelie
Casablanca
Serenity
Alien
Matrix
q= 5 0 0 0 0
v2
v1
q*v1
Matrix
48
Compactly, we have:
qconcept = q V
Amelie
Casablanca
Serenity
Alien
Matrix
E.g.:
q= 5 0 0 0 0
0.56
0.59
0.56
0.09
0.09
0.12
-0.02
0.12
-0.69
-0.69
SciFi-concept
2.8
0.6
movie-to-concept
similarities (V)
1/26/2015
49
Casablanca
Serenity
Alien
Matrix
q= 0 4 5 0 0
0.56
0.59
0.56
0.09
0.09
0.12
-0.02
0.12
-0.69
-0.69
SciFi-concept
5.2
0.4
movie-to-concept
similarities (V)
1/26/2015
50
Amelie
0 4
q =
5 0
Alien
d =
Matrix
Casablanca
SciFi-concept
5.2
0.4
2.8
0.6
Similarity > 0
51
- Lack of sparsity:
=
U
1/26/2015
52
Frobenius norm:
XF = ij Xij2
A
1/26/2015
C
Jure Leskovec, Stanford C246: Mining Massive Datasets
R
54
Frobenius norm:
XF = ij Xij2
Pseudo-inverse of
the intersection of C and R
A
1/26/2015
C
Jure Leskovec, Stanford C246: Mining Massive Datasets
R
55
57
Actual column
Singular vector
1/26/2015
58
Then: U = W+ = Y Z+ XT
+: reciprocals of non-zero
singular values: +ii =1/ ii
Def: W+ is the pseudoinverse
A
C
U = W+
1/26/2015
For example:
Select =
columns of A using
ColumnSelect algorithm
Select =
rows of A using
ColumnSelect algorithm
Set = +CUR error
SVD error
Then: 2 +
with probability 98%
In practice:
1/26/2015
Pick 4k cols/rows
for a rank-k approximation
61
Easy interpretation
Since the basis vectors are actual
columns and rows
Sparse basis
Actual column
Singular vector
1/26/2015
62
Rd
A
1/26/2015
Cd
Rs
Cs
Construct a
small U
63
SVD: A = U
Huge but sparse
T
V
CUR: A = C U R
Huge but sparse
1/26/2015
64
1/26/2015
65
SVD
CUR
CUR no duplicates
SVD
SVD
CUR
CUR no dup
CUR
Accuracy:
Space ratio:
CPU time
Sun, Faloutsos: Less is More: Compact Matrix Decomposition for Large Sparse Graphs, SDM 07.
1/26/2015
66
How?
Build adjacency graph
Geodesic distance is
graph distance
SVD/PCA the graph
pairwise distance matrix
1/26/2015
67
1/26/2015
68