.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_glvq.py: ======================================== Generalized Learning Vector Quantization ======================================== This example shows how GLVQ classifies. The plot shows the target class of each data point (big circle) and which class was predicted (smaller circle). It also shows the prototypes (black diamond) and their labels (small point inside the diamond). .. image:: /auto_examples/images/sphx_glr_plot_glvq_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none GLVQ: not implemented! ('classification accuracy:', 1.0) | .. code-block:: python import numpy as np import matplotlib.pyplot as plt from sklearn_lvq import GlvqModel from sklearn_lvq.utils import plot2d print(__doc__) nb_ppc = 100 print('GLVQ:') toy_data = np.append( np.random.multivariate_normal([0, 0], np.eye(2) / 2, size=nb_ppc), np.random.multivariate_normal([5, 0], np.eye(2) / 2, size=nb_ppc), axis=0) toy_label = np.append(np.zeros(nb_ppc), np.ones(nb_ppc), axis=0) glvq = GlvqModel() glvq.fit(toy_data, toy_label) plot2d(glvq, toy_data, toy_label, 1, 'glvq') print('classification accuracy:', glvq.score(toy_data, toy_label)) plt.show() **Total running time of the script:** ( 0 minutes 0.093 seconds) .. _sphx_glr_download_auto_examples_plot_glvq.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_glvq.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_glvq.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_