some update of pca
This commit is contained in:
@@ -1049,7 +1049,7 @@ $$
|
||||
When you are done with these steps, print out \( \mu_n \) to verify it is
|
||||
close to \( \mu \) and plot your mean centered data to verify it is
|
||||
centered at the origin! Compare your code with the functionality from <b>Scikit-Learn</b> discussed above.
|
||||
The following code elements perform these operations using <b>pandas</b> or your own functionality for doing so.
|
||||
The following code elements perform these operations using <b>pandas</b> or using our own functionality for doing so. The latter, using <b>numpy</b> is rather simply through the <b>mean()</b> function.
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
@@ -1068,7 +1068,7 @@ Alternatively, you could also have used the functions we discussed earlier for s
|
||||
That is, we could have used the <b>StandardScaler</b> function in <b>Scikit-Learn</b>, a function which
|
||||
ensures that for each feature/predictor we study the mean value is
|
||||
zero and the variance is one (every column in the design/feature
|
||||
matrix).
|
||||
matrix). You would then not get the same results, since we divide by the variance. For diagonal covariance matrix elements will then be one, while the non-diagonal ones will be divided by \( 2\sqrt{2} \) for our specific case.
|
||||
|
||||
<h3 id="___sec19">Compute the sample covariance </h3>
|
||||
|
||||
@@ -1110,11 +1110,11 @@ following tasks:
|
||||
|
||||
$$
|
||||
\begin{equation*}
|
||||
x_i \approx \tilde{x}_i := \mu_n + \langle x_i, v_0 \rangle v_0
|
||||
x_i \approx \tilde{x}_i = \mu_n + \langle x_i, v_0 \rangle v_0
|
||||
\end{equation*}
|
||||
$$
|
||||
|
||||
where \( v_0 \) is the first principal component. What do you observe?
|
||||
where \( v_0 \) is the first principal component.
|
||||
|
||||
<p>
|
||||
Collecting all these steps we can write our own PCA function and
|
||||
|
||||
Reference in New Issue
Block a user