updating
This commit is contained in:
@@ -232,6 +232,9 @@ low-dimensional encoding of the data is then given by a set of vectors
|
||||
orthogonal projection of the data onto the columns spanned by the
|
||||
eigenvectors of the covariance(correlations matrix).
|
||||
|
||||
<p>
|
||||
The proof which follows will be updated by mid January 2020.
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
|
||||
@@ -206,9 +206,8 @@ MathJax.Hub.Config({
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec26" class="anchor">Principal Component Analysis </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
Principal Component Analysis (PCA) is by far the most popular dimensionality reduction algorithm.
|
||||
First it identifies the hyperplane that lies closest to the data, and then it projects the data onto it.
|
||||
|
||||
|
||||
@@ -213,11 +213,6 @@ algorithm that quickly finds an approximation of the first d principal component
|
||||
complexity is \( O(m \times d^2)+O(d^3) \), instead of \( O(m \times n^2) + O(n^3) \), so it is dramatically faster than the
|
||||
previous algorithms when \( d \) is much smaller than \( n \).
|
||||
|
||||
<p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
|
||||
@@ -1143,6 +1143,9 @@ low-dimensional encoding of the data is then given by a set of vectors
|
||||
\( \boldsymbol{z}_i \) with at most \( l \) vectors, with \( l < < p \), defined by the
|
||||
orthogonal projection of the data onto the columns spanned by the
|
||||
eigenvectors of the covariance(correlations matrix).
|
||||
|
||||
<p>
|
||||
The proof which follows will be updated by mid January 2020.
|
||||
</section>
|
||||
|
||||
|
||||
@@ -1298,8 +1301,7 @@ This material will be added by mid January 2020.
|
||||
|
||||
<section>
|
||||
<h2 id="___sec26">Principal Component Analysis </h2>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
<b></b>
|
||||
|
||||
<p>
|
||||
Principal Component Analysis (PCA) is by far the most popular dimensionality reduction algorithm.
|
||||
First it identifies the hyperplane that lies closest to the data, and then it projects the data onto it.
|
||||
@@ -1477,9 +1479,6 @@ Scikit-Learn offers yet another option to perform PCA, called Randomized PCA. Th
|
||||
algorithm that quickly finds an approximation of the first d principal components. Its computational
|
||||
complexity is \( O(m \times d^2)+O(d^3) \), instead of \( O(m \times n^2) + O(n^3) \), so it is dramatically faster than the
|
||||
previous algorithms when \( d \) is much smaller than \( n \).
|
||||
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
@@ -1115,6 +1115,9 @@ low-dimensional encoding of the data is then given by a set of vectors
|
||||
orthogonal projection of the data onto the columns spanned by the
|
||||
eigenvectors of the covariance(correlations matrix).
|
||||
|
||||
<p>
|
||||
The proof which follows will be updated by mid January 2020.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
@@ -1245,8 +1248,7 @@ This material will be added by mid January 2020.
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec26">Principal Component Analysis </h2>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
<b></b>
|
||||
|
||||
<p>
|
||||
Principal Component Analysis (PCA) is by far the most popular dimensionality reduction algorithm.
|
||||
First it identifies the hyperplane that lies closest to the data, and then it projects the data onto it.
|
||||
@@ -1257,7 +1259,7 @@ training set, then extracts the first two principal components. First we center
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eee8d5"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">pandas</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">pd</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">IPython.display</span> <span style="color: #8B008B; font-weight: bold">import</span> display
|
||||
np.random.seed(<span style="color: #B452CD">100</span>)
|
||||
@@ -1294,7 +1296,7 @@ Selecting this hyperplane ensures that the projection will preserve as much vari
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eee8d5"><pre style="line-height: 125%"><span></span>W2 = V.T[:, :<span style="color: #B452CD">2</span>]
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span>W2 = V.T[:, :<span style="color: #B452CD">2</span>]
|
||||
X2D = X_centered.dot(W2)
|
||||
</pre></div>
|
||||
<p>
|
||||
@@ -1309,7 +1311,7 @@ that it automatically takes care of centering the data):
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eee8d5"><pre style="line-height: 125%"><span></span><span style="color: #228B22">#thereafter we do a PCA with Scikit-learn</span>
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #228B22">#thereafter we do a PCA with Scikit-learn</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.decomposition</span> <span style="color: #8B008B; font-weight: bold">import</span> PCA
|
||||
pca = PCA(n_components = <span style="color: #B452CD">2</span>)
|
||||
X2D = pca.fit_transform(X)
|
||||
@@ -1322,7 +1324,7 @@ principal component is equal to
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eee8d5"><pre style="line-height: 125%"><span></span>pca.components_.T[:, <span style="color: #B452CD">0</span>].
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span>pca.components_.T[:, <span style="color: #B452CD">0</span>].
|
||||
</pre></div>
|
||||
<p>
|
||||
Another very useful piece of information is the explained variance ratio of each principal component,
|
||||
@@ -1338,7 +1340,7 @@ Here we compute performance scores on the training data using logistic regressio
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eee8d5"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.datasets</span> <span style="color: #8B008B; font-weight: bold">import</span> load_breast_cancer
|
||||
@@ -1385,7 +1387,7 @@ of dimensions required to preserve 95% of the training set’s variance:
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eee8d5"><pre style="line-height: 125%"><span></span>pca = PCA()
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span>pca = PCA()
|
||||
pca.fit(X)
|
||||
cumsum = np.cumsum(pca.explained_variance_ratio_)
|
||||
d = np.argmax(cumsum >= <span style="color: #B452CD">0.95</span>) + <span style="color: #B452CD">1</span>
|
||||
@@ -1397,7 +1399,7 @@ a float between 0.0 and 1.0, indicating the ratio of variance you wish to preser
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eee8d5"><pre style="line-height: 125%"><span></span>pca = PCA(n_components=<span style="color: #B452CD">0.95</span>)
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span>pca = PCA(n_components=<span style="color: #B452CD">0.95</span>)
|
||||
X_reduced = pca.fit_transform(X)
|
||||
</pre></div>
|
||||
<p>
|
||||
@@ -1423,10 +1425,6 @@ algorithm that quickly finds an approximation of the first d principal component
|
||||
complexity is \( O(m \times d^2)+O(d^3) \), instead of \( O(m \times n^2) + O(n^3) \), so it is dramatically faster than the
|
||||
previous algorithms when \( d \) is much smaller than \( n \).
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
|
||||
@@ -1120,6 +1120,9 @@ low-dimensional encoding of the data is then given by a set of vectors
|
||||
orthogonal projection of the data onto the columns spanned by the
|
||||
eigenvectors of the covariance(correlations matrix).
|
||||
|
||||
<p>
|
||||
The proof which follows will be updated by mid January 2020.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
@@ -1250,8 +1253,7 @@ This material will be added by mid January 2020.
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec26">Principal Component Analysis </h2>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
<b></b>
|
||||
|
||||
<p>
|
||||
Principal Component Analysis (PCA) is by far the most popular dimensionality reduction algorithm.
|
||||
First it identifies the hyperplane that lies closest to the data, and then it projects the data onto it.
|
||||
@@ -1428,10 +1430,6 @@ algorithm that quickly finds an approximation of the first d principal component
|
||||
complexity is \( O(m \times d^2)+O(d^3) \), instead of \( O(m \times n^2) + O(n^3) \), so it is dramatically faster than the
|
||||
previous algorithms when \( d \) is much smaller than \( n \).
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
|
||||
@@ -1253,7 +1253,7 @@
|
||||
"orthogonal projection of the data onto the columns spanned by the\n",
|
||||
"eigenvectors of the covariance(correlations matrix).\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"The proof which follows will be updated by mid January 2020.\n",
|
||||
"\n",
|
||||
"## Proof of the PCA Theorem\n",
|
||||
"\n",
|
||||
@@ -1492,6 +1492,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"## Principal Component Analysis\n",
|
||||
"\n",
|
||||
"Principal Component Analysis (PCA) is by far the most popular dimensionality reduction algorithm.\n",
|
||||
"First it identifies the hyperplane that lies closest to the data, and then it projects the data onto it.\n",
|
||||
"\n",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -872,7 +872,7 @@ $\bm{z}_i$ with at most $l$ vectors, with $l << p$, defined by the
|
||||
orthogonal projection of the data onto the columns spanned by the
|
||||
eigenvectors of the covariance(correlations matrix).
|
||||
|
||||
|
||||
The proof which follows will be updated by mid January 2020.
|
||||
|
||||
!split
|
||||
===== Proof of the PCA Theorem =====
|
||||
@@ -1001,7 +1001,7 @@ This material will be added by mid January 2020.
|
||||
|
||||
!split
|
||||
===== Principal Component Analysis =====
|
||||
!bblock
|
||||
|
||||
Principal Component Analysis (PCA) is by far the most popular dimensionality reduction algorithm.
|
||||
First it identifies the hyperplane that lies closest to the data, and then it projects the data onto it.
|
||||
|
||||
@@ -1148,7 +1148,6 @@ complexity is $O(m \times d^2)+O(d^3)$, instead of $O(m \times n^2) + O(n^3)$, s
|
||||
previous algorithms when $d$ is much smaller than $n$.
|
||||
|
||||
|
||||
!eblock
|
||||
|
||||
|
||||
!split
|
||||
|
||||
Reference in New Issue
Block a user