Principal component analysis (PCA) reduces multidimensional vector data to fewer dimensions, making otherwise high-dimensional hyperparameter results easier to visualize in two or three dimensions. section 5.5.2
PCA works by:
- Projecting higher-dimensional data into a lower-dimensional space. section 5.5.2
- Calculating components from variance, with each axis representing relative distances between elements in vector space. section 5.5.2
- Supporting visualization while additional hyperparameters vary during automated optimization. section 5.5.2 section 5.7
Reducing four dimensions to two
Create a scikit-learn PCA object with n_components=2, call fit_transform on four-dimensional population data, transpose the result, and scatter-plot its two component axes. section 5.5.2
Listing 5.27 EDL_5_5_ES_HPO_PCA.ipynb: Adding PCA
pop = np.array([[-.5, .75, -.1, .8],
[-.5, -.3, -.5, .8],
[-.5, 1, -.5, -.8],
[ 1, -.3, -.5, .8]]) #1
pca = PCA(n_components=2) #2
reduced = pca.fit_transform(pop) #3
t = reduced.transpose() #4
plt.scatter(t[0], t[1]) #5
plt.show()
The runnable listing demonstrates PCA setup, transformation, and plotting on contrived four-dimensional data. section 5.5.2









