{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Logistic Regression 3-class Classifier\n\nShow below is a logistic-regression classifiers decision boundaries on the\nfirst two dimensions (sepal length and width) of the [iris](https://en.wikipedia.org/wiki/Iris_flower_data_set) dataset. The datapoints\nare colored according to their labels.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Code source: Ga\u00ebl Varoquaux\n# Modified for documentation by Jaques Grobler\n# License: BSD 3 clause\n\nimport matplotlib.pyplot as plt\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn import datasets\nfrom sklearn.inspection import DecisionBoundaryDisplay\n\n# import some data to play with\niris = datasets.load_iris()\nX = iris.data[:, :2]  # we only take the first two features.\nY = iris.target\n\n# Create an instance of Logistic Regression Classifier and fit the data.\nlogreg = LogisticRegression(C=1e5)\nlogreg.fit(X, Y)\n\n_, ax = plt.subplots(figsize=(4, 3))\nDecisionBoundaryDisplay.from_estimator(\n    logreg,\n    X,\n    cmap=plt.cm.Paired,\n    ax=ax,\n    response_method=\"predict\",\n    plot_method=\"pcolormesh\",\n    shading=\"auto\",\n    xlabel=\"Sepal length\",\n    ylabel=\"Sepal width\",\n    eps=0.5,\n)\n\n# Plot also the training points\nplt.scatter(X[:, 0], X[:, 1], c=Y, edgecolors=\"k\", cmap=plt.cm.Paired)\n\n\nplt.xticks(())\nplt.yticks(())\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.9.13"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}