.. _example_manifold_plot_lle_digits.py:


=============================================================================
Manifold learning on handwritten digits: Locally Linear Embedding, Isomap...
=============================================================================

An illustration of various embeddings on the digits dataset.

The RandomTreesEmbedding, from the :mod:`sklearn.ensemble` module, is not
technically a manifold embedding method, as it learn a high-dimensional
representation on which we apply a dimensionality reduction method.
However, it is often useful to cast a dataset into a representation in
which the classes are linearly-separable.

t-SNE will be initialized with the embedding that is generated by PCA in
this example, which is not the default setting. It ensures global stability
of the embedding, i.e., the embedding does not depend on random
initialization.



.. rst-class:: horizontal


    *

      .. image:: images/plot_lle_digits_001.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_002.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_003.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_004.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_005.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_006.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_007.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_008.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_009.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_010.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_011.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_012.png
            :scale: 47

    *

      .. image:: images/plot_lle_digits_013.png
            :scale: 47


**Script output**::

  Computing random projection
  Computing PCA projection
  Computing LDA projection
  Computing Isomap embedding
  Done.
  Computing LLE embedding
  Done. Reconstruction error: 1.63539e-06
  Computing modified LLE embedding
  Done. Reconstruction error: 0.360518
  Computing Hessian LLE embedding
  Done. Reconstruction error: 0.213002
  Computing LTSA embedding
  Done. Reconstruction error: 0.212806
  Computing MDS embedding
  Done. Stress: 139486576.843200
  Computing Totally Random Trees embedding
  Computing Spectral embedding
  Computing t-SNE embedding



**Python source code:** :download:`plot_lle_digits.py <plot_lle_digits.py>`

.. literalinclude:: plot_lle_digits.py
    :lines: 19-

**Total running time of the example:**  33.45 seconds
( 0 minutes  33.45 seconds)