Skip to Content
Hands-On Automated Machine Learning
book

Hands-On Automated Machine Learning

by Sibanjan Das, Umit Mert Cakmak
April 2018
Beginner to intermediate content levelBeginner to intermediate
282 pages
6h 52m
English
Packt Publishing
Content preview from Hands-On Automated Machine Learning

Principal Component Analysis in action

The following code block shows you how to apply PCA with two components and visualize the results:

# PCAfrom sklearn.decomposition import PCApca = PCA(n_components=2, whiten=True)pca = pca.fit_transform(df)plt.scatter(pca[:, 0], pca[:, 1], c=data.target, cmap="RdBu_r", edgecolor="Red", alpha=0.35)plt.colorbar()plt.title('PCA, n_components=2')plt.show()

We get the following plot from the preceding code:

Plot of PCA, n_components=2

Here, you can see the red class (dark gray) is very condensed into one particular area and it's hard to separate classes. Differences in variances distort our view and scaling ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Automated Machine Learning

Automated Machine Learning

Adnan Masood
R: Unleash Machine Learning Techniques

R: Unleash Machine Learning Techniques

Raghav Bali, Dipanjan Sarkar, Brett Lantz, Cory Lesmeister

Publisher Resources

ISBN: 9781788629898Supplemental Content