In this lesson, we're going to talk about,

Principal Component Analysis, commonly referred to as PCA.

And, specifically, we're going to see what PCA is used for and then,

moreover, we're going to get into the weeds of how it's performed using Python.

With big data, it's not uncommon to have many different dimensions to your data.

And with all these dimensions,

that can make it hard to process your data for analysis if you have many many records.

But, moreover, it's actually pretty impossible to visualize all these dimensions at once.

So, I'm going to walk through a visualization of how we can use

PCA to reduce the dimensionality of our data.

And, now, while this example is only in two dimensions,

it's really important that you remember that PCA can be

performed on any number of dimensions,

and this is where PCA really derives its power.

So, given a data matrix that has two dimensions,

we can go ahead and compute eigenvector that accounts for the most variance in our data,

and we'll call this PC1 or principal component 1.

Now, it's not super important that you understand when eigenvector is,

but understand that it's being used to demonstrate

the direction and magnitude of where we have the most variance in our data.

Now that we have PC1, we can go ahead and compute another eigenvector,

which is orthogonal to our first component that describes

which direction accounts for the most variance

across the space around our first component.

And now this process is performed for every dimension in our data.

So in this 2D example we're already done.

But, now, I want to emphasize that it's really important to remember

that each principal component is orthogonal to one another.

You'll see why this is important in just one second.

Now that we have these different principal components,

we can transform our data so that instead of it being

described in its original dimensions or features,

it's now being defined by our different principal components.

Now, this is really amazing.

Since all our eigenvectors are orthogonal to one another,

the relationships and correlations that existed

in our pre-transform matrix are preserved.

So, we're viewing most of the same data.

In this case, we're viewing all of the same data,

but now just in a new basis.

And this is where the real power of dimensionality reduction in PCA comes into play.

If we have a higher order matrix,

in this case, with three dimensions,

we can compute just the first two components instead of all three.

And then we can just project those two components

into two-dimensional space. And this is really powerful.

What we've done here is we've taken all of these relationships from our original data or,

in this case, most of the relationships of our data,

the relationships that have the most variance,

and we've clearly projected it into a new space,

where we can easily see and visualize those different relationships and correlations.