.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_intro_mlp_mmd.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_intro_mlp_mmd.py: ===================================================================== An introducing example to clustering with an MLP and the MMD GEMINI ===================================================================== An example plot of :class:`gemclus.base_gemini.DenseMMDOvO` .. GENERATED FROM PYTHON SOURCE LINES 8-14 .. code-block:: default from matplotlib import pyplot as plt from sklearn import datasets from gemclus.mlp import MLPMMD .. GENERATED FROM PYTHON SOURCE LINES 15-17 Generate data ------------- .. GENERATED FROM PYTHON SOURCE LINES 19-22 .. code-block:: default X, y = datasets.make_blobs(centers=3, cluster_std=0.5, n_samples=200, random_state=0) .. GENERATED FROM PYTHON SOURCE LINES 23-25 Create the MLP clustering model and fit it ------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 27-30 .. code-block:: default clf = MLPMMD(random_state=0, ovo=True) clf.fit(X) .. raw:: html
MLPMMD(ovo=True, random_state=0)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.


.. GENERATED FROM PYTHON SOURCE LINES 31-33 Plot the final clustering ------------------------- .. GENERATED FROM PYTHON SOURCE LINES 35-54 .. code-block:: default y_pred = clf.predict(X) X_0 = X[y_pred == 0] X_1 = X[y_pred == 1] X_2 = X[y_pred == 2] ax0 = plt.scatter(X_0[:, 0], X_0[:, 1], c='crimson', s=50) ax1 = plt.scatter(X_1[:, 0], X_1[:, 1], c='deepskyblue', s=50) ax2 = plt.scatter(X_2[:, 0], X_2[:, 1], c='darkgreen', s=50) leg = plt.legend([ax0, ax1, ax2], ['Cluster 0', 'Cluster 1', 'Cluster 2'], loc='upper left', fancybox=True, scatterpoints=1) leg.get_frame().set_alpha(0.5) plt.xlabel('Feature 1') plt.ylabel('Feature 2') plt.show() .. image-sg:: /auto_examples/images/sphx_glr_plot_intro_mlp_mmd_001.png :alt: plot intro mlp mmd :srcset: /auto_examples/images/sphx_glr_plot_intro_mlp_mmd_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.768 seconds) .. _sphx_glr_download_auto_examples_plot_intro_mlp_mmd.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_intro_mlp_mmd.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_intro_mlp_mmd.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_