Skip to content

Commit

Permalink
Eigenfaces tutorial added
Browse files Browse the repository at this point in the history
  • Loading branch information
jan authored and jan committed Apr 22, 2017
1 parent 90142b5 commit d01e85b
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions docs/tutorials/eigenfaces.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Eigenfaces
===========

Example for Principal Component Analysis (PCA) on face images also known as `Eigenfaces <https://en.wikipedia.org/wiki/Eigenface>`_

The code_ given below produces the following output.

Some examples of the face images of the olivetti face dataset.

.. figure:: images/example_faces.png
:scale: 75 %
:alt: Examples of the face datset

The first 100 principal components extracted from the dataset. The components focus on characteristics like glasses, lighting direction, nose shape, ...

.. image:: images/components_faces.png
:scale: 75 %
:alt: Principal components of teh face dataset

The cumulative sum of the Eigenvalues show how 'compressable' the dataset is.

.. image:: images/eigenspectrum_faces.png
:scale: 50 %
:alt: Eigenspectrum of the face dataset

For example using only the first 50 Eigenvectors retains 87,5 % of the variance of the data and the reconstructed images look as follows.

.. image:: images/reconstruction50.png
:scale: 75 %
:alt: Reconstruction using 50 PCs

For 200 Eigenvectors we retain 98,0 % of the variance of the data and the reconstructed images look as follows.

.. image:: images/reconstruction50.png
:scale: 75 %
:alt: Reconstruction using 200 PCs

Comparing the results with the original images shows that the data can be compressed to 50 dimensions with an acceptable error.

.. _code:

Source code
***********

.. figure:: images/download_icon.png
:scale: 20 %
:target: https://github.com/MelJan/PyDeep/blob/master/examples/eigenfaces.py

.. literalinclude:: ../../examples/eigenfaces.py
Binary file added docs/tutorials/images/components_faces.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/tutorials/images/download_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/tutorials/images/eigenspectrum_faces.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/tutorials/images/example_faces.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/tutorials/images/reconstruction200.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/tutorials/images/reconstruction50.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d01e85b

Please sign in to comment.