.. note::
    :class: sphx-glr-download-link-note

    Click :ref:`here <sphx_glr_download_auto_examples_plot_lmrslvq.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_plot_lmrslvq.py:


=========================================================
Localized Matrix Robust Soft Learning Vector Quantization
=========================================================
This example shows the different glvq algorithms and how they project
different data sets. The data sets are chosen to show the strength of each
algorithm. Each plot shows for each data point which class it belongs to
(big circle) and which class it was classified to (smaller circle). It also
shows the prototypes (light blue circle). The projected data is shown in the
right plot.





.. image:: /auto_examples/images/sphx_glr_plot_lmrslvq_001.png
    :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none

    LMRSLVQ:
    ('variance coverd by projection:', 100.0)
    ('variance coverd by projection:', 100.0)
    ('classification accuracy:', 0.76)




|


.. code-block:: python

    import numpy as np
    import matplotlib.pyplot as plt

    from sklearn_lvq import LmrslvqModel
    from sklearn_lvq.utils import plot2d

    print(__doc__)

    nb_ppc = 100
    toy_label = np.append(np.zeros(nb_ppc), np.ones(nb_ppc), axis=0)

    print('LMRSLVQ:')
    toy_data = np.append(
        np.random.multivariate_normal([0, 1], np.array([[5, -4], [-4, 6]]),
                                      size=nb_ppc),
        np.random.multivariate_normal([0, 0], np.array([[5, 4], [4, 6]]),
                                      size=nb_ppc), axis=0)
    mrslvq = LmrslvqModel(sigma=10)
    mrslvq.fit(toy_data, toy_label)
    plot2d(mrslvq, toy_data, toy_label, 1, 'lmrslvq')

    print('classification accuracy:', mrslvq.score(toy_data, toy_label))
    plt.show()


**Total running time of the script:** ( 0 minutes  4.008 seconds)


.. _sphx_glr_download_auto_examples_plot_lmrslvq.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download

     :download:`Download Python source code: plot_lmrslvq.py <plot_lmrslvq.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: plot_lmrslvq.ipynb <plot_lmrslvq.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_