limix.stats.pca¶
-
limix.stats.
pca
(X, ncomp)[source]¶ Principal component analysis.
Parameters: - X (array_like) – Data.
- ncomp (int) – Number of components.
Returns: - components (array_like): first components ordered by explained variance.
- explained_variance (array_like): explained variance.
- explained_variance_ratio (array_like): percentage of variance explained.
Return type: Examples
>>> from numpy import round >>> from numpy.random import RandomState >>> from limix.stats import pca >>> >>> X = RandomState(1).randn(4, 5) >>> r = pca(X, ncomp=2) >>> round(r['components'], 2) array([[-0.75, 0.58, -0.08, 0.2 , -0.23], [ 0.49, 0.72, 0.02, -0.46, -0.16]]) >>> round(r['explained_variance'], 4) array([ 6.4466, 0.5145]) >>> round(r['explained_variance_ratio'], 4) array([ 0.9205, 0.0735])