Using Numpy (np.linalg.svd) for Singular Value Decomposition

前端 未结 3 1067
既然无缘
既然无缘 2021-02-02 12:01

Im reading Abdi & Williams (2010) \"Principal Component Analysis\", and I\'m trying to redo the SVD to attain values for further PCA.

The article states that followi

3条回答
  •  爱一瞬间的悲伤
    2021-02-02 12:30

    From the scipy.linalg.svd docstring, where (M,N) is the shape of the input matrix, and K is the lesser of the two:

    Returns
    -------
    U : ndarray
        Unitary matrix having left singular vectors as columns.
        Of shape ``(M,M)`` or ``(M,K)``, depending on `full_matrices`.
    s : ndarray
        The singular values, sorted in non-increasing order.
        Of shape (K,), with ``K = min(M, N)``.
    Vh : ndarray
        Unitary matrix having right singular vectors as rows.
        Of shape ``(N,N)`` or ``(K,N)`` depending on `full_matrices`.
    

    Vh, as described, is the transpose of the Q used in the Abdi and Williams paper. So just

    X_a = P.dot(D).dot(Q)
    

    should give you your answer.

提交回复
热议问题