
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/datasets/plot_random_dataset.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_auto_examples_datasets_plot_random_dataset.py>`
        to download the full example code or to run this example in your browser via Binder

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_datasets_plot_random_dataset.py:


==============================================
Plot randomly generated classification dataset
==============================================

This example plots several randomly generated classification datasets.
For easy visualization, all datasets have 2 features, plotted on the x and y
axis. The color of each point represents its class label.

The first 4 plots use the :func:`~sklearn.datasets.make_classification` with
different numbers of informative features, clusters per class and classes.
The final 2 plots use :func:`~sklearn.datasets.make_blobs` and
:func:`~sklearn.datasets.make_gaussian_quantiles`.

.. GENERATED FROM PYTHON SOURCE LINES 16-61



.. image-sg:: /auto_examples/datasets/images/sphx_glr_plot_random_dataset_001.png
   :alt: One informative feature, one cluster per class, Two informative features, one cluster per class, Two informative features, two clusters per class, Multi-class, two informative features, one cluster, Three blobs, Gaussian divided into three quantiles
   :srcset: /auto_examples/datasets/images/sphx_glr_plot_random_dataset_001.png
   :class: sphx-glr-single-img





.. code-block:: default


    import matplotlib.pyplot as plt

    from sklearn.datasets import make_blobs, make_classification, make_gaussian_quantiles

    plt.figure(figsize=(8, 8))
    plt.subplots_adjust(bottom=0.05, top=0.9, left=0.05, right=0.95)

    plt.subplot(321)
    plt.title("One informative feature, one cluster per class", fontsize="small")
    X1, Y1 = make_classification(
        n_features=2, n_redundant=0, n_informative=1, n_clusters_per_class=1
    )
    plt.scatter(X1[:, 0], X1[:, 1], marker="o", c=Y1, s=25, edgecolor="k")

    plt.subplot(322)
    plt.title("Two informative features, one cluster per class", fontsize="small")
    X1, Y1 = make_classification(
        n_features=2, n_redundant=0, n_informative=2, n_clusters_per_class=1
    )
    plt.scatter(X1[:, 0], X1[:, 1], marker="o", c=Y1, s=25, edgecolor="k")

    plt.subplot(323)
    plt.title("Two informative features, two clusters per class", fontsize="small")
    X2, Y2 = make_classification(n_features=2, n_redundant=0, n_informative=2)
    plt.scatter(X2[:, 0], X2[:, 1], marker="o", c=Y2, s=25, edgecolor="k")

    plt.subplot(324)
    plt.title("Multi-class, two informative features, one cluster", fontsize="small")
    X1, Y1 = make_classification(
        n_features=2, n_redundant=0, n_informative=2, n_clusters_per_class=1, n_classes=3
    )
    plt.scatter(X1[:, 0], X1[:, 1], marker="o", c=Y1, s=25, edgecolor="k")

    plt.subplot(325)
    plt.title("Three blobs", fontsize="small")
    X1, Y1 = make_blobs(n_features=2, centers=3)
    plt.scatter(X1[:, 0], X1[:, 1], marker="o", c=Y1, s=25, edgecolor="k")

    plt.subplot(326)
    plt.title("Gaussian divided into three quantiles", fontsize="small")
    X1, Y1 = make_gaussian_quantiles(n_features=2, n_classes=3)
    plt.scatter(X1[:, 0], X1[:, 1], marker="o", c=Y1, s=25, edgecolor="k")

    plt.show()


.. rst-class:: sphx-glr-timing

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


.. _sphx_glr_download_auto_examples_datasets_plot_random_dataset.py:

.. only:: html

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


    .. container:: binder-badge

      .. image:: images/binder_badge_logo.svg
        :target: https://mybinder.org/v2/gh/scikit-learn/scikit-learn/1.3.X?urlpath=lab/tree/notebooks/auto_examples/datasets/plot_random_dataset.ipynb
        :alt: Launch binder
        :width: 150 px



    .. container:: sphx-glr-download sphx-glr-download-python

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

    .. container:: sphx-glr-download sphx-glr-download-jupyter

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


.. only:: html

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

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