January 2018
Beginner to intermediate
316 pages
7h 14m
English
Once we decide to keep two principal components (whether we use a grid search module or the analysis of a scree plot to find the optimal number doesn't matter), we have to be able to use these components to transform incoming, out of sample data-points. To do this, let's first isolate the top two eigenvectors and store them in a new variable called top_2_eigenvectors:
# store the top two eigenvectors in a variabletop_2_eigenvectors = eig_vec_cov[:,:2].T# show the transpose so that each row is a principal component, we have two rows == two componentstop_2_eigenvectorsarray([[ 0.36158968, -0.08226889, 0.85657211, 0.35884393], [-0.65653988, -0.72971237, 0.1757674 , 0.07470647]])
This array ...
Read now
Unlock full access