Created
November 9, 2018 02:17
-
-
Save GeorgeSeif/d1770bc4cf5438cfa0800c2ae8ff9b2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Compute the eigen values and vectors using numpy | |
| eig_vals, eig_vecs = np.linalg.eig(cov_mat) | |
| # Make a list of (eigenvalue, eigenvector) tuples | |
| eig_pairs = [(np.abs(eig_vals[i]), eig_vecs[:,i]) for i in range(len(eig_vals))] | |
| # Sort the (eigenvalue, eigenvector) tuples from high to low | |
| eig_pairs.sort(key=lambda x: x[0], reverse=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment