pydiodon.pca_met

pydiodon.pca_met(A, M, N, k=- 1, pretreatment='col_centering', meth='svd')[source]

PCA of an array with metrics on rows and/or columns - without guaranty

Parameters
Aa \(n \times p\) 2D numpy array

the array to be analysed

Na 2D numpy array

a Symmetric Definite Positive (SDP) matrix defining an inner product on \(R^n\)

Pa 2D numpy array

a SDP matrix defining an inner product on \(R^p\)

kan integer

the number of axis to be computed

if \(k = -1\), all axis are computed

pretreatmenta string

the pretreatment to apply

possible values are: ``col_centering ``

metha string

method for numerical calculation of PCA

Returns
Ya \(n \times k\) 2D numpy array

the princial components

La k 1D numpy array

the eigenvalues

Va \(p \times k\) 2D numpy array

the new basis

Notes

If \(A\) has \(n\) rows and p columns, we assume that an inner product has been defined on \(R^n\) by a SDP matrix N and on \(R^p\) by a SDP matrix P.

This is how the algorithm works:

  • first: computes the square roots of N and P; this is done with a SVD. If

\(N = M^2\) and \(N = U \Sigma U^t\) (\(U=V\) in the SVD because N is symmetric), then \(M = U \Sigma^{1/2} U^t\); simlarily, if \(P=Q^2\), Then \(Q = V\Phi^{1/2} V^t\) if the SVD of P is \(P = V \Phi V^t\).

  • second: computes \(R = MAQ\)

  • third: run the PCA of R: \((Z, \Lambda, X) = PCA(R)\)

  • fourth: computes \(M^{-1}\) and \(Q^{-1}\) as \(M^{-1}=U \Sigma^{-1/2} U^t\) and

\(Q^{-1}=V \Phi^{-1/2} V^t\)

  • fifth: computes \(Y = M^{-1}Z\) and \(V = Q^{-1}X\)

The result is \((Y, V, \Lambda)\)

Let us note that numpy contains a function, called scipy.linalg.sqrtm which computes the square root of a square n x n matrix, from algorithm published in Deadman, E., Higham, N. J. and Ralha, R. (2013) “Blocked Schur Algorithms for Computing the Matrix Square Root, Lecture Notes in Computer Science, 7782. pp. 171-182, which is not used here. Indeed, using the SVD permits to compute easily \(M=N^{1/2}\) and \(M^{-1}=N^{-1/2}\), and the same for P.

Warnings

  • Pretreatment has not been implemented, but centering by column

  • still under work - not frozen for a release

Diodon Documentation

  • see section 6, and algorithm pca_met() in section 11.

28/12/2017, revised 22.09.28