Exercise:PCA and Whitening
From Ufldl
Line 3: | Line 3: | ||
=== Step 0: Load data === | === Step 0: Load data === | ||
- | [[ | + | [[Image:raw_images.png|thumb|left|240px|alt=Raw images|Raw images]] |
=== Step 1: Implement PCA === | === Step 1: Implement PCA === | ||
Line 17: | Line 17: | ||
Visualise the covariance matrix. You should see a line across the diagonal against a blue background. | Visualise the covariance matrix. You should see a line across the diagonal against a blue background. | ||
- | [[ | + | [[Image:pca_covar.png|thumb|left|240px]] |
=== Step 2: Find number of components to retain === | === Step 2: Find number of components to retain === | ||
Line 31: | Line 31: | ||
Visualise the data, and compare it to the raw data. You should observe that the raw and processed data are of comparable quality. For comparison, you may wish to generate a PCA reduced image which retains only 50% of the variance. | Visualise the data, and compare it to the raw data. You should observe that the raw and processed data are of comparable quality. For comparison, you may wish to generate a PCA reduced image which retains only 50% of the variance. | ||
- | [[ | + | [[Image:pca_images.png|thumb|left|240px|alt=PCA dimension-reduced images (99% variance)|PCA dimension-reduced images (99% variance)]] [[Image:raw_images.png|thumb|left|240px|alt=Raw images|Raw images]] [[Image:pca_images_50.png|thumb|left|240px|alt=PCA dimension-reduced images (50% variance)|PCA dimension-reduced images (50% variance)]] |
=== Step 4: PCA with whitening and regularisation === | === Step 4: PCA with whitening and regularisation === | ||
Line 45: | Line 45: | ||
Visualise the covariance matrix. You should see a red line across the diagonal against a blue background. | Visualise the covariance matrix. You should see a red line across the diagonal against a blue background. | ||
- | [[ | + | [[Image:pca_whitened_covar.png|thumb|left|240px]] |
=== Step 5: ZCA whitening === | === Step 5: ZCA whitening === | ||
Line 53: | Line 53: | ||
Visualise the data, and compare it to the raw data. You should observe that the whitened images have enhanced edges. | Visualise the data, and compare it to the raw data. You should observe that the whitened images have enhanced edges. | ||
- | [[ | + | [[Image:zca_whitened_images.png|thumb|left|240px|alt=ZCA whitened images|ZCA whitened images]] [[Image:raw_images.png|thumb|left|240px|alt=Raw images|Raw images]] |