CPC

Multiview Common Principal Components

CPC computes Common principal components of a set of matrices.

This file uses a variation of Trendafilov (2010) method to compute the k first common principal components of a set of matrices in an efficient way

class multiview.cpcmv.MVCPC(k=0)

Compute common principal components of x.

Parameters:k (int, default 0) – Number of components to extract (0 means all p components).
eigenvalues_

ndarray – Stores the eigenvalues computed in the algorithm.

eigenvectors_

ndarray – Stores the eigenvectors computed in the algorithm.

References

Trendafilov, N. (2010). Stepwise estimation of common principal components. Computational Statistics and Data Analysis, 54, 3446–3457.

fit(x)

Compute k common principal components of x.

Parameters:x (array_like or ndarray) – A set of n matrices of dimension pxp given as a n x p x p matrix.
fit_transform(x)

Compute k common principal components of x, and return those components.

Parameters:

x (array_like or ndarray) – A set of n matrices of dimension pxp given as a n x p x p matrix.

Returns:

values – Tuple with two elements:

the eigenvalues

the common eigenvectors

Return type:

tuple

Raises:
  • ValueError: Matrices are not square matrices or k value is
  • negative.

Examples

>>> import numpy as np
>>> x = np.array([[[2, 1, 8], [4, 5, 6], [3, 7, 9]],
              [[1, 4, 7], [2, 5, 8], [3, 6, 9]]])
>>> mv_cpc = MVCPC(k=3)
>>> mv_cpc.fit_transform(x)
(array([[ 16.09601677,  16.21849616],
        [ -0.11903382,  -0.85516505],
        [  0.02301705,  -0.3633311 ]]),
        array([[ 0.45139369, -0.88875921,  0.07969196],
        [ 0.55811719,  0.35088538,  0.75192065],
        [ 0.69623914,  0.29493478, -0.65441923]]))
>>>