diff --git a/doc/pub/DimRed/html/._DimRed-bs000.html b/doc/pub/DimRed/html/._DimRed-bs000.html index 91cab9210..c3c8a51c9 100644 --- a/doc/pub/DimRed/html/._DimRed-bs000.html +++ b/doc/pub/DimRed/html/._DimRed-bs000.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -199,7 +203,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Oct 22, 2019

    +

    Oct 24, 2019


    @@ -223,7 +227,7 @@ MathJax.Hub.Config({

  • 9
  • 10
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs001.html b/doc/pub/DimRed/html/._DimRed-bs001.html index d27224c80..ce342b3b1 100644 --- a/doc/pub/DimRed/html/._DimRed-bs001.html +++ b/doc/pub/DimRed/html/._DimRed-bs001.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -223,7 +227,7 @@ data.
  • 10
  • 11
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs002.html b/doc/pub/DimRed/html/._DimRed-bs002.html index 43db98f35..c537b36a4 100644 --- a/doc/pub/DimRed/html/._DimRed-bs002.html +++ b/doc/pub/DimRed/html/._DimRed-bs002.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -222,7 +226,7 @@ ensures that all features are exactly between \( 0 \) and \( 1 \). The
  • 11
  • 12
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs003.html b/doc/pub/DimRed/html/._DimRed-bs003.html index bf6c5a14b..11eadab08 100644 --- a/doc/pub/DimRed/html/._DimRed-bs003.html +++ b/doc/pub/DimRed/html/._DimRed-bs003.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -225,7 +229,7 @@ techniques.
  • 12
  • 13
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs004.html b/doc/pub/DimRed/html/._DimRed-bs004.html index 3301f1ff5..46e7ba32e 100644 --- a/doc/pub/DimRed/html/._DimRed-bs004.html +++ b/doc/pub/DimRed/html/._DimRed-bs004.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -300,7 +304,7 @@ svm.fit(X_train_scaled, y_train)
  • 13
  • 14
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs005.html b/doc/pub/DimRed/html/._DimRed-bs005.html index 86a86103e..6359652d4 100644 --- a/doc/pub/DimRed/html/._DimRed-bs005.html +++ b/doc/pub/DimRed/html/._DimRed-bs005.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -250,7 +254,7 @@ svm.fit(X_train_scaled, y_train)
  • 14
  • 15
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs006.html b/doc/pub/DimRed/html/._DimRed-bs006.html index 670708858..df43e01cf 100644 --- a/doc/pub/DimRed/html/._DimRed-bs006.html +++ b/doc/pub/DimRed/html/._DimRed-bs006.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -229,7 +233,7 @@ logreg.fit(X_train_scaled, y_train)
  • 15
  • 16
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs007.html b/doc/pub/DimRed/html/._DimRed-bs007.html index df6017a07..e84fa6fa9 100644 --- a/doc/pub/DimRed/html/._DimRed-bs007.html +++ b/doc/pub/DimRed/html/._DimRed-bs007.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -284,7 +288,7 @@ applications.
  • 16
  • 17
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs008.html b/doc/pub/DimRed/html/._DimRed-bs008.html index 61a2e91bc..d78dddb0d 100644 --- a/doc/pub/DimRed/html/._DimRed-bs008.html +++ b/doc/pub/DimRed/html/._DimRed-bs008.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -214,7 +218,7 @@ We have a data set defined by a design/feature matrix \( \boldsymbol{X} \) (see
  • 17
  • 18
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs009.html b/doc/pub/DimRed/html/._DimRed-bs009.html index 2c062364d..d7c080305 100644 --- a/doc/pub/DimRed/html/._DimRed-bs009.html +++ b/doc/pub/DimRed/html/._DimRed-bs009.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -263,7 +267,7 @@ In the above example this is the function we constructed using pandas.
  • 18
  • 19
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs010.html b/doc/pub/DimRed/html/._DimRed-bs010.html index 4dfdd3345..130708b5f 100644 --- a/doc/pub/DimRed/html/._DimRed-bs010.html +++ b/doc/pub/DimRed/html/._DimRed-bs010.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -258,7 +262,7 @@ $$
  • 19
  • 20
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs011.html b/doc/pub/DimRed/html/._DimRed-bs011.html index e13c5c7c3..371c75618 100644 --- a/doc/pub/DimRed/html/._DimRed-bs011.html +++ b/doc/pub/DimRed/html/._DimRed-bs011.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -246,7 +250,7 @@ C = np.c
  • 20
  • 21
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs012.html b/doc/pub/DimRed/html/._DimRed-bs012.html index e1767f7a6..57633c696 100644 --- a/doc/pub/DimRed/html/._DimRed-bs012.html +++ b/doc/pub/DimRed/html/._DimRed-bs012.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -248,7 +252,7 @@ The above procedure with numpy can be made more compact if we use pand
  • 21
  • 22
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs013.html b/doc/pub/DimRed/html/._DimRed-bs013.html index 2c7239f42..8f6909aab 100644 --- a/doc/pub/DimRed/html/._DimRed-bs013.html +++ b/doc/pub/DimRed/html/._DimRed-bs013.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -230,7 +234,7 @@ We expand this model to the Franke function discussed above.
  • 22
  • 23
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs014.html b/doc/pub/DimRed/html/._DimRed-bs014.html index d99b56d86..0b53a02a9 100644 --- a/doc/pub/DimRed/html/._DimRed-bs014.html +++ b/doc/pub/DimRed/html/._DimRed-bs014.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -266,7 +270,7 @@ matrix.
  • 23
  • 24
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs015.html b/doc/pub/DimRed/html/._DimRed-bs015.html index 1c1a2f6f6..990a16b7c 100644 --- a/doc/pub/DimRed/html/._DimRed-bs015.html +++ b/doc/pub/DimRed/html/._DimRed-bs015.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -246,7 +250,7 @@ It is easy to generalize this to a matrix \( \boldsymbol{X}\in {\mathbb{R}}^{n\t
  • 24
  • 25
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs016.html b/doc/pub/DimRed/html/._DimRed-bs016.html index 6c0b5dad2..cbb6d1706 100644 --- a/doc/pub/DimRed/html/._DimRed-bs016.html +++ b/doc/pub/DimRed/html/._DimRed-bs016.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -254,7 +258,7 @@ features/predictors.
  • 25
  • 26
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs017.html b/doc/pub/DimRed/html/._DimRed-bs017.html index c263831ce..5233c395e 100644 --- a/doc/pub/DimRed/html/._DimRed-bs017.html +++ b/doc/pub/DimRed/html/._DimRed-bs017.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -237,7 +241,7 @@ After this we ask ourselves how do we prove the link between the maximum varianc
  • 26
  • 27
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs018.html b/doc/pub/DimRed/html/._DimRed-bs018.html index cdf76d830..c172b2cd4 100644 --- a/doc/pub/DimRed/html/._DimRed-bs018.html +++ b/doc/pub/DimRed/html/._DimRed-bs018.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -193,10 +197,10 @@ J(\boldsymbol{W},\boldsymbol{Z}) = \frac{1}{p}\sum_i (\boldsymbol{x}_i - \overli $$ with \( \overline{\boldsymbol{x}_i} = \boldsymbol{W}\boldsymbol{z}_i \), where \( \boldsymbol{z}_i \) is a row vector with dimension \( {\mathbb{R}}^{n} \) of the matrix -\( \boldsymbol{Z}\in {\mathbb{R}}^{p\times n} \). +\( \boldsymbol{Z}\in {\mathbb{R}}^{p\times n} \). When doing PCA we want to reduce this dimensionality.

    -The PCA theorem states that minimizing the above reconstruction error corresponds to setting \( \boldsymbol{W}=\boldsymbol{S} \), the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors \( l \) $\boldsymbol{z}_i$, with \( l < < p \), defined by the orthogonal projection of the data onto the columns spanned by they eigenvectors of the covariance(correlations matrix). +The PCA theorem states that minimizing the above reconstruction error corresponds to setting \( \boldsymbol{W}=\boldsymbol{S} \), the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors \( l \) $\boldsymbol{z}_i$, with \( l < < p \), defined by the orthogonal projection of the data onto the columns spanned by the eigenvectors of the covariance(correlations matrix).

    @@ -224,7 +228,7 @@ The PCA theorem states that minimizing the above reconstruction error correspond

  • 27
  • 28
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs019.html b/doc/pub/DimRed/html/._DimRed-bs019.html index 313bb5b43..92de15a5a 100644 --- a/doc/pub/DimRed/html/._DimRed-bs019.html +++ b/doc/pub/DimRed/html/._DimRed-bs019.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -183,7 +187,7 @@ MathJax.Hub.Config({

    Proof of the PCA Theorem

    -To show the PCA theorem let us start with the assumption that there is a vector \( \boldsymbol{w}_0 \) which corresponds to a solution which minimized the reconstruction error \( J \). This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of \( \boldsymbol{w}_0 \) and \( \boldsymbol{z}_0 \) as +To show the PCA theorem let us start with the assumption that there is one vector \( \boldsymbol{w}_0 \) which corresponds to a solution which minimized the reconstruction error \( J \). This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of \( \boldsymbol{w}_0 \) and \( \boldsymbol{z}_0 \) as $$ J(\boldsymbol{w}_0,\boldsymbol{z}_0)= \frac{1}{p}\sum_i (\boldsymbol{x}_i - z_{i0}\boldsymbol{w}_0)^2=\frac{1}{p}\sum_i (\boldsymbol{x}_^T\boldsymbol{x}_i - 2z_{i0}\boldsymbol{w}_0^T\boldsymbol{x}_i+z_{i0}^2\boldsymbol{w}_0^T\boldsymbol{w}_0), $$ @@ -225,6 +229,8 @@ where the vectors on the rhs are known.

  • 27
  • 28
  • 29
  • +
  • ...
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs020.html b/doc/pub/DimRed/html/._DimRed-bs020.html index 11b293e38..ec98cd767 100644 --- a/doc/pub/DimRed/html/._DimRed-bs020.html +++ b/doc/pub/DimRed/html/._DimRed-bs020.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -180,18 +184,41 @@ MathJax.Hub.Config({ -

    Getting started with PCA

    +

    PCA Proof continued

    +We have now found the unknown parameters \( z_{i0} \). These correspond to the project coordinates and we can write +$$ +J(\boldsymbol{w}_0)= \frac{1}{p}\sum_i (\boldsymbol{x}_i^T\boldsymbol{x}_i - z_{i0}^2)=\mathrm{const}-\frac{1}{p}\sum_i z_{i0}^2. +$$ - -

    # Now add PCA
    -from sklearn.decomposition import PCA
    -pca = PCA(n_components = 2)
    -pca.fit(X_train_scaled)
    +

    +We can show that the variance of the project coordinates defined by \( \boldsymbol{w}_0^T\boldsymbol{x}_i \) are given by +$$ +\mathrm{var}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \frac{1}{p}\sum_i z_{i0}^2, +$$ + +since the expectation value of +$$ +\mathbb{E}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \mathbb{E}[z_{i0}]= \boldsymbol{w}_0^T\mathbb{E}[\boldsymbol{x}_i]=0, +$$ + +where we have used the fact that our data are centered. + +

    +Recalling our definition of the covariance as +$$ +\boldsymbol{C}[\boldsymbol{x}] = \frac{1}{n}\boldsymbol{X}\boldsymbol{X}^T= \mathbb{E}[\boldsymbol{X}\boldsymbol{X}^T], +$$ + +we have thus that +$$ +\mathrm{var}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \frac{1}{p}\sum_i z_{i0}^2=\boldsymbol{w}_0^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0. +$$ + +

    +We are almost there, we have obtained a relation between minimizing the reconstruction error and the variance and the covariance matrix. Minimizing the error is equivalent to maximizing the variance of the projected data. -X_pca = pca.transform(X_train_scaled) -

    @@ -216,6 +243,9 @@ X_pca = pca.27

  • 28
  • 29
  • +
  • 30
  • +
  • ...
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs021.html b/doc/pub/DimRed/html/._DimRed-bs021.html index d5a312ff5..8d010f1b0 100644 --- a/doc/pub/DimRed/html/._DimRed-bs021.html +++ b/doc/pub/DimRed/html/._DimRed-bs021.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -180,39 +184,38 @@ MathJax.Hub.Config({ -

    Principal Component Analysis

    -
    -
    -

    -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. +

    The final step

    -The following Python code uses NumPy’s svd() function to obtain all the principal components of the -training set, then extracts the first two principal components -

    +We could trivially maximize the variance of the projection (and +thereby minimize the error in the reconstruction function) by letting +the norm-2 of \( \boldsymbol{w}_0 \) go to infinity. However, this norm since we +want the matrix \( \boldsymbol{W} \) to be an orthogonal matrix, is constrained by +\( $\vert\vert \boldsymbol{w}_0 \vert\vert_2^2=1 \). Imposing this condition via a +Lagrange multiplier we can then in turn maximize - -

    X_centered = X - X.mean(axis=0)
    -U, s, V = np.linalg.svd(X_centered)
    -c1 = V.T[:, 0]
    -c2 = V.T[:, 1]
    -
    -

    -PCA assumes that the dataset is centered around the origin. Scikit-Learn’s PCA classes take care of centering -the data for you. However, if you implement PCA yourself (as in the preceding example), or if you use other libraries, don’t -forget to center the data first. +$$ +J(\boldsymbol{w}_0)= \boldsymbol{w}_0^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0+\lambda_0(1-\boldsymbol{w}_0^T\boldsymbol{w}_0). +$$ -

    -Once you have identified all the principal components, you can reduce the dimensionality of the dataset -down to \( d \) dimensions by projecting it onto the hyperplane defined by the first \( d \) principal components. -Selecting this hyperplane ensures that the projection will preserve as much variance as possible. -

    +Taking the derivative with respect to \( \boldsymbol{w}_0 \) we obtain + +$$ +\frac{\partial J(\boldsymbol{w}_0)}{\partial \boldsymbol{w}_0}= 2\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0-2\lambda_0\boldsymbol{w}_0=0, +$$ + +meaning that +$$ +\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0=\lambda_0\boldsymbol{w}_0. +$$ + +The direction that maximizes the variance (or minimizes the construction error) is an eigenvector of the covariance matrix! If we left multiply with \( \boldsymbol{w}_0^T \) we have the variance of the projected data is +$$ +\boldsymbol{w}_^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0=\lambda_0. +$$ + +If we want to maximize the variance (minimize the construction error) we simply pick the eigenvector of the covariance matrix with the largest eigenvalue. This establishes the link between the minimization of the reconstruction function \( J \) in terms of an orthogonal matrix and the maximization of the variance and thereby the covariance of our observations encoded in the design/feature matrix \( \boldsymbol{X} \). The proof for the other eigenvectors \( \boldsymbol{w}_1,\boldsymbol{w}_2,\dots \) cna be established by applying the above arguments and using the fact that basis of eigenvectors is orthogonal, see Murphy chapter 12.2. The discussion in chapter 12.2 of Murphy's text has also a nice link with the Singular Value Decomposition theorem. For categorical data, see chapter 12.4 and discussion therein. - -

    W2 = V.T[:, :2]
    -X2D = X_centered.dot(W2)
    -

    @@ -236,6 +239,8 @@ X2D = X_centered27

  • 28
  • 29
  • +
  • 30
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs022.html b/doc/pub/DimRed/html/._DimRed-bs022.html index 2e2ec0180..b106221a3 100644 --- a/doc/pub/DimRed/html/._DimRed-bs022.html +++ b/doc/pub/DimRed/html/._DimRed-bs022.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -178,36 +182,20 @@ MathJax.Hub.Config({

     

     

     

    - + -

    PCA and scikit-learn

    +

    PCA and Scikit-Learn Functionality

    -

    -Scikit-Learn’s PCA class implements PCA using SVD decomposition just like we did before. The -following code applies PCA to reduce the dimensionality of the dataset down to two dimensions (note -that it automatically takes care of centering the data):

    -

    from sklearn.decomposition import PCA
    +
    # Now add PCA
    +from sklearn.decomposition import PCA
     pca = PCA(n_components = 2)
    -X2D = pca.fit_transform(X)
    -
    -

    -After fitting the PCA transformer to the dataset, you can access the principal components using the -components variable (note that it contains the PCs as horizontal vectors, so, for example, the first -principal component is equal to -

    +pca.fit(X_train_scaled) - -

    pca.components_.T[:, 0]).
    +X_pca = pca.transform(X_train_scaled)
     
    -

    -Another very useful piece of information is the explained variance ratio of each principal component, -available via the \( explained\_variance\_ratio \) variable. It indicates the proportion of the dataset’s -variance that lies along the axis of each principal component. -More material to come here. -

    @@ -230,6 +218,8 @@ More material to come here.

  • 27
  • 28
  • 29
  • +
  • 30
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs023.html b/doc/pub/DimRed/html/._DimRed-bs023.html index aefe56512..cf2b2049f 100644 --- a/doc/pub/DimRed/html/._DimRed-bs023.html +++ b/doc/pub/DimRed/html/._DimRed-bs023.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -180,32 +184,38 @@ MathJax.Hub.Config({ -

    More on the PCA

    +

    Principal Component Analysis

    +
    +
    +

    +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.

    -Instead of arbitrarily choosing the number of dimensions to reduce down to, it is generally preferable to -choose the number of dimensions that add up to a sufficiently large portion of the variance (e.g., 95%). -Unless, of course, you are reducing dimensionality for data visualization — in that case you will -generally want to reduce the dimensionality down to 2 or 3. -The following code computes PCA without reducing dimensionality, then computes the minimum number -of dimensions required to preserve 95% of the training set’s variance: +The following Python code uses NumPy’s svd() function to obtain all the principal components of the +training set, then extracts the first two principal components. First we center the data

    -

    pca = PCA()
    -pca.fit(X)
    -cumsum = np.cumsum(pca.explained_variance_ratio_)
    -d = np.argmax(cumsum >= 0.95) + 1
    +
    X_centered = X - X.mean(axis=0)
    +U, s, V = np.linalg.svd(X_centered)
    +c1 = V.T[:, 0]
    +c2 = V.T[:, 1]
     

    -You could then set \( n\_components=d \) and run PCA again. However, there is a much better option: instead -of specifying the number of principal components you want to preserve, you can set \( n\_components \) to be -a float between 0.0 and 1.0, indicating the ratio of variance you wish to preserve: +PCA assumes that the dataset is centered around the origin. Scikit-Learn’s PCA classes take care of centering +the data for you. However, if you implement PCA yourself (as in the preceding example), or if you use other libraries, don’t +forget to center the data first. + +

    +Once you have identified all the principal components, you can reduce the dimensionality of the dataset +down to \( d \) dimensions by projecting it onto the hyperplane defined by the first \( d \) principal components. +Selecting this hyperplane ensures that the projection will preserve as much variance as possible.

    -

    pca = PCA(n_components=0.95)
    -X_reduced = pca.fit_transform(X)
    +
    W2 = V.T[:, :2]
    +X2D = X_centered.dot(W2)
     

    @@ -228,6 +238,8 @@ X_reduced = pca

  • 27
  • 28
  • 29
  • +
  • 30
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs024.html b/doc/pub/DimRed/html/._DimRed-bs024.html index a86276aa9..70af1ae21 100644 --- a/doc/pub/DimRed/html/._DimRed-bs024.html +++ b/doc/pub/DimRed/html/._DimRed-bs024.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -178,16 +182,35 @@ MathJax.Hub.Config({

     

     

     

    - + -

    Incremental PCA

    +

    PCA and scikit-learn

    -One problem with the preceding implementation of PCA is that it requires the whole training set to fit in -memory in order for the SVD algorithm to run. Fortunately, Incremental PCA (IPCA) algorithms have -been developed: you can split the training set into mini-batches and feed an IPCA algorithm one minibatch -at a time. This is useful for large training sets, and also to apply PCA online (i.e., on the fly, as new -instances arrive). +Scikit-Learn’s PCA class implements PCA using SVD decomposition just like we did before. The +following code applies PCA to reduce the dimensionality of the dataset down to two dimensions (note +that it automatically takes care of centering the data): +

    + + +

    from sklearn.decomposition import PCA
    +pca = PCA(n_components = 2)
    +X2D = pca.fit_transform(X)
    +
    +

    +After fitting the PCA transformer to the dataset, you can access the principal components using the +components variable (note that it contains the PCs as horizontal vectors, so, for example, the first +principal component is equal to +

    + + +

    pca.components_.T[:, 0]).
    +
    +

    +Another very useful piece of information is the explained variance ratio of each principal component, +available via the \( explained\_variance\_ratio \) variable. It indicates the proportion of the dataset’s +variance that lies along the axis of each principal component. +More material to come here.

    @@ -209,6 +232,8 @@ instances arrive).

  • 27
  • 28
  • 29
  • +
  • 30
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs025.html b/doc/pub/DimRed/html/._DimRed-bs025.html index d3fe90508..44a5f82f1 100644 --- a/doc/pub/DimRed/html/._DimRed-bs025.html +++ b/doc/pub/DimRed/html/._DimRed-bs025.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -180,19 +184,33 @@ MathJax.Hub.Config({ -

    Randomized PCA

    +

    More on the PCA

    -Scikit-Learn offers yet another option to perform PCA, called Randomized PCA. This is a stochastic -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 \). - +Instead of arbitrarily choosing the number of dimensions to reduce down to, it is generally preferable to +choose the number of dimensions that add up to a sufficiently large portion of the variance (e.g., 95%). +Unless, of course, you are reducing dimensionality for data visualization — in that case you will +generally want to reduce the dimensionality down to 2 or 3. +The following code computes PCA without reducing dimensionality, then computes the minimum number +of dimensions required to preserve 95% of the training set’s variance:

    -

    -
    + +
    pca = PCA()
    +pca.fit(X)
    +cumsum = np.cumsum(pca.explained_variance_ratio_)
    +d = np.argmax(cumsum >= 0.95) + 1
    +
    +

    +You could then set \( n\_components=d \) and run PCA again. However, there is a much better option: instead +of specifying the number of principal components you want to preserve, you can set \( n\_components \) to be +a float between 0.0 and 1.0, indicating the ratio of variance you wish to preserve: +

    + +

    pca = PCA(n_components=0.95)
    +X_reduced = pca.fit_transform(X)
    +

    @@ -212,6 +230,8 @@ previous algorithms when \( d \) is much smaller than \( n \).

  • 27
  • 28
  • 29
  • +
  • 30
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs026.html b/doc/pub/DimRed/html/._DimRed-bs026.html index e15057617..1dacaf321 100644 --- a/doc/pub/DimRed/html/._DimRed-bs026.html +++ b/doc/pub/DimRed/html/._DimRed-bs026.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -180,32 +184,14 @@ MathJax.Hub.Config({ -

    Kernel PCA

    -
    -
    -

    +

    Incremental PCA

    -The kernel trick is a mathematical technique that implicitly maps instances into a -very high-dimensional space (called the feature space), enabling nonlinear classification and regression -with Support Vector Machines. Recall that a linear decision boundary in the high-dimensional feature -space corresponds to a complex nonlinear decision boundary in the original space. -It turns out that the same trick can be applied to PCA, making it possible to perform complex nonlinear -projections for dimensionality reduction. This is called Kernel PCA (kPCA). It is often good at -preserving clusters of instances after projection, or sometimes even unrolling datasets that lie close to a -twisted manifold. -For example, the following code uses Scikit-Learn’s KernelPCA class to perform kPCA with an -

    - - -

    from sklearn.decomposition import KernelPCA
    -rbf_pca = KernelPCA(n_components = 2, kernel="rbf", gamma=0.04)
    -X_reduced = rbf_pca.fit_transform(X)
    -
    -

    -

    -
    - +One problem with the preceding implementation of PCA is that it requires the whole training set to fit in +memory in order for the SVD algorithm to run. Fortunately, Incremental PCA (IPCA) algorithms have +been developed: you can split the training set into mini-batches and feed an IPCA algorithm one minibatch +at a time. This is useful for large training sets, and also to apply PCA online (i.e., on the fly, as new +instances arrive).

    @@ -225,6 +211,8 @@ X_reduced = rbf_pca27

  • 28
  • 29
  • +
  • 30
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/._DimRed-bs027.html b/doc/pub/DimRed/html/._DimRed-bs027.html index 5d51e8360..0aeb436e1 100644 --- a/doc/pub/DimRed/html/._DimRed-bs027.html +++ b/doc/pub/DimRed/html/._DimRed-bs027.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -180,14 +184,18 @@ MathJax.Hub.Config({ -

    LLE

    +

    Randomized PCA

    -Locally Linear Embedding (LLE) is another very powerful nonlinear dimensionality reduction -(NLDR) technique. It is a Manifold Learning technique that does not rely on projections like the previous -algorithms. In a nutshell, LLE works by first measuring how each training instance linearly relates to its -closest neighbors (c.n.), and then looking for a low-dimensional representation of the training set where -these local relationships are best preserved (more details shortly). +Scikit-Learn offers yet another option to perform PCA, called Randomized PCA. This is a stochastic +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 \). + +

    +

    +
    +

    @@ -206,6 +214,8 @@ these local relationships are best preserved (more details shortly).

  • 27
  • 28
  • 29
  • +
  • 30
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/DimRed-bs.html b/doc/pub/DimRed/html/DimRed-bs.html index 91cab9210..c3c8a51c9 100644 --- a/doc/pub/DimRed/html/DimRed-bs.html +++ b/doc/pub/DimRed/html/DimRed-bs.html @@ -91,15 +91,17 @@ Automatically generated HTML file from DocOnce source ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -156,15 +158,17 @@ MathJax.Hub.Config({
  • The Algorithm before the Theorem
  • Classical PCA Theorem
  • Proof of the PCA Theorem
  • -
  • Getting started with PCA
  • -
  • Principal Component Analysis
  • -
  • PCA and scikit-learn
  • -
  • More on the PCA
  • -
  • Incremental PCA
  • -
  • Randomized PCA
  • -
  • Kernel PCA
  • -
  • LLE
  • -
  • Other techniques
  • +
  • PCA Proof continued
  • +
  • The final step
  • +
  • PCA and Scikit-Learn Functionality
  • +
  • Principal Component Analysis
  • +
  • PCA and scikit-learn
  • +
  • More on the PCA
  • +
  • Incremental PCA
  • +
  • Randomized PCA
  • +
  • Kernel PCA
  • +
  • LLE
  • +
  • Other techniques
  • @@ -199,7 +203,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Oct 22, 2019

    +

    Oct 24, 2019


    @@ -223,7 +227,7 @@ MathJax.Hub.Config({

  • 9
  • 10
  • ...
  • -
  • 29
  • +
  • 31
  • »
  • diff --git a/doc/pub/DimRed/html/DimRed-reveal.html b/doc/pub/DimRed/html/DimRed-reveal.html index b2cdac307..217576ba5 100644 --- a/doc/pub/DimRed/html/DimRed-reveal.html +++ b/doc/pub/DimRed/html/DimRed-reveal.html @@ -148,7 +148,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

     
    -

    Oct 22, 2019

    +

    Oct 24, 2019


    @@ -1004,10 +1004,10 @@ $$

     
    with \( \overline{\boldsymbol{x}_i} = \boldsymbol{W}\boldsymbol{z}_i \), where \( \boldsymbol{z}_i \) is a row vector with dimension \( {\mathbb{R}}^{n} \) of the matrix -\( \boldsymbol{Z}\in {\mathbb{R}}^{p\times n} \). +\( \boldsymbol{Z}\in {\mathbb{R}}^{p\times n} \). When doing PCA we want to reduce this dimensionality.

    -The PCA theorem states that minimizing the above reconstruction error corresponds to setting \( \boldsymbol{W}=\boldsymbol{S} \), the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors \( l \) $\boldsymbol{z}_i$, with \( l < < p \), defined by the orthogonal projection of the data onto the columns spanned by they eigenvectors of the covariance(correlations matrix). +The PCA theorem states that minimizing the above reconstruction error corresponds to setting \( \boldsymbol{W}=\boldsymbol{S} \), the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors \( l \) $\boldsymbol{z}_i$, with \( l < < p \), defined by the orthogonal projection of the data onto the columns spanned by the eigenvectors of the covariance(correlations matrix). @@ -1015,7 +1015,7 @@ The PCA theorem states that minimizing the above reconstruction error correspond

    Proof of the PCA Theorem

    -To show the PCA theorem let us start with the assumption that there is a vector \( \boldsymbol{w}_0 \) which corresponds to a solution which minimized the reconstruction error \( J \). This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of \( \boldsymbol{w}_0 \) and \( \boldsymbol{z}_0 \) as +To show the PCA theorem let us start with the assumption that there is one vector \( \boldsymbol{w}_0 \) which corresponds to a solution which minimized the reconstruction error \( J \). This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of \( \boldsymbol{w}_0 \) and \( \boldsymbol{z}_0 \) as

     
    $$ J(\boldsymbol{w}_0,\boldsymbol{z}_0)= \frac{1}{p}\sum_i (\boldsymbol{x}_i - z_{i0}\boldsymbol{w}_0)^2=\frac{1}{p}\sum_i (\boldsymbol{x}_^T\boldsymbol{x}_i - 2z_{i0}\boldsymbol{w}_0^T\boldsymbol{x}_i+z_{i0}^2\boldsymbol{w}_0^T\boldsymbol{w}_0), @@ -1041,7 +1041,98 @@ where the vectors on the rhs are known.

    -

    Getting started with PCA

    +

    PCA Proof continued

    + +

    +We have now found the unknown parameters \( z_{i0} \). These correspond to the project coordinates and we can write +

     
    +$$ +J(\boldsymbol{w}_0)= \frac{1}{p}\sum_i (\boldsymbol{x}_i^T\boldsymbol{x}_i - z_{i0}^2)=\mathrm{const}-\frac{1}{p}\sum_i z_{i0}^2. +$$ +

     
    + +

    +We can show that the variance of the project coordinates defined by \( \boldsymbol{w}_0^T\boldsymbol{x}_i \) are given by +

     
    +$$ +\mathrm{var}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \frac{1}{p}\sum_i z_{i0}^2, +$$ +

     
    + +since the expectation value of +

     
    +$$ +\mathbb{E}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \mathbb{E}[z_{i0}]= \boldsymbol{w}_0^T\mathbb{E}[\boldsymbol{x}_i]=0, +$$ +

     
    + +where we have used the fact that our data are centered. + +

    +Recalling our definition of the covariance as +

     
    +$$ +\boldsymbol{C}[\boldsymbol{x}] = \frac{1}{n}\boldsymbol{X}\boldsymbol{X}^T= \mathbb{E}[\boldsymbol{X}\boldsymbol{X}^T], +$$ +

     
    + +we have thus that +

     
    +$$ +\mathrm{var}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \frac{1}{p}\sum_i z_{i0}^2=\boldsymbol{w}_0^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0. +$$ +

     
    + +

    +We are almost there, we have obtained a relation between minimizing the reconstruction error and the variance and the covariance matrix. Minimizing the error is equivalent to maximizing the variance of the projected data. +

    + + +
    +

    The final step

    + +

    +We could trivially maximize the variance of the projection (and +thereby minimize the error in the reconstruction function) by letting +the norm-2 of \( \boldsymbol{w}_0 \) go to infinity. However, this norm since we +want the matrix \( \boldsymbol{W} \) to be an orthogonal matrix, is constrained by +\( $\vert\vert \boldsymbol{w}_0 \vert\vert_2^2=1 \). Imposing this condition via a +Lagrange multiplier we can then in turn maximize + +

     
    +$$ +J(\boldsymbol{w}_0)= \boldsymbol{w}_0^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0+\lambda_0(1-\boldsymbol{w}_0^T\boldsymbol{w}_0). +$$ +

     
    + +Taking the derivative with respect to \( \boldsymbol{w}_0 \) we obtain + +

     
    +$$ +\frac{\partial J(\boldsymbol{w}_0)}{\partial \boldsymbol{w}_0}= 2\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0-2\lambda_0\boldsymbol{w}_0=0, +$$ +

     
    + +meaning that +

     
    +$$ +\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0=\lambda_0\boldsymbol{w}_0. +$$ +

     
    + +The direction that maximizes the variance (or minimizes the construction error) is an eigenvector of the covariance matrix! If we left multiply with \( \boldsymbol{w}_0^T \) we have the variance of the projected data is +

     
    +$$ +\boldsymbol{w}_^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0=\lambda_0. +$$ +

     
    + +If we want to maximize the variance (minimize the construction error) we simply pick the eigenvector of the covariance matrix with the largest eigenvalue. This establishes the link between the minimization of the reconstruction function \( J \) in terms of an orthogonal matrix and the maximization of the variance and thereby the covariance of our observations encoded in the design/feature matrix \( \boldsymbol{X} \). The proof for the other eigenvectors \( \boldsymbol{w}_1,\boldsymbol{w}_2,\dots \) cna be established by applying the above arguments and using the fact that basis of eigenvectors is orthogonal, see Murphy chapter 12.2. The discussion in chapter 12.2 of Murphy's text has also a nice link with the Singular Value Decomposition theorem. For categorical data, see chapter 12.4 and discussion therein. +

    + + +
    +

    PCA and Scikit-Learn Functionality

    @@ -1057,7 +1148,7 @@ X_pca = pca.transform(X_train_scaled)

    -

    Principal Component Analysis

    +

    Principal Component Analysis

    @@ -1066,7 +1157,7 @@ First it identifies the hyperplane that lies closest to the data, and then it pr

    The following Python code uses NumPy’s svd() function to obtain all the principal components of the -training set, then extracts the first two principal components +training set, then extracts the first two principal components. First we center the data

    @@ -1094,7 +1185,7 @@ X2D = X_centered.dot(W2)

    -

    PCA and scikit-learn

    +

    PCA and scikit-learn

    Scikit-Learn’s PCA class implements PCA using SVD decomposition just like we did before. The @@ -1125,7 +1216,7 @@ More material to come here.

    -

    More on the PCA

    +

    More on the PCA

    Instead of arbitrarily choosing the number of dimensions to reduce down to, it is generally preferable to @@ -1156,7 +1247,7 @@ X_reduced = pca.fit_transform(X)

    -

    Incremental PCA

    +

    Incremental PCA

    One problem with the preceding implementation of PCA is that it requires the whole training set to fit in @@ -1168,7 +1259,7 @@ instances arrive).

    -

    Randomized PCA

    +

    Randomized PCA

    Scikit-Learn offers yet another option to perform PCA, called Randomized PCA. This is a stochastic @@ -1182,7 +1273,7 @@ previous algorithms when \( d \) is much smaller than \( n \).

    -

    Kernel PCA

    +

    Kernel PCA

    @@ -1208,7 +1299,7 @@ X_reduced = rbf_pca.fit_transform(X)

    -

    LLE

    +

    LLE

    Locally Linear Embedding (LLE) is another very powerful nonlinear dimensionality reduction @@ -1220,7 +1311,7 @@ these local relationships are best preserved (more details shortly).

    -

    Other techniques

    +

    Other techniques

    There are many other dimensionality reduction techniques, several of which are available in Scikit-Learn. @@ -1255,42 +1346,6 @@ display(df) print(df.std()) display(df**2)

    -

    -Thereafter we can select specific columns only and plot final results -

    - - -

    df.columns = ['First', 'Second', 'Third', 'Fourth', 'Fifth']
    -df.index = np.arange(10)
    -
    -display(df)
    -print(df['Second'].mean() )
    -print(df.info())
    -print(df.describe())
    -
    -from pylab import plt, mpl
    -plt.style.use('seaborn')
    -mpl.rcParams['font.family'] = 'serif'
    -
    -df.cumsum().plot(lw=2.0, figsize=(10,6))
    -plt.show()
    -
    -
    -df.plot.bar(figsize=(10,6), rot=15)
    -plt.show()
    -
    -

    -We can produce a \( 4\times 4 \) matrix -

    - - -

    b = np.arange(16).reshape((4,4))
    -print(b)
    -df1 = pd.DataFrame(b)
    -print(df1)
    -
    -

    -and many other operations. diff --git a/doc/pub/DimRed/html/DimRed-solarized.html b/doc/pub/DimRed/html/DimRed-solarized.html index 908e6efc9..e9cc33dae 100644 --- a/doc/pub/DimRed/html/DimRed-solarized.html +++ b/doc/pub/DimRed/html/DimRed-solarized.html @@ -111,15 +111,17 @@ div { text-align: justify; text-justify: inter-word; } ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -161,7 +163,7 @@ MathJax.Hub.Config({

    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Oct 22, 2019

    +

    Oct 24, 2019












    @@ -966,10 +968,10 @@ J(\boldsymbol{W},\boldsymbol{Z}) = \frac{1}{p}\sum_i (\boldsymbol{x}_i - \overli $$ with \( \overline{\boldsymbol{x}_i} = \boldsymbol{W}\boldsymbol{z}_i \), where \( \boldsymbol{z}_i \) is a row vector with dimension \( {\mathbb{R}}^{n} \) of the matrix -\( \boldsymbol{Z}\in {\mathbb{R}}^{p\times n} \). +\( \boldsymbol{Z}\in {\mathbb{R}}^{p\times n} \). When doing PCA we want to reduce this dimensionality.

    -The PCA theorem states that minimizing the above reconstruction error corresponds to setting \( \boldsymbol{W}=\boldsymbol{S} \), the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors \( l \) $\boldsymbol{z}_i$, with \( l < < p \), defined by the orthogonal projection of the data onto the columns spanned by they eigenvectors of the covariance(correlations matrix). +The PCA theorem states that minimizing the above reconstruction error corresponds to setting \( \boldsymbol{W}=\boldsymbol{S} \), the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors \( l \) $\boldsymbol{z}_i$, with \( l < < p \), defined by the orthogonal projection of the data onto the columns spanned by the eigenvectors of the covariance(correlations matrix).











    @@ -977,7 +979,7 @@ The PCA theorem states that minimizing the above reconstruction error correspond

    Proof of the PCA Theorem

    -To show the PCA theorem let us start with the assumption that there is a vector \( \boldsymbol{w}_0 \) which corresponds to a solution which minimized the reconstruction error \( J \). This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of \( \boldsymbol{w}_0 \) and \( \boldsymbol{z}_0 \) as +To show the PCA theorem let us start with the assumption that there is one vector \( \boldsymbol{w}_0 \) which corresponds to a solution which minimized the reconstruction error \( J \). This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of \( \boldsymbol{w}_0 \) and \( \boldsymbol{z}_0 \) as $$ J(\boldsymbol{w}_0,\boldsymbol{z}_0)= \frac{1}{p}\sum_i (\boldsymbol{x}_i - z_{i0}\boldsymbol{w}_0)^2=\frac{1}{p}\sum_i (\boldsymbol{x}_^T\boldsymbol{x}_i - 2z_{i0}\boldsymbol{w}_0^T\boldsymbol{x}_i+z_{i0}^2\boldsymbol{w}_0^T\boldsymbol{w}_0), $$ @@ -997,7 +999,80 @@ where the vectors on the rhs are known.











    -

    Getting started with PCA

    +

    PCA Proof continued

    + +

    +We have now found the unknown parameters \( z_{i0} \). These correspond to the project coordinates and we can write +$$ +J(\boldsymbol{w}_0)= \frac{1}{p}\sum_i (\boldsymbol{x}_i^T\boldsymbol{x}_i - z_{i0}^2)=\mathrm{const}-\frac{1}{p}\sum_i z_{i0}^2. +$$ + +

    +We can show that the variance of the project coordinates defined by \( \boldsymbol{w}_0^T\boldsymbol{x}_i \) are given by +$$ +\mathrm{var}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \frac{1}{p}\sum_i z_{i0}^2, +$$ + +since the expectation value of +$$ +\mathbb{E}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \mathbb{E}[z_{i0}]= \boldsymbol{w}_0^T\mathbb{E}[\boldsymbol{x}_i]=0, +$$ + +where we have used the fact that our data are centered. + +

    +Recalling our definition of the covariance as +$$ +\boldsymbol{C}[\boldsymbol{x}] = \frac{1}{n}\boldsymbol{X}\boldsymbol{X}^T= \mathbb{E}[\boldsymbol{X}\boldsymbol{X}^T], +$$ + +we have thus that +$$ +\mathrm{var}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \frac{1}{p}\sum_i z_{i0}^2=\boldsymbol{w}_0^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0. +$$ + +

    +We are almost there, we have obtained a relation between minimizing the reconstruction error and the variance and the covariance matrix. Minimizing the error is equivalent to maximizing the variance of the projected data. + +

    +









    + +

    The final step

    + +

    +We could trivially maximize the variance of the projection (and +thereby minimize the error in the reconstruction function) by letting +the norm-2 of \( \boldsymbol{w}_0 \) go to infinity. However, this norm since we +want the matrix \( \boldsymbol{W} \) to be an orthogonal matrix, is constrained by +\( $\vert\vert \boldsymbol{w}_0 \vert\vert_2^2=1 \). Imposing this condition via a +Lagrange multiplier we can then in turn maximize + +$$ +J(\boldsymbol{w}_0)= \boldsymbol{w}_0^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0+\lambda_0(1-\boldsymbol{w}_0^T\boldsymbol{w}_0). +$$ + +Taking the derivative with respect to \( \boldsymbol{w}_0 \) we obtain + +$$ +\frac{\partial J(\boldsymbol{w}_0)}{\partial \boldsymbol{w}_0}= 2\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0-2\lambda_0\boldsymbol{w}_0=0, +$$ + +meaning that +$$ +\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0=\lambda_0\boldsymbol{w}_0. +$$ + +The direction that maximizes the variance (or minimizes the construction error) is an eigenvector of the covariance matrix! If we left multiply with \( \boldsymbol{w}_0^T \) we have the variance of the projected data is +$$ +\boldsymbol{w}_^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0=\lambda_0. +$$ + +If we want to maximize the variance (minimize the construction error) we simply pick the eigenvector of the covariance matrix with the largest eigenvalue. This establishes the link between the minimization of the reconstruction function \( J \) in terms of an orthogonal matrix and the maximization of the variance and thereby the covariance of our observations encoded in the design/feature matrix \( \boldsymbol{X} \). The proof for the other eigenvectors \( \boldsymbol{w}_1,\boldsymbol{w}_2,\dots \) cna be established by applying the above arguments and using the fact that basis of eigenvectors is orthogonal, see Murphy chapter 12.2. The discussion in chapter 12.2 of Murphy's text has also a nice link with the Singular Value Decomposition theorem. For categorical data, see chapter 12.4 and discussion therein. + +

    +









    + +

    PCA and Scikit-Learn Functionality

    @@ -1012,7 +1087,7 @@ X_pca = pca.transform(X_train_scaled)











    -

    Principal Component Analysis

    +

    Principal Component Analysis

    @@ -1021,7 +1096,7 @@ First it identifies the hyperplane that lies closest to the data, and then it pr

    The following Python code uses NumPy’s svd() function to obtain all the principal components of the -training set, then extracts the first two principal components +training set, then extracts the first two principal components. First we center the data

    @@ -1048,7 +1123,7 @@ X2D = X_centered.dot(W2)

    -

    PCA and scikit-learn

    +

    PCA and scikit-learn

    Scikit-Learn’s PCA class implements PCA using SVD decomposition just like we did before. The @@ -1079,7 +1154,7 @@ More material to come here.











    -

    More on the PCA

    +

    More on the PCA

    Instead of arbitrarily choosing the number of dimensions to reduce down to, it is generally preferable to @@ -1109,7 +1184,7 @@ X_reduced = pca.fit_transform(X)











    -

    Incremental PCA

    +

    Incremental PCA

    One problem with the preceding implementation of PCA is that it requires the whole training set to fit in @@ -1121,7 +1196,7 @@ instances arrive).











    -

    Randomized PCA

    +

    Randomized PCA

    Scikit-Learn offers yet another option to perform PCA, called Randomized PCA. This is a stochastic @@ -1136,7 +1211,7 @@ previous algorithms when \( d \) is much smaller than \( n \).











    -

    Kernel PCA

    +

    Kernel PCA

    @@ -1165,7 +1240,7 @@ X_reduced = rbf_pca.fit_transform(X)











    -

    LLE

    +

    LLE

    Locally Linear Embedding (LLE) is another very powerful nonlinear dimensionality reduction @@ -1177,7 +1252,7 @@ these local relationships are best preserved (more details shortly).











    -

    Other techniques

    +

    Other techniques

    There are many other dimensionality reduction techniques, several of which are available in Scikit-Learn. @@ -1212,41 +1287,6 @@ display(df) display(df**2)

    -Thereafter we can select specific columns only and plot final results -

    - - -

    df.columns = ['First', 'Second', 'Third', 'Fourth', 'Fifth']
    -df.index = np.arange(10)
    -
    -display(df)
    -print(df['Second'].mean() )
    -print(df.info())
    -print(df.describe())
    -
    -from pylab import plt, mpl
    -plt.style.use('seaborn')
    -mpl.rcParams['font.family'] = 'serif'
    -
    -df.cumsum().plot(lw=2.0, figsize=(10,6))
    -plt.show()
    -
    -
    -df.plot.bar(figsize=(10,6), rot=15)
    -plt.show()
    -
    -

    -We can produce a \( 4\times 4 \) matrix -

    - - -

    b = np.arange(16).reshape((4,4))
    -print(b)
    -df1 = pd.DataFrame(b)
    -print(df1)
    -
    -

    -and many other operations. diff --git a/doc/pub/DimRed/html/DimRed.html b/doc/pub/DimRed/html/DimRed.html index d9d23455b..e3bc0b44a 100644 --- a/doc/pub/DimRed/html/DimRed.html +++ b/doc/pub/DimRed/html/DimRed.html @@ -116,15 +116,17 @@ div { text-align: justify; text-justify: inter-word; } ('The Algorithm before the Theorem', 2, None, '___sec16'), ('Classical PCA Theorem', 2, None, '___sec17'), ('Proof of the PCA Theorem', 2, None, '___sec18'), - ('Getting started with PCA', 2, None, '___sec19'), - ('Principal Component Analysis', 2, None, '___sec20'), - ('PCA and scikit-learn', 2, None, '___sec21'), - ('More on the PCA', 2, None, '___sec22'), - ('Incremental PCA', 2, None, '___sec23'), - ('Randomized PCA', 2, None, '___sec24'), - ('Kernel PCA', 2, None, '___sec25'), - ('LLE', 2, None, '___sec26'), - ('Other techniques', 2, None, '___sec27')]} + ('PCA Proof continued', 2, None, '___sec19'), + ('The final step', 2, None, '___sec20'), + ('PCA and Scikit-Learn Functionality', 2, None, '___sec21'), + ('Principal Component Analysis', 2, None, '___sec22'), + ('PCA and scikit-learn', 2, None, '___sec23'), + ('More on the PCA', 2, None, '___sec24'), + ('Incremental PCA', 2, None, '___sec25'), + ('Randomized PCA', 2, None, '___sec26'), + ('Kernel PCA', 2, None, '___sec27'), + ('LLE', 2, None, '___sec28'), + ('Other techniques', 2, None, '___sec29')]} end of tocinfo --> @@ -166,7 +168,7 @@ MathJax.Hub.Config({

    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Oct 22, 2019

    +

    Oct 24, 2019












    @@ -971,10 +973,10 @@ J(\boldsymbol{W},\boldsymbol{Z}) = \frac{1}{p}\sum_i (\boldsymbol{x}_i - \overli $$ with \( \overline{\boldsymbol{x}_i} = \boldsymbol{W}\boldsymbol{z}_i \), where \( \boldsymbol{z}_i \) is a row vector with dimension \( {\mathbb{R}}^{n} \) of the matrix -\( \boldsymbol{Z}\in {\mathbb{R}}^{p\times n} \). +\( \boldsymbol{Z}\in {\mathbb{R}}^{p\times n} \). When doing PCA we want to reduce this dimensionality.

    -The PCA theorem states that minimizing the above reconstruction error corresponds to setting \( \boldsymbol{W}=\boldsymbol{S} \), the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors \( l \) $\boldsymbol{z}_i$, with \( l < < p \), defined by the orthogonal projection of the data onto the columns spanned by they eigenvectors of the covariance(correlations matrix). +The PCA theorem states that minimizing the above reconstruction error corresponds to setting \( \boldsymbol{W}=\boldsymbol{S} \), the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors \( l \) $\boldsymbol{z}_i$, with \( l < < p \), defined by the orthogonal projection of the data onto the columns spanned by the eigenvectors of the covariance(correlations matrix).











    @@ -982,7 +984,7 @@ The PCA theorem states that minimizing the above reconstruction error correspond

    Proof of the PCA Theorem

    -To show the PCA theorem let us start with the assumption that there is a vector \( \boldsymbol{w}_0 \) which corresponds to a solution which minimized the reconstruction error \( J \). This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of \( \boldsymbol{w}_0 \) and \( \boldsymbol{z}_0 \) as +To show the PCA theorem let us start with the assumption that there is one vector \( \boldsymbol{w}_0 \) which corresponds to a solution which minimized the reconstruction error \( J \). This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of \( \boldsymbol{w}_0 \) and \( \boldsymbol{z}_0 \) as $$ J(\boldsymbol{w}_0,\boldsymbol{z}_0)= \frac{1}{p}\sum_i (\boldsymbol{x}_i - z_{i0}\boldsymbol{w}_0)^2=\frac{1}{p}\sum_i (\boldsymbol{x}_^T\boldsymbol{x}_i - 2z_{i0}\boldsymbol{w}_0^T\boldsymbol{x}_i+z_{i0}^2\boldsymbol{w}_0^T\boldsymbol{w}_0), $$ @@ -1002,7 +1004,80 @@ where the vectors on the rhs are known.











    -

    Getting started with PCA

    +

    PCA Proof continued

    + +

    +We have now found the unknown parameters \( z_{i0} \). These correspond to the project coordinates and we can write +$$ +J(\boldsymbol{w}_0)= \frac{1}{p}\sum_i (\boldsymbol{x}_i^T\boldsymbol{x}_i - z_{i0}^2)=\mathrm{const}-\frac{1}{p}\sum_i z_{i0}^2. +$$ + +

    +We can show that the variance of the project coordinates defined by \( \boldsymbol{w}_0^T\boldsymbol{x}_i \) are given by +$$ +\mathrm{var}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \frac{1}{p}\sum_i z_{i0}^2, +$$ + +since the expectation value of +$$ +\mathbb{E}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \mathbb{E}[z_{i0}]= \boldsymbol{w}_0^T\mathbb{E}[\boldsymbol{x}_i]=0, +$$ + +where we have used the fact that our data are centered. + +

    +Recalling our definition of the covariance as +$$ +\boldsymbol{C}[\boldsymbol{x}] = \frac{1}{n}\boldsymbol{X}\boldsymbol{X}^T= \mathbb{E}[\boldsymbol{X}\boldsymbol{X}^T], +$$ + +we have thus that +$$ +\mathrm{var}[\boldsymbol{w}_0^T\boldsymbol{x}_i] = \frac{1}{p}\sum_i z_{i0}^2=\boldsymbol{w}_0^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0. +$$ + +

    +We are almost there, we have obtained a relation between minimizing the reconstruction error and the variance and the covariance matrix. Minimizing the error is equivalent to maximizing the variance of the projected data. + +

    +









    + +

    The final step

    + +

    +We could trivially maximize the variance of the projection (and +thereby minimize the error in the reconstruction function) by letting +the norm-2 of \( \boldsymbol{w}_0 \) go to infinity. However, this norm since we +want the matrix \( \boldsymbol{W} \) to be an orthogonal matrix, is constrained by +\( $\vert\vert \boldsymbol{w}_0 \vert\vert_2^2=1 \). Imposing this condition via a +Lagrange multiplier we can then in turn maximize + +$$ +J(\boldsymbol{w}_0)= \boldsymbol{w}_0^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0+\lambda_0(1-\boldsymbol{w}_0^T\boldsymbol{w}_0). +$$ + +Taking the derivative with respect to \( \boldsymbol{w}_0 \) we obtain + +$$ +\frac{\partial J(\boldsymbol{w}_0)}{\partial \boldsymbol{w}_0}= 2\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0-2\lambda_0\boldsymbol{w}_0=0, +$$ + +meaning that +$$ +\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0=\lambda_0\boldsymbol{w}_0. +$$ + +The direction that maximizes the variance (or minimizes the construction error) is an eigenvector of the covariance matrix! If we left multiply with \( \boldsymbol{w}_0^T \) we have the variance of the projected data is +$$ +\boldsymbol{w}_^T\boldsymbol{C}[\boldsymbol{x}]\boldsymbol{w}_0=\lambda_0. +$$ + +If we want to maximize the variance (minimize the construction error) we simply pick the eigenvector of the covariance matrix with the largest eigenvalue. This establishes the link between the minimization of the reconstruction function \( J \) in terms of an orthogonal matrix and the maximization of the variance and thereby the covariance of our observations encoded in the design/feature matrix \( \boldsymbol{X} \). The proof for the other eigenvectors \( \boldsymbol{w}_1,\boldsymbol{w}_2,\dots \) cna be established by applying the above arguments and using the fact that basis of eigenvectors is orthogonal, see Murphy chapter 12.2. The discussion in chapter 12.2 of Murphy's text has also a nice link with the Singular Value Decomposition theorem. For categorical data, see chapter 12.4 and discussion therein. + +

    +









    + +

    PCA and Scikit-Learn Functionality

    @@ -1017,7 +1092,7 @@ X_pca = pca.









    -

    Principal Component Analysis

    +

    Principal Component Analysis

    @@ -1026,7 +1101,7 @@ First it identifies the hyperplane that lies closest to the data, and then it pr

    The following Python code uses NumPy’s svd() function to obtain all the principal components of the -training set, then extracts the first two principal components +training set, then extracts the first two principal components. First we center the data

    @@ -1053,7 +1128,7 @@ X2D = X_centered -

    PCA and scikit-learn

    +

    PCA and scikit-learn

    Scikit-Learn’s PCA class implements PCA using SVD decomposition just like we did before. The @@ -1084,7 +1159,7 @@ More material to come here.











    -

    More on the PCA

    +

    More on the PCA

    Instead of arbitrarily choosing the number of dimensions to reduce down to, it is generally preferable to @@ -1114,7 +1189,7 @@ X_reduced = pca











    -

    Incremental PCA

    +

    Incremental PCA

    One problem with the preceding implementation of PCA is that it requires the whole training set to fit in @@ -1126,7 +1201,7 @@ instances arrive).











    -

    Randomized PCA

    +

    Randomized PCA

    Scikit-Learn offers yet another option to perform PCA, called Randomized PCA. This is a stochastic @@ -1141,7 +1216,7 @@ previous algorithms when \( d \) is much smaller than \( n \).











    -

    Kernel PCA

    +

    Kernel PCA

    @@ -1170,7 +1245,7 @@ X_reduced = rbf_pcaLLE +

    LLE

    Locally Linear Embedding (LLE) is another very powerful nonlinear dimensionality reduction @@ -1182,7 +1257,7 @@ these local relationships are best preserved (more details shortly).











    -

    Other techniques

    +

    Other techniques

    There are many other dimensionality reduction techniques, several of which are available in Scikit-Learn. @@ -1217,41 +1292,6 @@ display(df) display(df**2)

    -Thereafter we can select specific columns only and plot final results -

    - - -

    df.columns = ['First', 'Second', 'Third', 'Fourth', 'Fifth']
    -df.index = np.arange(10)
    -
    -display(df)
    -print(df['Second'].mean() )
    -print(df.info())
    -print(df.describe())
    -
    -from pylab import plt, mpl
    -plt.style.use('seaborn')
    -mpl.rcParams['font.family'] = 'serif'
    -
    -df.cumsum().plot(lw=2.0, figsize=(10,6))
    -plt.show()
    -
    -
    -df.plot.bar(figsize=(10,6), rot=15)
    -plt.show()
    -
    -

    -We can produce a \( 4\times 4 \) matrix -

    - - -

    b = np.arange(16).reshape((4,4))
    -print(b)
    -df1 = pd.DataFrame(b)
    -print(df1)
    -
    -

    -and many other operations. diff --git a/doc/pub/DimRed/ipynb/DimRed.ipynb b/doc/pub/DimRed/ipynb/DimRed.ipynb index dfc5ebe65..4ac228c70 100644 --- a/doc/pub/DimRed/ipynb/DimRed.ipynb +++ b/doc/pub/DimRed/ipynb/DimRed.ipynb @@ -10,7 +10,7 @@ " \n", "**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University\n", "\n", - "Date: **Oct 22, 2019**\n", + "Date: **Oct 24, 2019**\n", "\n", "Copyright 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license\n", "\n", @@ -1073,15 +1073,15 @@ "metadata": {}, "source": [ "with $\\overline{\\boldsymbol{x}_i} = \\boldsymbol{W}\\boldsymbol{z}_i$, where $\\boldsymbol{z}_i$ is a row vector with dimension ${\\mathbb{R}}^{n}$ of the matrix\n", - "$\\boldsymbol{Z}\\in {\\mathbb{R}}^{p\\times n}$. \n", + "$\\boldsymbol{Z}\\in {\\mathbb{R}}^{p\\times n}$. When doing PCA we want to reduce this dimensionality. \n", "\n", - "The PCA theorem states that minimizing the above reconstruction error corresponds to setting $\\boldsymbol{W}=\\boldsymbol{S}$, the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors $l$ $\\boldsymbol{z}_i$, with $l << p$, defined by the orthogonal projection of the data onto the columns spanned by they eigenvectors of the covariance(correlations matrix).\n", + "The PCA theorem states that minimizing the above reconstruction error corresponds to setting $\\boldsymbol{W}=\\boldsymbol{S}$, the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors $l$ $\\boldsymbol{z}_i$, with $l << p$, defined by the orthogonal projection of the data onto the columns spanned by the eigenvectors of the covariance(correlations matrix).\n", "\n", "\n", "\n", "## Proof of the PCA Theorem\n", "\n", - "To show the PCA theorem let us start with the assumption that there is a vector $\\boldsymbol{w}_0$ which corresponds to a solution which minimized the reconstruction error $J$. This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of $\\boldsymbol{w}_0$ and $\\boldsymbol{z}_0$ as" + "To show the PCA theorem let us start with the assumption that there is one vector $\\boldsymbol{w}_0$ which corresponds to a solution which minimized the reconstruction error $J$. This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of $\\boldsymbol{w}_0$ and $\\boldsymbol{z}_0$ as" ] }, { @@ -1131,7 +1131,170 @@ "source": [ "where the vectors on the rhs are known. \n", "\n", - "## Getting started with PCA" + "\n", + "## PCA Proof continued\n", + "\n", + "We have now found the unknown parameters $z_{i0}$. These correspond to the project coordinates and we can write" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "J(\\boldsymbol{w}_0)= \\frac{1}{p}\\sum_i (\\boldsymbol{x}_i^T\\boldsymbol{x}_i - z_{i0}^2)=\\mathrm{const}-\\frac{1}{p}\\sum_i z_{i0}^2.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can show that the variance of the project coordinates defined by $\\boldsymbol{w}_0^T\\boldsymbol{x}_i$ are given by" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "\\mathrm{var}[\\boldsymbol{w}_0^T\\boldsymbol{x}_i] = \\frac{1}{p}\\sum_i z_{i0}^2,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "since the expectation value of" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "\\mathbb{E}[\\boldsymbol{w}_0^T\\boldsymbol{x}_i] = \\mathbb{E}[z_{i0}]= \\boldsymbol{w}_0^T\\mathbb{E}[\\boldsymbol{x}_i]=0,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "where we have used the fact that our data are centered.\n", + "\n", + "Recalling our definition of the covariance as" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "\\boldsymbol{C}[\\boldsymbol{x}] = \\frac{1}{n}\\boldsymbol{X}\\boldsymbol{X}^T= \\mathbb{E}[\\boldsymbol{X}\\boldsymbol{X}^T],\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "we have thus that" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "\\mathrm{var}[\\boldsymbol{w}_0^T\\boldsymbol{x}_i] = \\frac{1}{p}\\sum_i z_{i0}^2=\\boldsymbol{w}_0^T\\boldsymbol{C}[\\boldsymbol{x}]\\boldsymbol{w}_0.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We are almost there, we have obtained a relation between minimizing the reconstruction error and the variance and the covariance matrix. Minimizing the error is equivalent to maximizing the variance of the projected data. \n", + "\n", + "## The final step\n", + "\n", + "We could trivially maximize the variance of the projection (and\n", + "thereby minimize the error in the reconstruction function) by letting\n", + "the norm-2 of $\\boldsymbol{w}_0$ go to infinity. However, this norm since we\n", + "want the matrix $\\boldsymbol{W}$ to be an orthogonal matrix, is constrained by\n", + "$$\\vert\\vert \\boldsymbol{w}_0 \\vert\\vert_2^2=1$. Imposing this condition via a\n", + "Lagrange multiplier we can then in turn maximize" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "J(\\boldsymbol{w}_0)= \\boldsymbol{w}_0^T\\boldsymbol{C}[\\boldsymbol{x}]\\boldsymbol{w}_0+\\lambda_0(1-\\boldsymbol{w}_0^T\\boldsymbol{w}_0).\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Taking the derivative with respect to $\\boldsymbol{w}_0$ we obtain" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "\\frac{\\partial J(\\boldsymbol{w}_0)}{\\partial \\boldsymbol{w}_0}= 2\\boldsymbol{C}[\\boldsymbol{x}]\\boldsymbol{w}_0-2\\lambda_0\\boldsymbol{w}_0=0,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "meaning that" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "\\boldsymbol{C}[\\boldsymbol{x}]\\boldsymbol{w}_0=\\lambda_0\\boldsymbol{w}_0.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**The direction that maximizes the variance (or minimizes the construction error) is an eigenvector of the covariance matrix**! If we left multiply with $\\boldsymbol{w}_0^T$ we have the variance of the projected data is" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "\\boldsymbol{w}_^T\\boldsymbol{C}[\\boldsymbol{x}]\\boldsymbol{w}_0=\\lambda_0.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If we want to maximize the variance (minimize the construction error) we simply pick the eigenvector of the covariance matrix with the largest eigenvalue. This establishes the link between the minimization of the reconstruction function $J$ in terms of an orthogonal matrix and the maximization of the variance and thereby the covariance of our observations encoded in the design/feature matrix $\\boldsymbol{X}$. The proof for the other eigenvectors $\\boldsymbol{w}_1,\\boldsymbol{w}_2,\\dots$ cna be established by applying the above arguments and using the fact that basis of eigenvectors is orthogonal, see [Murphy chapter 12.2](https://mitpress.mit.edu/books/machine-learning-1). The discussion in chapter 12.2 of Murphy's text has also a nice link with the Singular Value Decomposition theorem. For categorical data, see chapter 12.4 and discussion therein. \n", + "\n", + "\n", + "\n", + "\n", + "## PCA and Scikit-Learn Functionality" ] }, { @@ -1159,7 +1322,7 @@ "First it identifies the hyperplane that lies closest to the data, and then it projects the data onto it.\n", "\n", "The following Python code uses NumPy’s **svd()** function to obtain all the principal components of the\n", - "training set, then extracts the first two principal components" + "training set, then extracts the first two principal components. First we center the data" ] }, { @@ -1402,69 +1565,6 @@ "print(df.std())\n", "display(df**2)" ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Thereafter we can select specific columns only and plot final results" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "df.columns = ['First', 'Second', 'Third', 'Fourth', 'Fifth']\n", - "df.index = np.arange(10)\n", - "\n", - "display(df)\n", - "print(df['Second'].mean() )\n", - "print(df.info())\n", - "print(df.describe())\n", - "\n", - "from pylab import plt, mpl\n", - "plt.style.use('seaborn')\n", - "mpl.rcParams['font.family'] = 'serif'\n", - "\n", - "df.cumsum().plot(lw=2.0, figsize=(10,6))\n", - "plt.show()\n", - "\n", - "\n", - "df.plot.bar(figsize=(10,6), rot=15)\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We can produce a $4\\times 4$ matrix" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "b = np.arange(16).reshape((4,4))\n", - "print(b)\n", - "df1 = pd.DataFrame(b)\n", - "print(df1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "and many other operations." - ] } ], "metadata": {}, diff --git a/doc/pub/DimRed/ipynb/ipynb-DimRed-src.tar.gz b/doc/pub/DimRed/ipynb/ipynb-DimRed-src.tar.gz index d669e7d78..6437b95f4 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 0db06109c..8b6bcbffa 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 301664605..9d33bb058 100644 --- a/doc/src/DimRed/DimRed.do.txt +++ b/doc/src/DimRed/DimRed.do.txt @@ -754,16 +754,16 @@ J(\bm{W},\bm{Z}) = \frac{1}{p}\sum_i (\bm{x}_i - \overline{\bm{x}_i})^2, \] !et with $\overline{\bm{x}_i} = \bm{W}\bm{z}_i$, where $\bm{z}_i$ is a row vector with dimension ${\mathbb{R}}^{n}$ of the matrix -$\bm{Z}\in {\mathbb{R}}^{p\times n}$. +$\bm{Z}\in {\mathbb{R}}^{p\times n}$. When doing PCA we want to reduce this dimensionality. -The PCA theorem states that minimizing the above reconstruction error corresponds to setting $\bm{W}=\bm{S}$, the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors $l$ $\bm{z}_i$, with $l << p$, defined by the orthogonal projection of the data onto the columns spanned by they eigenvectors of the covariance(correlations matrix). +The PCA theorem states that minimizing the above reconstruction error corresponds to setting $\bm{W}=\bm{S}$, the orthogonal matrix which diagonalizes the empirical covariance(correlation) matrix. The optimal low-dimensional encoding of the data is then given by a set of vectors $l$ $\bm{z}_i$, with $l << p$, defined by the orthogonal projection of the data onto the columns spanned by the eigenvectors of the covariance(correlations matrix). !split ===== Proof of the PCA Theorem ===== -To show the PCA theorem let us start with the assumption that there is a vector $\bm{w}_0$ which corresponds to a solution which minimized the reconstruction error $J$. This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of $\bm{w}_0$ and $\bm{z}_0$ as +To show the PCA theorem let us start with the assumption that there is one vector $\bm{w}_0$ which corresponds to a solution which minimized the reconstruction error $J$. This is an orthogonal vector. It means that we now approximate the reconstruction error in terms of $\bm{w}_0$ and $\bm{z}_0$ as !bt \[ J(\bm{w}_0,\bm{z}_0)= \frac{1}{p}\sum_i (\bm{x}_i - z_{i0}\bm{w}_0)^2=\frac{1}{p}\sum_i (\bm{x}_^T\bm{x}_i - 2z_{i0}\bm{w}_0^T\bm{x}_i+z_{i0}^2\bm{w}_0^T\bm{w}_0), @@ -783,8 +783,87 @@ z_{i0}=\bm{w}_0^T\bm{x}_i, !et where the vectors on the rhs are known. + !split -===== Getting started with PCA ===== +===== PCA Proof continued ===== + +We have now found the unknown parameters $z_{i0}$. These correspond to the project coordinates and we can write +!bt +\[ +J(\bm{w}_0)= \frac{1}{p}\sum_i (\bm{x}_i^T\bm{x}_i - z_{i0}^2)=\mathrm{const}-\frac{1}{p}\sum_i z_{i0}^2. +\] +!et + +We can show that the variance of the project coordinates defined by $\bm{w}_0^T\bm{x}_i$ are given by +!bt +\[ +\mathrm{var}[\bm{w}_0^T\bm{x}_i] = \frac{1}{p}\sum_i z_{i0}^2, +\] +!et +since the expectation value of +!bt +\[ +\mathbb{E}[\bm{w}_0^T\bm{x}_i] = \mathbb{E}[z_{i0}]= \bm{w}_0^T\mathbb{E}[\bm{x}_i]=0, +\] +!et +where we have used the fact that our data are centered. + +Recalling our definition of the covariance as +!bt +\[ +\bm{C}[\bm{x}] = \frac{1}{n}\bm{X}\bm{X}^T= \mathbb{E}[\bm{X}\bm{X}^T], +\] +!et +we have thus that +!bt +\[ +\mathrm{var}[\bm{w}_0^T\bm{x}_i] = \frac{1}{p}\sum_i z_{i0}^2=\bm{w}_0^T\bm{C}[\bm{x}]\bm{w}_0. +\] +!et + +We are almost there, we have obtained a relation between minimizing the reconstruction error and the variance and the covariance matrix. Minimizing the error is equivalent to maximizing the variance of the projected data. + +!split +===== The final step ===== + +We could trivially maximize the variance of the projection (and +thereby minimize the error in the reconstruction function) by letting +the norm-2 of $\bm{w}_0$ go to infinity. However, this norm since we +want the matrix $\bm{W}$ to be an orthogonal matrix, is constrained by +$$\vert\vert \bm{w}_0 \vert\vert_2^2=1$. Imposing this condition via a +Lagrange multiplier we can then in turn maximize + +!bt +\[ +J(\bm{w}_0)= \bm{w}_0^T\bm{C}[\bm{x}]\bm{w}_0+\lambda_0(1-\bm{w}_0^T\bm{w}_0). +\] +!et +Taking the derivative with respect to $\bm{w}_0$ we obtain + +!bt +\[ +\frac{\partial J(\bm{w}_0)}{\partial \bm{w}_0}= 2\bm{C}[\bm{x}]\bm{w}_0-2\lambda_0\bm{w}_0=0, +\] +!et +meaning that +!bt +\[ +\bm{C}[\bm{x}]\bm{w}_0=\lambda_0\bm{w}_0. +\] +!et +_The direction that maximizes the variance (or minimizes the construction error) is an eigenvector of the covariance matrix_! If we left multiply with $\bm{w}_0^T$ we have the variance of the projected data is +!bt +\[ +\bm{w}_^T\bm{C}[\bm{x}]\bm{w}_0=\lambda_0. +\] +!et +If we want to maximize the variance (minimize the construction error) we simply pick the eigenvector of the covariance matrix with the largest eigenvalue. This establishes the link between the minimization of the reconstruction function $J$ in terms of an orthogonal matrix and the maximization of the variance and thereby the covariance of our observations encoded in the design/feature matrix $\bm{X}$. The proof for the other eigenvectors $\bm{w}_1,\bm{w}_2,\dots$ cna be established by applying the above arguments and using the fact that basis of eigenvectors is orthogonal, see "Murphy chapter 12.2":"https://mitpress.mit.edu/books/machine-learning-1". The discussion in chapter 12.2 of Murphy's text has also a nice link with the Singular Value Decomposition theorem. For categorical data, see chapter 12.4 and discussion therein. + + + + +!split +===== PCA and Scikit-Learn Functionality ===== !bc pycod @@ -805,7 +884,7 @@ Principal Component Analysis (PCA) is by far the most popular dimensionality red First it identifies the hyperplane that lies closest to the data, and then it projects the data onto it. The following Python code uses NumPy’s _svd()_ function to obtain all the principal components of the -training set, then extracts the first two principal components +training set, then extracts the first two principal components. First we center the data !bc pycod X_centered = X - X.mean(axis=0) U, s, V = np.linalg.svd(X_centered) @@ -960,33 +1039,3 @@ print(df.std()) display(df**2) !ec -Thereafter we can select specific columns only and plot final results -!bc pycod -df.columns = ['First', 'Second', 'Third', 'Fourth', 'Fifth'] -df.index = np.arange(10) - -display(df) -print(df['Second'].mean() ) -print(df.info()) -print(df.describe()) - -from pylab import plt, mpl -plt.style.use('seaborn') -mpl.rcParams['font.family'] = 'serif' - -df.cumsum().plot(lw=2.0, figsize=(10,6)) -plt.show() - - -df.plot.bar(figsize=(10,6), rot=15) -plt.show() -!ec -We can produce a $4\times 4$ matrix -!bc pycod -b = np.arange(16).reshape((4,4)) -print(b) -df1 = pd.DataFrame(b) -print(df1) -!ec -and many other operations. -