From the course: Data Science Foundations: Data Mining in Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: PCA

Solution: PCA - Python Tutorial

From the course: Data Science Foundations: Data Mining in Python

Start my 1-month free trial

Solution: PCA

- [Instructor] And now I'd like to compare solutions to the PCA challenge. What I'm doing is I'm following the template we had in the PCA demonstration. But I'm going to come down and start by importing the libraries. And then importing our data set. Which again, we're not splitting in to training and testing. We're going to do it all at once. It's the swiss data set. And here's the head, the first five rows that we saw previously. To actually do the principal components analysis, it's really straightforward, again, using the template we had before. I set up the PCA object. Transformed the data because they're on different scales and you need them to be on similar scales. This standardizes them to do that. And then plot the variance explained by each component. And what you see from this is you have a maximum number of components that matches how many variables or features you had. And you can see that the first one…

Contents