Exercise:PCA in 2D
From Ufldl
Line 24: | Line 24: | ||
==== Step 1b: Check xRot ==== | ==== Step 1b: Check xRot ==== | ||
- | Compute <tt>xRot</tt>, and use the <tt>scatter</tt> function to check that xRot looks as it should, which should be something like the following: | + | Compute <tt>xRot</tt>, and use the <tt>scatter</tt> function to check that <tt>xRot</tt> looks as it should, which should be something like the following: |
[[File:pca_xrot_2d.png|360px]] | [[File:pca_xrot_2d.png|360px]] | ||
- | Because Matlab/Octave could have returned <math>\textstyle -u_1</math> and/or <math>\textstyle -u_2</math> instead of <math>\textstyle u_1</math> and <math>\textstyle u_2</math>, it's also possible that you might have gotten a figure which is "flipped" or "reflected" along the <math>\textstyle x</math>- and/or <math>\textstyle y</math>-axis; this is also completely correct. | + | Because Matlab/Octave could have returned <math>\textstyle -u_1</math> and/or <math>\textstyle -u_2</math> instead of <math>\textstyle u_1</math> and <math>\textstyle u_2</math>, it's also possible that you might have gotten a figure which is "flipped" or "reflected" along the <math>\textstyle x</math>- and/or <math>\textstyle y</math>-axis; a flipped/reflected version of this figure is also a completely correct result. |
=== Step 2: Dimension reduce and replot === | === Step 2: Dimension reduce and replot === | ||
- | In the next step, set <math>k</math>, the number of components to retain, to be 1 (we have already done this for you). Compute the resulting < | + | In the next step, set <math>k</math>, the number of components to retain, to be 1 (we have already done this for you). Compute the resulting <tt>xHat</tt> and plot the results. You should get the following (this figure should '''not''' be flipped along the <math>\textstyle x</math>- or <math>\textstyle y</math>-axis): |
[[File:pca_xhat_2d.png|400px]] | [[File:pca_xhat_2d.png|400px]] | ||
Line 47: | Line 47: | ||
[[Category:Exercises]] | [[Category:Exercises]] | ||
+ | |||
+ | |||
+ | {{PCA}} |