Reputation: 11431
I have a question for following
A = array([
[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]])
print(A)
# Singular-value decomposition
U, s, VT = svd(A)
For above “s” should be of shape(10,) as we have 10 features, but instead of (3,) is shown. Sample output is shown below I am confused. Kindly explain, why we go (3,)
(3, 10)
U shape (3, 3)
s shape (3,)
VT shape (10, 10)
Let us consider another example
A = array([[1, 2], [3, 4], [5, 6]])
print(A.shape)
# Singular-value decomposition
U, s, VT = svd(A)
Here “s” shape is shown as (2,)
Here output is shown below
(3, 2)
U shape (3, 3)
s shape (2,)
VT shape (2, 2)
I am not getting why there is difference in shape. Kindly expalin
Upvotes: 0
Views: 341
Reputation: 36719
Using SVD, a matrix A of shape (m x n) is decomposed into
Sigma contains all singular values on its main diagonal. Since a matrix of shape (m x n) only contains min(m, n) elements on its main diagonal, there are only min(m, n) singular values.
Upvotes: 1