November 2017
Intermediate to advanced
374 pages
10h 19m
English
It is recommended that PCA is scaled beforehand. Do so as follows:
from sklearn import preprocessingiris_X_scaled = preprocessing.scale(iris_X)pca = decomposition.PCA(n_components=2)iris_X_scaled = pca.fit_transform(iris_X_scaled)
This leads to the following graph:
fig = plt.figure(figsize=(20,7))ax = fig.add_subplot(121)ax.scatter(iris_X_prime[:,0],iris_X_prime[:,1],c=y,s=40)ax.set_title('Regular PCA')ax2 = fig.add_subplot(122)ax2.scatter(iris_X_scaled[:,0],iris_X_scaled[:,1],c=y,s=40)ax2.set_title('Scaling followed by PCA')

This looks a bit worse. Regardless, you should always consider the scaled PCA if you consider PCA. ...
Read now
Unlock full access