The downside to using PCA to visualize your data is that some variance will likely be removed. To help get a sense for the integrity of your low dimensional visualizations, we built the describe_pca function, which computes the covariance (samples by samples) of both the raw and reduced datasets, and plots their correlation. The function repeats this analysis from 2:N dimensions until the correlation reaches a local maximum. Often times this will be less than the total number of dimensions because the PCA model is whitened.
# Code source: Andrew Heusser
# License: MIT
import hypertools as hyp
import scipy.io as sio
import numpy as np
data=sio.loadmat('sample_data/weights.mat')
w=[i for i in data['weights'][0][0:3]]
hyp.tools.describe_pca(w)
Total running time of the script: ( 0 minutes 3.749 seconds)