{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n=====================================================\nGaussian process classification (GPC) on iris dataset\n=====================================================\n\nThis example illustrates the predicted probability of GPC for an isotropic\nand anisotropic RBF kernel on a two-dimensional version for the iris-dataset.\nThe anisotropic RBF kernel obtains slightly higher log-marginal-likelihood by\nassigning different length-scales to the two feature dimensions.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "print(__doc__)\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import datasets\nfrom sklearn.gaussian_process import GaussianProcessClassifier\nfrom sklearn.gaussian_process.kernels import RBF\n\n# import some data to play with\niris = datasets.load_iris()\nX = iris.data[:, :2]  # we only take the first two features.\ny = np.array(iris.target, dtype=int)\n\nh = .02  # step size in the mesh\n\nkernel = 1.0 * RBF([1.0])\ngpc_rbf_isotropic = GaussianProcessClassifier(kernel=kernel).fit(X, y)\nkernel = 1.0 * RBF([1.0, 1.0])\ngpc_rbf_anisotropic = GaussianProcessClassifier(kernel=kernel).fit(X, y)\n\n# create a mesh to plot in\nx_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1\ny_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1\nxx, yy = np.meshgrid(np.arange(x_min, x_max, h),\n                     np.arange(y_min, y_max, h))\n\ntitles = [\"Isotropic RBF\", \"Anisotropic RBF\"]\nplt.figure(figsize=(10, 5))\nfor i, clf in enumerate((gpc_rbf_isotropic, gpc_rbf_anisotropic)):\n    # Plot the predicted probabilities. For that, we will assign a color to\n    # each point in the mesh [x_min, m_max]x[y_min, y_max].\n    plt.subplot(1, 2, i + 1)\n\n    Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])\n\n    # Put the result into a color plot\n    Z = Z.reshape((xx.shape[0], xx.shape[1], 3))\n    plt.imshow(Z, extent=(x_min, x_max, y_min, y_max), origin=\"lower\")\n\n    # Plot also the training points\n    plt.scatter(X[:, 0], X[:, 1], c=np.array([\"r\", \"g\", \"b\"])[y],\n                edgecolors=(0, 0, 0))\n    plt.xlabel('Sepal length')\n    plt.ylabel('Sepal width')\n    plt.xlim(xx.min(), xx.max())\n    plt.ylim(yy.min(), yy.max())\n    plt.xticks(())\n    plt.yticks(())\n    plt.title(\"%s, LML: %.3f\" %\n              (titles[i], clf.log_marginal_likelihood(clf.kernel_.theta)))\n\nplt.tight_layout()\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.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}