{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Plot randomly generated classification dataset\n\n\nPlot several randomly generated 2D classification datasets.\nThis example illustrates the :func:`datasets.make_classification`\n:func:`datasets.make_blobs` and :func:`datasets.make_gaussian_quantiles`\nfunctions.\n\nFor ``make_classification``, three binary and two multi-class classification\ndatasets are generated, with different numbers of informative features and\nclusters per class. \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(__doc__)\n\nimport matplotlib.pyplot as plt\n\nfrom sklearn.datasets import make_classification\nfrom sklearn.datasets import make_blobs\nfrom sklearn.datasets import make_gaussian_quantiles\n\nplt.figure(figsize=(8, 8))\nplt.subplots_adjust(bottom=.05, top=.9, left=.05, right=.95)\n\nplt.subplot(321)\nplt.title(\"One informative feature, one cluster per class\", fontsize='small')\nX1, Y1 = make_classification(n_features=2, n_redundant=0, n_informative=1,\n n_clusters_per_class=1)\nplt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1,\n s=25, edgecolor='k')\n\nplt.subplot(322)\nplt.title(\"Two informative features, one cluster per class\", fontsize='small')\nX1, Y1 = make_classification(n_features=2, n_redundant=0, n_informative=2,\n n_clusters_per_class=1)\nplt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1,\n s=25, edgecolor='k')\n\nplt.subplot(323)\nplt.title(\"Two informative features, two clusters per class\",\n fontsize='small')\nX2, Y2 = make_classification(n_features=2, n_redundant=0, n_informative=2)\nplt.scatter(X2[:, 0], X2[:, 1], marker='o', c=Y2,\n s=25, edgecolor='k')\n\nplt.subplot(324)\nplt.title(\"Multi-class, two informative features, one cluster\",\n fontsize='small')\nX1, Y1 = make_classification(n_features=2, n_redundant=0, n_informative=2,\n n_clusters_per_class=1, n_classes=3)\nplt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1,\n s=25, edgecolor='k')\n\nplt.subplot(325)\nplt.title(\"Three blobs\", fontsize='small')\nX1, Y1 = make_blobs(n_features=2, centers=3)\nplt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1,\n s=25, edgecolor='k')\n\nplt.subplot(326)\nplt.title(\"Gaussian divided into three quantiles\", fontsize='small')\nX1, Y1 = make_gaussian_quantiles(n_features=2, n_classes=3)\nplt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1,\n s=25, edgecolor='k')\n\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.6" } }, "nbformat": 4, "nbformat_minor": 0 }