diff --git a/doc/pub/DimRed/html/._DimRed-bs018.html b/doc/pub/DimRed/html/._DimRed-bs018.html index a7cce97b1..da98177dc 100644 --- a/doc/pub/DimRed/html/._DimRed-bs018.html +++ b/doc/pub/DimRed/html/._DimRed-bs018.html @@ -374,7 +374,7 @@ X2Dsl = pca.print(pca.components_.T[:, 0])

-This code does not contain all the above elements, but it shows how we can use Scikit-Learn to extract the eigenvector which corresponds to the largest eigenvalue. Try to, based on the above, to address the questions above. +This code does not contain all the above elements, but it shows how we can use Scikit-Learn to extract the eigenvector which corresponds to the largest eigenvalue. Try to address the questions we pose before the above code. Try also to change the values of the covariance matrix by making one of the diagonal elements much larger than the other. What do you observe then?

diff --git a/doc/pub/DimRed/html/DimRed-reveal.html b/doc/pub/DimRed/html/DimRed-reveal.html index 367451ae8..570cd0c98 100644 --- a/doc/pub/DimRed/html/DimRed-reveal.html +++ b/doc/pub/DimRed/html/DimRed-reveal.html @@ -1187,7 +1187,7 @@ X2Dsl = pca.fit_transform(X) print(pca.components_.T[:, 0])

-This code does not contain all the above elements, but it shows how we can use Scikit-Learn to extract the eigenvector which corresponds to the largest eigenvalue. Try to, based on the above, to address the questions above. +This code does not contain all the above elements, but it shows how we can use Scikit-Learn to extract the eigenvector which corresponds to the largest eigenvalue. Try to address the questions we pose before the above code. Try also to change the values of the covariance matrix by making one of the diagonal elements much larger than the other. What do you observe then? diff --git a/doc/pub/DimRed/html/DimRed-solarized.html b/doc/pub/DimRed/html/DimRed-solarized.html index 29d7191d6..3fd9e4333 100644 --- a/doc/pub/DimRed/html/DimRed-solarized.html +++ b/doc/pub/DimRed/html/DimRed-solarized.html @@ -1160,7 +1160,7 @@ X2Dsl = pca.fit_transform(X) print(pca.components_.T[:, 0])

-This code does not contain all the above elements, but it shows how we can use Scikit-Learn to extract the eigenvector which corresponds to the largest eigenvalue. Try to, based on the above, to address the questions above. +This code does not contain all the above elements, but it shows how we can use Scikit-Learn to extract the eigenvector which corresponds to the largest eigenvalue. Try to address the questions we pose before the above code. Try also to change the values of the covariance matrix by making one of the diagonal elements much larger than the other. What do you observe then?











diff --git a/doc/pub/DimRed/html/DimRed.html b/doc/pub/DimRed/html/DimRed.html index 8960e958f..728373253 100644 --- a/doc/pub/DimRed/html/DimRed.html +++ b/doc/pub/DimRed/html/DimRed.html @@ -1165,7 +1165,7 @@ X2Dsl = pca.print(pca.components_.T[:, 0])

-This code does not contain all the above elements, but it shows how we can use Scikit-Learn to extract the eigenvector which corresponds to the largest eigenvalue. Try to, based on the above, to address the questions above. +This code does not contain all the above elements, but it shows how we can use Scikit-Learn to extract the eigenvector which corresponds to the largest eigenvalue. Try to address the questions we pose before the above code. Try also to change the values of the covariance matrix by making one of the diagonal elements much larger than the other. What do you observe then?











diff --git a/doc/pub/DimRed/ipynb/DimRed.ipynb b/doc/pub/DimRed/ipynb/DimRed.ipynb index 2301b9649..ae921523d 100644 --- a/doc/pub/DimRed/ipynb/DimRed.ipynb +++ b/doc/pub/DimRed/ipynb/DimRed.ipynb @@ -1335,7 +1335,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This code does not contain all the above elements, but it shows how we can use **Scikit-Learn** to extract the eigenvector which corresponds to the largest eigenvalue. Try to, based on the above, to address the questions above. \n", + "This code does not contain all the above elements, but it shows how we can use **Scikit-Learn** to extract the eigenvector which corresponds to the largest eigenvalue. Try to address the questions we pose before the above code. Try also to change the values of the covariance matrix by making one of the diagonal elements much larger than the other. What do you observe then? \n", "\n", "## Classical PCA Theorem\n", "\n", diff --git a/doc/pub/DimRed/ipynb/ipynb-DimRed-src.tar.gz b/doc/pub/DimRed/ipynb/ipynb-DimRed-src.tar.gz index 88a78300f..2b31e7165 100644 Binary files a/doc/pub/DimRed/ipynb/ipynb-DimRed-src.tar.gz and b/doc/pub/DimRed/ipynb/ipynb-DimRed-src.tar.gz differ diff --git a/doc/pub/DimRed/pdf/DimRed-minted.pdf b/doc/pub/DimRed/pdf/DimRed-minted.pdf index c79cb2584..99b0277f7 100644 Binary files a/doc/pub/DimRed/pdf/DimRed-minted.pdf and b/doc/pub/DimRed/pdf/DimRed-minted.pdf differ diff --git a/doc/src/DimRed/DimRed.do.txt b/doc/src/DimRed/DimRed.do.txt index 0b7bc1eb0..4f92f64ff 100644 --- a/doc/src/DimRed/DimRed.do.txt +++ b/doc/src/DimRed/DimRed.do.txt @@ -911,7 +911,7 @@ print("Eigenvector of largest eigenvalue") print(pca.components_.T[:, 0]) !ec -This code does not contain all the above elements, but it shows how we can use _Scikit-Learn_ to extract the eigenvector which corresponds to the largest eigenvalue. Try to, based on the above, to address the questions above. +This code does not contain all the above elements, but it shows how we can use _Scikit-Learn_ to extract the eigenvector which corresponds to the largest eigenvalue. Try to address the questions we pose before the above code. Try also to change the values of the covariance matrix by making one of the diagonal elements much larger than the other. What do you observe then? !split ===== Classical PCA Theorem ===== diff --git a/doc/src/DimRed/Programs/PCAsimple.py b/doc/src/DimRed/Programs/PCAsimple.py index c23d51e47..4f06292dd 100644 --- a/doc/src/DimRed/Programs/PCAsimple.py +++ b/doc/src/DimRed/Programs/PCAsimple.py @@ -5,7 +5,7 @@ import matplotlib.pyplot as plt n = 1000 mean = (-1, 2) -cov = [[4, 2], [2, 2]] +cov = [[10, 1], [1, 0.5]] X = np.random.multivariate_normal(mean, cov, n) df = pd.DataFrame(X) @@ -21,8 +21,8 @@ X_centered = X - X.mean(axis=0) print("Centered covariance using numpy") print(np.cov(X_centered.T)) # extract the relevant columns from the centered design matrix -x = X_centered[:,[0]] -y = X_centered[:,[1]] +x = X_centered[:,0] +y = X_centered[:,1] Cov = np.zeros((2,2)) Cov[0,1] = np.sum(x.T@y)/(n-1.0) Cov[0,0] = np.sum(x.T@x)/(n-1.0)