Package: vipurpca
VIPurPCAVIPurPCA offers a visualization of uncertainty propagated through the dimensionality reduction technique Principal Component Analysis (PCA) by automatic differentiation.InstallationVIPurPCA requires Python 3.7.3 or later and can be installed via:pip install vipurpcaA website showing results and animations can be foundhere.UsagePropagating uncertainty through PCA and visualize output uncertainty as animated scatter plotIn order to propagate uncertainty through PCA the classPCAcan be used, which has the following parameters, attributes, and methods:Parametersmatrix : array_likeArray of size [n, p] containing mean numbers to which VIPurPCA should be applied.sample_cov : array_like of shape [n, n] or [n], default=None, optionalInput uncertainties in terms of the sample covariance matrix. Ifsample_covis one-dimensional its values are assumed to be the diagonal of a diagonal matrix. Used to compute the total covariance matrix over the input using the Kronecker product ofsample_covandfeature_cov.feature_cov : array_like of shape [p, p] or [p], default=None, optionalInput uncertainties in terms of the feature covariance matrix. Iffeature_covis one-dimensional its values are assumed to be the diagonal of a diagonal matrix. Used to compute the total covariance matrix over the input using the Kronecker product ofsample_covandfeature_cov.full_cov : array_like of shape [np, np] or [np], default=None, optionalInput uncertainties in terms of the full covariance matrix. Iffull_covis one-dimensional its values are assumed to be the diagonal of a diagonal matrix. Used alternatively to the Kronecker product ofsample_covandfeature_cov. Requires more memory.n_components : int or float, default=None, optionalNumber of components to keep.axis : {0, 1} , default=0, optionalThe default expects samples in rows and features in columns.Attributessize : [n, p]Dimension ofmatrix(n: number of samples, p: number of dimensions)eigenvalues : ndarray of size [n_components]Eigenvalues obtained from eigenvalue decomposition of thecovariancematrix.eigenvectors : ndarray of size [n_componentsp, np]Eigenvectors obtained from eigenvalue decomposition of thecovariancematrix.jacobian : ndarray of size [n_componentsp, np]Jacobian containing derivatives ofeigenvectorsw.r.t. inputmatrix.cov_eigenvectors : ndarray of size [n_componentsp, n_componentsp]Propagated uncertainties ofeigenvectors.transformed data : ndarray of size [n, n_components]Low dimensional representation of data after applying PCA.Methodspca_value()Apply PCA to thematrix.compute_cov_eigenvectors(save_jacobian=False)Compute uncertainties ofeigenvectors.animate(pcx=1, pcy=2, n_frames=10, labels=None, outfile='animation.gif')Generate animation of PCA-plot of PC pcx vs. PC pcy withn_framesnumber of frames.labels(list, 1d array) indicate labelling of individual samples. >Example datasetsTwo example datasets can be loaded after installing VIPurPCA providing mean, covariance and labels.from vipurpca import load_data
Y, cov_Y, y = load_data.load_studentgrades_dataset()
Y, cov_Y, y = load_data.load_estrogen_dataset()More information on the datasets can be foundhereExamplefrom vipurpca import load_data
from vipurpca import PCA

# load mean (Y), uncertainty estimates (cov_Y) and labels (y)
Y, cov_Y, y = load_data.load_estrogen_dataset()
pca = PCA(matrix=Y, sample_cov=None, feature_cov=None,
full_cov=cov_Y, n_components=3, axis=0)
# compute PCA
pca.pca_value()
# Bayesian inference
pca.compute_cov_eigenvectors(save_jacobian=False)# Create animation
pca.animate(1, 2, labels=y, outfile='animation.gif')The resulting animation can be found herehere.