Format: application/octet-stream
⬇ Download File (90.3 KB)
   1  {
   2   "cells": [
   3    {
   4     "cell_type": "markdown",
   5     "metadata": {},
   6     "source": [
   7      "---\n",
   8      "\n",
   9      "_You are currently looking at **version 1.2** of this notebook. To download notebooks and datafiles, as well as get help on Jupyter notebooks in the Coursera platform, visit the [Jupyter Notebook FAQ](https://www.coursera.org/learn/python-machine-learning/resources/bANLa) course resource._\n",
  10      "\n",
  11      "---"
  12     ]
  13    },
  14    {
  15     "cell_type": "markdown",
  16     "metadata": {},
  17     "source": [
  18      "# Assignment 3 - Evaluation\n",
  19      "\n",
  20      "In this assignment you will train several models and evaluate how effectively they predict instances of fraud using data based on [this dataset from Kaggle](https://www.kaggle.com/dalpozz/creditcardfraud).\n",
  21      " \n",
  22      "Each row in `fraud_data.csv` corresponds to a credit card transaction. Features include confidential variables `V1` through `V28` as well as `Amount` which is the amount of the transaction. \n",
  23      " \n",
  24      "The target is stored in the `class` column, where a value of 1 corresponds to an instance of fraud and 0 corresponds to an instance of not fraud."
  25     ]
  26    },
  27    {
  28     "cell_type": "code",
  29     "execution_count": 2,
  30     "metadata": {},
  31     "outputs": [],
  32     "source": [
  33      "import numpy as np\n",
  34      "import pandas as pd"
  35     ]
  36    },
  37    {
  38     "cell_type": "markdown",
  39     "metadata": {},
  40     "source": [
  41      "### Question 1\n",
  42      "Import the data from `fraud_data.csv`. What percentage of the observations in the dataset are instances of fraud?\n",
  43      "\n",
  44      "*This function should return a float between 0 and 1.* "
  45     ]
  46    },
  47    {
  48     "cell_type": "code",
  49     "execution_count": 5,
  50     "metadata": {},
  51     "outputs": [
  52      {
  53       "data": {
  54        "text/plain": [
  55         "0.016410823768035772"
  56        ]
  57       },
  58       "execution_count": 5,
  59       "metadata": {},
  60       "output_type": "execute_result"
  61      }
  62     ],
  63     "source": [
  64      "def answer_one():\n",
  65      "    \n",
  66      "    df = pd.read_csv('Source/fraud_data.csv')\n",
  67      "    \n",
  68      "    \n",
  69      "    return len(df[df.Class==1])/len(df)\n"
  70     ]
  71    },
  72    {
  73     "cell_type": "code",
  74     "execution_count": 6,
  75     "metadata": {},
  76     "outputs": [],
  77     "source": [
  78      "# Use X_train, X_test, y_train, y_test for all of the following questions\n",
  79      "from sklearn.model_selection import train_test_split\n",
  80      "\n",
  81      "df = pd.read_csv('Source/fraud_data.csv')\n",
  82      "\n",
  83      "X = df.iloc[:,:-1]\n",
  84      "y = df.iloc[:,-1]\n",
  85      "\n",
  86      "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)"
  87     ]
  88    },
  89    {
  90     "cell_type": "markdown",
  91     "metadata": {},
  92     "source": [
  93      "### Question 2\n",
  94      "\n",
  95      "Using `X_train`, `X_test`, `y_train`, and `y_test` (as defined above), train a dummy classifier that classifies everything as the majority class of the training data. What is the accuracy of this classifier? What is the recall?\n",
  96      "\n",
  97      "*This function should a return a tuple with two floats, i.e. `(accuracy score, recall score)`.*"
  98     ]
  99    },
 100    {
 101     "cell_type": "code",
 102     "execution_count": 9,
 103     "metadata": {},
 104     "outputs": [
 105      {
 106       "data": {
 107        "text/plain": [
 108         "(0.9852507374631269, 0.0)"
 109        ]
 110       },
 111       "execution_count": 9,
 112       "metadata": {},
 113       "output_type": "execute_result"
 114      }
 115     ],
 116     "source": [
 117      "def answer_two():\n",
 118      "    from sklearn.dummy import DummyClassifier\n",
 119      "    from sklearn.metrics import recall_score\n",
 120      "    \n",
 121      "    clfr= DummyClassifier(strategy='most_frequent')\n",
 122      "    clfr.fit(X_train, y_train)\n",
 123      "    y_pred= clfr.predict(X_test)\n",
 124      "    \n",
 125      "    return (clfr.score(X_test,y_test), recall_score(y_test, y_pred))\n",
 126      "answer_two()"
 127     ]
 128    },
 129    {
 130     "cell_type": "markdown",
 131     "metadata": {},
 132     "source": [
 133      "### Question 3\n",
 134      "\n",
 135      "Using X_train, X_test, y_train, y_test (as defined above), train a SVC classifer using the default parameters. What is the accuracy, recall, and precision of this classifier?\n",
 136      "\n",
 137      "*This function should a return a tuple with three floats, i.e. `(accuracy score, recall score, precision score)`.*"
 138     ]
 139    },
 140    {
 141     "cell_type": "code",
 142     "execution_count": 11,
 143     "metadata": {},
 144     "outputs": [
 145      {
 146       "data": {
 147        "text/plain": [
 148         "(0.9900442477876106, 0.35, 0.9333333333333333)"
 149        ]
 150       },
 151       "execution_count": 11,
 152       "metadata": {},
 153       "output_type": "execute_result"
 154      }
 155     ],
 156     "source": [
 157      "def answer_three():\n",
 158      "    from sklearn.metrics import recall_score, precision_score\n",
 159      "    from sklearn.svm import SVC\n",
 160      "    clfr= SVC()\n",
 161      "    clfr.fit(X_train,y_train)\n",
 162      "    y_pred= clfr.predict(X_test)\n",
 163      "    \n",
 164      "    return (clfr.score(X_test,y_test) , recall_score(y_test,y_pred), precision_score(y_test, y_pred))\n",
 165      "answer_three()"
 166     ]
 167    },
 168    {
 169     "cell_type": "markdown",
 170     "metadata": {},
 171     "source": [
 172      "### Question 4\n",
 173      "\n",
 174      "Using the SVC classifier with parameters `{'C': 1e9, 'gamma': 1e-07}`, what is the confusion matrix when using a threshold of -220 on the decision function. Use X_test and y_test.\n",
 175      "\n",
 176      "*This function should return a confusion matrix, a 2x2 numpy array with 4 integers.*"
 177     ]
 178    },
 179    {
 180     "cell_type": "code",
 181     "execution_count": null,
 182     "metadata": {},
 183     "outputs": [],
 184     "source": []
 185    },
 186    {
 187     "cell_type": "code",
 188     "execution_count": 17,
 189     "metadata": {},
 190     "outputs": [
 191      {
 192       "data": {
 193        "text/plain": [
 194         "array([[5320,   24],\n",
 195         "       [  14,   66]], dtype=int64)"
 196        ]
 197       },
 198       "execution_count": 17,
 199       "metadata": {},
 200       "output_type": "execute_result"
 201      }
 202     ],
 203     "source": [
 204      "def answer_four():\n",
 205      "    from sklearn.metrics import confusion_matrix\n",
 206      "    from sklearn.svm import SVC\n",
 207      "    clfr= SVC(C=1e9, gamma=1e-07)\n",
 208      "    clfr.fit(X_train, y_train)\n",
 209      "    y_pred= np.where(clfr.decision_function(X_test) >-220, 1, 0)\n",
 210      "    matrix= confusion_matrix(y_test, y_pred)\n",
 211      "    \n",
 212      "    return matrix\n",
 213      "\n",
 214      "answer_four()"
 215     ]
 216    },
 217    {
 218     "cell_type": "markdown",
 219     "metadata": {},
 220     "source": [
 221      "### Question 5\n",
 222      "\n",
 223      "Train a logisitic regression classifier with default parameters using X_train and y_train.\n",
 224      "\n",
 225      "For the logisitic regression classifier, create a precision recall curve and a roc curve using y_test and the probability estimates for X_test (probability it is fraud).\n",
 226      "\n",
 227      "Looking at the precision recall curve, what is the recall when the precision is `0.75`?\n",
 228      "\n",
 229      "Looking at the roc curve, what is the true positive rate when the false positive rate is `0.16`?\n",
 230      "\n",
 231      "*This function should return a tuple with two floats, i.e. `(recall, true positive rate)`.*"
 232     ]
 233    },
 234    {
 235     "cell_type": "code",
 236     "execution_count": 30,
 237     "metadata": {},
 238     "outputs": [
 239      {
 240       "data": {
 241        "text/plain": [
 242         "(0.825, 0.9375)"
 243        ]
 244       },
 245       "execution_count": 30,
 246       "metadata": {},
 247       "output_type": "execute_result"
 248      }
 249     ],
 250     "source": [
 251      "def answer_five():\n",
 252      "    from sklearn.linear_model import LogisticRegression\n",
 253      "    from sklearn.metrics import precision_recall_curve, roc_curve\n",
 254      "    clfr= LogisticRegression(max_iter=1000)\n",
 255      "    clfr.fit(X_train, y_train)\n",
 256      "    y_score= clfr.decision_function(X_test)\n",
 257      "    prec, recall, _=precision_recall_curve(y_test, y_score)\n",
 258      "    fpr, tpr,__= roc_curve(y_test, y_score)\n",
 259      "    \n",
 260      "    \n",
 261      "    \n",
 262      "    return (np.interp(0.75, prec, recall) , np.interp(0.16, fpr, tpr))\n",
 263      "\n",
 264      "answer_five()"
 265     ]
 266    },
 267    {
 268     "cell_type": "markdown",
 269     "metadata": {},
 270     "source": [
 271      "### Question 6\n",
 272      "\n",
 273      "Perform a grid search over the parameters listed below for a Logisitic Regression classifier, using recall for scoring and the default 3-fold cross validation.\n",
 274      "\n",
 275      "`'penalty': ['l1', 'l2']`\n",
 276      "\n",
 277      "`'C':[0.01, 0.1, 1, 10, 100]`\n",
 278      "\n",
 279      "From `.cv_results_`, create an array of the mean test scores of each parameter combination. i.e.\n",
 280      "\n",
 281      "|      \t| `l1` \t| `l2` \t|\n",
 282      "|:----:\t|----\t|----\t|\n",
 283      "| **`0.01`** \t|    ?\t|   ? \t|\n",
 284      "| **`0.1`**  \t|    ?\t|   ? \t|\n",
 285      "| **`1`**    \t|    ?\t|   ? \t|\n",
 286      "| **`10`**   \t|    ?\t|   ? \t|\n",
 287      "| **`100`**   \t|    ?\t|   ? \t|\n",
 288      "\n",
 289      "<br>\n",
 290      "\n",
 291      "*This function should return a 5 by 2 numpy array with 10 floats.* \n",
 292      "\n",
 293      "*Note: do not return a DataFrame, just the values denoted by '?' above in a numpy array. You might need to reshape your raw result to meet the format we are looking for.*"
 294     ]
 295    },
 296    {
 297     "cell_type": "code",
 298     "execution_count": 34,
 299     "metadata": {},
 300     "outputs": [
 301      {
 302       "name": "stderr",
 303       "output_type": "stream",
 304       "text": [
 305        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 306        "Traceback (most recent call last):\n",
 307        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 308        "    estimator.fit(X_train, y_train, **fit_params)\n",
 309        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 310        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 311        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 312        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 313        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 314        "\n",
 315        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 316        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 317        "Traceback (most recent call last):\n",
 318        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 319        "    estimator.fit(X_train, y_train, **fit_params)\n",
 320        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 321        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 322        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 323        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 324        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 325        "\n",
 326        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 327        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 328        "Traceback (most recent call last):\n",
 329        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 330        "    estimator.fit(X_train, y_train, **fit_params)\n",
 331        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 332        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 333        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 334        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 335        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 336        "\n",
 337        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 338        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 339        "Traceback (most recent call last):\n",
 340        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 341        "    estimator.fit(X_train, y_train, **fit_params)\n",
 342        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 343        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 344        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 345        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 346        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 347        "\n",
 348        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 349        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 350        "Traceback (most recent call last):\n",
 351        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 352        "    estimator.fit(X_train, y_train, **fit_params)\n",
 353        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 354        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 355        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 356        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 357        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 358        "\n",
 359        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 360        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 361        "Traceback (most recent call last):\n",
 362        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 363        "    estimator.fit(X_train, y_train, **fit_params)\n",
 364        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 365        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 366        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 367        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 368        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 369        "\n",
 370        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 371        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 372        "Traceback (most recent call last):\n",
 373        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 374        "    estimator.fit(X_train, y_train, **fit_params)\n",
 375        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 376        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 377        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 378        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 379        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 380        "\n",
 381        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 382        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 383        "Traceback (most recent call last):\n",
 384        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 385        "    estimator.fit(X_train, y_train, **fit_params)\n",
 386        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 387        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 388        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 389        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 390        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 391        "\n",
 392        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 393        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 394        "Traceback (most recent call last):\n",
 395        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 396        "    estimator.fit(X_train, y_train, **fit_params)\n",
 397        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 398        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 399        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 400        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 401        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 402        "\n",
 403        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n"
 404       ]
 405      },
 406      {
 407       "name": "stderr",
 408       "output_type": "stream",
 409       "text": [
 410        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 411        "Traceback (most recent call last):\n",
 412        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 413        "    estimator.fit(X_train, y_train, **fit_params)\n",
 414        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 415        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 416        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 417        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 418        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 419        "\n",
 420        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 421        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 422        "Traceback (most recent call last):\n",
 423        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 424        "    estimator.fit(X_train, y_train, **fit_params)\n",
 425        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 426        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 427        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 428        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 429        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 430        "\n",
 431        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 432        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 433        "Traceback (most recent call last):\n",
 434        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 435        "    estimator.fit(X_train, y_train, **fit_params)\n",
 436        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 437        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 438        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 439        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 440        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 441        "\n",
 442        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 443        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 444        "Traceback (most recent call last):\n",
 445        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 446        "    estimator.fit(X_train, y_train, **fit_params)\n",
 447        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 448        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 449        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 450        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 451        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 452        "\n",
 453        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 454        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 455        "Traceback (most recent call last):\n",
 456        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 457        "    estimator.fit(X_train, y_train, **fit_params)\n",
 458        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 459        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 460        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 461        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 462        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 463        "\n",
 464        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 465        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 466        "Traceback (most recent call last):\n",
 467        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 468        "    estimator.fit(X_train, y_train, **fit_params)\n",
 469        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 470        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 471        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 472        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 473        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 474        "\n",
 475        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 476        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_search.py:918: UserWarning: One or more of the test scores are non-finite: [       nan 0.79347826        nan 0.80797101        nan 0.80797101\n",
 477        "        nan 0.80797101        nan 0.80797101]\n",
 478        "  warnings.warn(\n"
 479       ]
 480      },
 481      {
 482       "data": {
 483        "text/plain": [
 484         "array([       nan, 0.79347826,        nan, 0.80797101,        nan,\n",
 485         "       0.80797101,        nan, 0.80797101,        nan, 0.80797101])"
 486        ]
 487       },
 488       "execution_count": 34,
 489       "metadata": {},
 490       "output_type": "execute_result"
 491      }
 492     ],
 493     "source": [
 494      "def answer_six():    \n",
 495      "    from sklearn.model_selection import GridSearchCV\n",
 496      "    from sklearn.linear_model import LogisticRegression\n",
 497      "    args={'penalty': ['l1', 'l2'],'C':[0.01, 0.1, 1, 10, 100] }\n",
 498      "    clfr=LogisticRegression(max_iter=1000).fit(X_train, y_train)\n",
 499      "    \n",
 500      "    clfr_grid= GridSearchCV(clfr, param_grid=args, scoring='recall', cv=3)\n",
 501      "    X_train.astype(float)\n",
 502      "    y_train.astype(float)\n",
 503      "    clfr_grid.fit(X_train, y_train)\n",
 504      "    \n",
 505      "    \n",
 506      "    return clfr_grid.cv_results_['mean_test_score']\n",
 507      "answer_six()"
 508     ]
 509    },
 510    {
 511     "cell_type": "code",
 512     "execution_count": 27,
 513     "metadata": {},
 514     "outputs": [
 515      {
 516       "name": "stderr",
 517       "output_type": "stream",
 518       "text": [
 519        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 520        "Traceback (most recent call last):\n",
 521        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 522        "    estimator.fit(X_train, y_train, **fit_params)\n",
 523        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 524        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 525        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 526        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 527        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 528        "\n",
 529        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 530        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 531        "Traceback (most recent call last):\n",
 532        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 533        "    estimator.fit(X_train, y_train, **fit_params)\n",
 534        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 535        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 536        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 537        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 538        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 539        "\n",
 540        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 541        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 542        "Traceback (most recent call last):\n",
 543        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 544        "    estimator.fit(X_train, y_train, **fit_params)\n",
 545        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 546        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 547        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 548        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 549        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 550        "\n",
 551        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 552        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 553        "Traceback (most recent call last):\n",
 554        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 555        "    estimator.fit(X_train, y_train, **fit_params)\n",
 556        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 557        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 558        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 559        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 560        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 561        "\n",
 562        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 563        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 564        "Traceback (most recent call last):\n",
 565        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 566        "    estimator.fit(X_train, y_train, **fit_params)\n",
 567        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 568        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 569        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 570        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 571        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 572        "\n",
 573        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 574        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 575        "Traceback (most recent call last):\n",
 576        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 577        "    estimator.fit(X_train, y_train, **fit_params)\n",
 578        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 579        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 580        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 581        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 582        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 583        "\n",
 584        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 585        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 586        "Traceback (most recent call last):\n",
 587        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 588        "    estimator.fit(X_train, y_train, **fit_params)\n",
 589        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 590        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 591        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 592        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 593        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 594        "\n",
 595        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 596        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 597        "Traceback (most recent call last):\n",
 598        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 599        "    estimator.fit(X_train, y_train, **fit_params)\n",
 600        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 601        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 602        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 603        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 604        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 605        "\n",
 606        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 607        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 608        "Traceback (most recent call last):\n",
 609        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 610        "    estimator.fit(X_train, y_train, **fit_params)\n",
 611        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 612        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 613        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 614        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 615        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 616        "\n",
 617        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n"
 618       ]
 619      },
 620      {
 621       "name": "stderr",
 622       "output_type": "stream",
 623       "text": [
 624        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 625        "Traceback (most recent call last):\n",
 626        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 627        "    estimator.fit(X_train, y_train, **fit_params)\n",
 628        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 629        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 630        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 631        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 632        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 633        "\n",
 634        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 635        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 636        "Traceback (most recent call last):\n",
 637        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 638        "    estimator.fit(X_train, y_train, **fit_params)\n",
 639        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 640        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 641        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 642        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 643        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 644        "\n",
 645        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 646        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 647        "Traceback (most recent call last):\n",
 648        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 649        "    estimator.fit(X_train, y_train, **fit_params)\n",
 650        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 651        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 652        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 653        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 654        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 655        "\n",
 656        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 657        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 658        "Traceback (most recent call last):\n",
 659        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 660        "    estimator.fit(X_train, y_train, **fit_params)\n",
 661        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 662        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 663        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 664        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 665        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 666        "\n",
 667        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 668        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 669        "Traceback (most recent call last):\n",
 670        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 671        "    estimator.fit(X_train, y_train, **fit_params)\n",
 672        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 673        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 674        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 675        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 676        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 677        "\n",
 678        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 679        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:610: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
 680        "Traceback (most recent call last):\n",
 681        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 593, in _fit_and_score\n",
 682        "    estimator.fit(X_train, y_train, **fit_params)\n",
 683        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 1306, in fit\n",
 684        "    solver = _check_solver(self.solver, self.penalty, self.dual)\n",
 685        "  File \"C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py\", line 443, in _check_solver\n",
 686        "    raise ValueError(\"Solver %s supports only 'l2' or 'none' penalties, \"\n",
 687        "ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty.\n",
 688        "\n",
 689        "  warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
 690        "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_search.py:918: UserWarning: One or more of the test scores are non-finite: [       nan 0.79347826        nan 0.80797101        nan 0.80797101\n",
 691        "        nan 0.80797101        nan 0.80797101]\n",
 692        "  warnings.warn(\n"
 693       ]
 694      },
 695      {
 696       "data": {
 697        "application/javascript": [
 698         "/* Put everything inside the global mpl namespace */\n",
 699         "/* global mpl */\n",
 700         "window.mpl = {};\n",
 701         "\n",
 702         "mpl.get_websocket_type = function () {\n",
 703         "    if (typeof WebSocket !== 'undefined') {\n",
 704         "        return WebSocket;\n",
 705         "    } else if (typeof MozWebSocket !== 'undefined') {\n",
 706         "        return MozWebSocket;\n",
 707         "    } else {\n",
 708         "        alert(\n",
 709         "            'Your browser does not have WebSocket support. ' +\n",
 710         "                'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
 711         "                'Firefox 4 and 5 are also supported but you ' +\n",
 712         "                'have to enable WebSockets in about:config.'\n",
 713         "        );\n",
 714         "    }\n",
 715         "};\n",
 716         "\n",
 717         "mpl.figure = function (figure_id, websocket, ondownload, parent_element) {\n",
 718         "    this.id = figure_id;\n",
 719         "\n",
 720         "    this.ws = websocket;\n",
 721         "\n",
 722         "    this.supports_binary = this.ws.binaryType !== undefined;\n",
 723         "\n",
 724         "    if (!this.supports_binary) {\n",
 725         "        var warnings = document.getElementById('mpl-warnings');\n",
 726         "        if (warnings) {\n",
 727         "            warnings.style.display = 'block';\n",
 728         "            warnings.textContent =\n",
 729         "                'This browser does not support binary websocket messages. ' +\n",
 730         "                'Performance may be slow.';\n",
 731         "        }\n",
 732         "    }\n",
 733         "\n",
 734         "    this.imageObj = new Image();\n",
 735         "\n",
 736         "    this.context = undefined;\n",
 737         "    this.message = undefined;\n",
 738         "    this.canvas = undefined;\n",
 739         "    this.rubberband_canvas = undefined;\n",
 740         "    this.rubberband_context = undefined;\n",
 741         "    this.format_dropdown = undefined;\n",
 742         "\n",
 743         "    this.image_mode = 'full';\n",
 744         "\n",
 745         "    this.root = document.createElement('div');\n",
 746         "    this.root.setAttribute('style', 'display: inline-block');\n",
 747         "    this._root_extra_style(this.root);\n",
 748         "\n",
 749         "    parent_element.appendChild(this.root);\n",
 750         "\n",
 751         "    this._init_header(this);\n",
 752         "    this._init_canvas(this);\n",
 753         "    this._init_toolbar(this);\n",
 754         "\n",
 755         "    var fig = this;\n",
 756         "\n",
 757         "    this.waiting = false;\n",
 758         "\n",
 759         "    this.ws.onopen = function () {\n",
 760         "        fig.send_message('supports_binary', { value: fig.supports_binary });\n",
 761         "        fig.send_message('send_image_mode', {});\n",
 762         "        if (fig.ratio !== 1) {\n",
 763         "            fig.send_message('set_dpi_ratio', { dpi_ratio: fig.ratio });\n",
 764         "        }\n",
 765         "        fig.send_message('refresh', {});\n",
 766         "    };\n",
 767         "\n",
 768         "    this.imageObj.onload = function () {\n",
 769         "        if (fig.image_mode === 'full') {\n",
 770         "            // Full images could contain transparency (where diff images\n",
 771         "            // almost always do), so we need to clear the canvas so that\n",
 772         "            // there is no ghosting.\n",
 773         "            fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n",
 774         "        }\n",
 775         "        fig.context.drawImage(fig.imageObj, 0, 0);\n",
 776         "    };\n",
 777         "\n",
 778         "    this.imageObj.onunload = function () {\n",
 779         "        fig.ws.close();\n",
 780         "    };\n",
 781         "\n",
 782         "    this.ws.onmessage = this._make_on_message_function(this);\n",
 783         "\n",
 784         "    this.ondownload = ondownload;\n",
 785         "};\n",
 786         "\n",
 787         "mpl.figure.prototype._init_header = function () {\n",
 788         "    var titlebar = document.createElement('div');\n",
 789         "    titlebar.classList =\n",
 790         "        'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix';\n",
 791         "    var titletext = document.createElement('div');\n",
 792         "    titletext.classList = 'ui-dialog-title';\n",
 793         "    titletext.setAttribute(\n",
 794         "        'style',\n",
 795         "        'width: 100%; text-align: center; padding: 3px;'\n",
 796         "    );\n",
 797         "    titlebar.appendChild(titletext);\n",
 798         "    this.root.appendChild(titlebar);\n",
 799         "    this.header = titletext;\n",
 800         "};\n",
 801         "\n",
 802         "mpl.figure.prototype._canvas_extra_style = function (_canvas_div) {};\n",
 803         "\n",
 804         "mpl.figure.prototype._root_extra_style = function (_canvas_div) {};\n",
 805         "\n",
 806         "mpl.figure.prototype._init_canvas = function () {\n",
 807         "    var fig = this;\n",
 808         "\n",
 809         "    var canvas_div = (this.canvas_div = document.createElement('div'));\n",
 810         "    canvas_div.setAttribute(\n",
 811         "        'style',\n",
 812         "        'border: 1px solid #ddd;' +\n",
 813         "            'box-sizing: content-box;' +\n",
 814         "            'clear: both;' +\n",
 815         "            'min-height: 1px;' +\n",
 816         "            'min-width: 1px;' +\n",
 817         "            'outline: 0;' +\n",
 818         "            'overflow: hidden;' +\n",
 819         "            'position: relative;' +\n",
 820         "            'resize: both;'\n",
 821         "    );\n",
 822         "\n",
 823         "    function on_keyboard_event_closure(name) {\n",
 824         "        return function (event) {\n",
 825         "            return fig.key_event(event, name);\n",
 826         "        };\n",
 827         "    }\n",
 828         "\n",
 829         "    canvas_div.addEventListener(\n",
 830         "        'keydown',\n",
 831         "        on_keyboard_event_closure('key_press')\n",
 832         "    );\n",
 833         "    canvas_div.addEventListener(\n",
 834         "        'keyup',\n",
 835         "        on_keyboard_event_closure('key_release')\n",
 836         "    );\n",
 837         "\n",
 838         "    this._canvas_extra_style(canvas_div);\n",
 839         "    this.root.appendChild(canvas_div);\n",
 840         "\n",
 841         "    var canvas = (this.canvas = document.createElement('canvas'));\n",
 842         "    canvas.classList.add('mpl-canvas');\n",
 843         "    canvas.setAttribute('style', 'box-sizing: content-box;');\n",
 844         "\n",
 845         "    this.context = canvas.getContext('2d');\n",
 846         "\n",
 847         "    var backingStore =\n",
 848         "        this.context.backingStorePixelRatio ||\n",
 849         "        this.context.webkitBackingStorePixelRatio ||\n",
 850         "        this.context.mozBackingStorePixelRatio ||\n",
 851         "        this.context.msBackingStorePixelRatio ||\n",
 852         "        this.context.oBackingStorePixelRatio ||\n",
 853         "        this.context.backingStorePixelRatio ||\n",
 854         "        1;\n",
 855         "\n",
 856         "    this.ratio = (window.devicePixelRatio || 1) / backingStore;\n",
 857         "\n",
 858         "    var rubberband_canvas = (this.rubberband_canvas = document.createElement(\n",
 859         "        'canvas'\n",
 860         "    ));\n",
 861         "    rubberband_canvas.setAttribute(\n",
 862         "        'style',\n",
 863         "        'box-sizing: content-box; position: absolute; left: 0; top: 0; z-index: 1;'\n",
 864         "    );\n",
 865         "\n",
 866         "    // Apply a ponyfill if ResizeObserver is not implemented by browser.\n",
 867         "    if (this.ResizeObserver === undefined) {\n",
 868         "        if (window.ResizeObserver !== undefined) {\n",
 869         "            this.ResizeObserver = window.ResizeObserver;\n",
 870         "        } else {\n",
 871         "            var obs = _JSXTOOLS_RESIZE_OBSERVER({});\n",
 872         "            this.ResizeObserver = obs.ResizeObserver;\n",
 873         "        }\n",
 874         "    }\n",
 875         "\n",
 876         "    this.resizeObserverInstance = new this.ResizeObserver(function (entries) {\n",
 877         "        var nentries = entries.length;\n",
 878         "        for (var i = 0; i < nentries; i++) {\n",
 879         "            var entry = entries[i];\n",
 880         "            var width, height;\n",
 881         "            if (entry.contentBoxSize) {\n",
 882         "                if (entry.contentBoxSize instanceof Array) {\n",
 883         "                    // Chrome 84 implements new version of spec.\n",
 884         "                    width = entry.contentBoxSize[0].inlineSize;\n",
 885         "                    height = entry.contentBoxSize[0].blockSize;\n",
 886         "                } else {\n",
 887         "                    // Firefox implements old version of spec.\n",
 888         "                    width = entry.contentBoxSize.inlineSize;\n",
 889         "                    height = entry.contentBoxSize.blockSize;\n",
 890         "                }\n",
 891         "            } else {\n",
 892         "                // Chrome <84 implements even older version of spec.\n",
 893         "                width = entry.contentRect.width;\n",
 894         "                height = entry.contentRect.height;\n",
 895         "            }\n",
 896         "\n",
 897         "            // Keep the size of the canvas and rubber band canvas in sync with\n",
 898         "            // the canvas container.\n",
 899         "            if (entry.devicePixelContentBoxSize) {\n",
 900         "                // Chrome 84 implements new version of spec.\n",
 901         "                canvas.setAttribute(\n",
 902         "                    'width',\n",
 903         "                    entry.devicePixelContentBoxSize[0].inlineSize\n",
 904         "                );\n",
 905         "                canvas.setAttribute(\n",
 906         "                    'height',\n",
 907         "                    entry.devicePixelContentBoxSize[0].blockSize\n",
 908         "                );\n",
 909         "            } else {\n",
 910         "                canvas.setAttribute('width', width * fig.ratio);\n",
 911         "                canvas.setAttribute('height', height * fig.ratio);\n",
 912         "            }\n",
 913         "            canvas.setAttribute(\n",
 914         "                'style',\n",
 915         "                'width: ' + width + 'px; height: ' + height + 'px;'\n",
 916         "            );\n",
 917         "\n",
 918         "            rubberband_canvas.setAttribute('width', width);\n",
 919         "            rubberband_canvas.setAttribute('height', height);\n",
 920         "\n",
 921         "            // And update the size in Python. We ignore the initial 0/0 size\n",
 922         "            // that occurs as the element is placed into the DOM, which should\n",
 923         "            // otherwise not happen due to the minimum size styling.\n",
 924         "            if (fig.ws.readyState == 1 && width != 0 && height != 0) {\n",
 925         "                fig.request_resize(width, height);\n",
 926         "            }\n",
 927         "        }\n",
 928         "    });\n",
 929         "    this.resizeObserverInstance.observe(canvas_div);\n",
 930         "\n",
 931         "    function on_mouse_event_closure(name) {\n",
 932         "        return function (event) {\n",
 933         "            return fig.mouse_event(event, name);\n",
 934         "        };\n",
 935         "    }\n",
 936         "\n",
 937         "    rubberband_canvas.addEventListener(\n",
 938         "        'mousedown',\n",
 939         "        on_mouse_event_closure('button_press')\n",
 940         "    );\n",
 941         "    rubberband_canvas.addEventListener(\n",
 942         "        'mouseup',\n",
 943         "        on_mouse_event_closure('button_release')\n",
 944         "    );\n",
 945         "    // Throttle sequential mouse events to 1 every 20ms.\n",
 946         "    rubberband_canvas.addEventListener(\n",
 947         "        'mousemove',\n",
 948         "        on_mouse_event_closure('motion_notify')\n",
 949         "    );\n",
 950         "\n",
 951         "    rubberband_canvas.addEventListener(\n",
 952         "        'mouseenter',\n",
 953         "        on_mouse_event_closure('figure_enter')\n",
 954         "    );\n",
 955         "    rubberband_canvas.addEventListener(\n",
 956         "        'mouseleave',\n",
 957         "        on_mouse_event_closure('figure_leave')\n",
 958         "    );\n",
 959         "\n",
 960         "    canvas_div.addEventListener('wheel', function (event) {\n",
 961         "        if (event.deltaY < 0) {\n",
 962         "            event.step = 1;\n",
 963         "        } else {\n",
 964         "            event.step = -1;\n",
 965         "        }\n",
 966         "        on_mouse_event_closure('scroll')(event);\n",
 967         "    });\n",
 968         "\n",
 969         "    canvas_div.appendChild(canvas);\n",
 970         "    canvas_div.appendChild(rubberband_canvas);\n",
 971         "\n",
 972         "    this.rubberband_context = rubberband_canvas.getContext('2d');\n",
 973         "    this.rubberband_context.strokeStyle = '#000000';\n",
 974         "\n",
 975         "    this._resize_canvas = function (width, height, forward) {\n",
 976         "        if (forward) {\n",
 977         "            canvas_div.style.width = width + 'px';\n",
 978         "            canvas_div.style.height = height + 'px';\n",
 979         "        }\n",
 980         "    };\n",
 981         "\n",
 982         "    // Disable right mouse context menu.\n",
 983         "    this.rubberband_canvas.addEventListener('contextmenu', function (_e) {\n",
 984         "        event.preventDefault();\n",
 985         "        return false;\n",
 986         "    });\n",
 987         "\n",
 988         "    function set_focus() {\n",
 989         "        canvas.focus();\n",
 990         "        canvas_div.focus();\n",
 991         "    }\n",
 992         "\n",
 993         "    window.setTimeout(set_focus, 100);\n",
 994         "};\n",
 995         "\n",
 996         "mpl.figure.prototype._init_toolbar = function () {\n",
 997         "    var fig = this;\n",
 998         "\n",
 999         "    var toolbar = document.createElement('div');\n",
1000         "    toolbar.classList = 'mpl-toolbar';\n",
1001         "    this.root.appendChild(toolbar);\n",
1002         "\n",
1003         "    function on_click_closure(name) {\n",
1004         "        return function (_event) {\n",
1005         "            return fig.toolbar_button_onclick(name);\n",
1006         "        };\n",
1007         "    }\n",
1008         "\n",
1009         "    function on_mouseover_closure(tooltip) {\n",
1010         "        return function (event) {\n",
1011         "            if (!event.currentTarget.disabled) {\n",
1012         "                return fig.toolbar_button_onmouseover(tooltip);\n",
1013         "            }\n",
1014         "        };\n",
1015         "    }\n",
1016         "\n",
1017         "    fig.buttons = {};\n",
1018         "    var buttonGroup = document.createElement('div');\n",
1019         "    buttonGroup.classList = 'mpl-button-group';\n",
1020         "    for (var toolbar_ind in mpl.toolbar_items) {\n",
1021         "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
1022         "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
1023         "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
1024         "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
1025         "\n",
1026         "        if (!name) {\n",
1027         "            /* Instead of a spacer, we start a new button group. */\n",
1028         "            if (buttonGroup.hasChildNodes()) {\n",
1029         "                toolbar.appendChild(buttonGroup);\n",
1030         "            }\n",
1031         "            buttonGroup = document.createElement('div');\n",
1032         "            buttonGroup.classList = 'mpl-button-group';\n",
1033         "            continue;\n",
1034         "        }\n",
1035         "\n",
1036         "        var button = (fig.buttons[name] = document.createElement('button'));\n",
1037         "        button.classList = 'mpl-widget';\n",
1038         "        button.setAttribute('role', 'button');\n",
1039         "        button.setAttribute('aria-disabled', 'false');\n",
1040         "        button.addEventListener('click', on_click_closure(method_name));\n",
1041         "        button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n",
1042         "\n",
1043         "        var icon_img = document.createElement('img');\n",
1044         "        icon_img.src = '_images/' + image + '.png';\n",
1045         "        icon_img.srcset = '_images/' + image + '_large.png 2x';\n",
1046         "        icon_img.alt = tooltip;\n",
1047         "        button.appendChild(icon_img);\n",
1048         "\n",
1049         "        buttonGroup.appendChild(button);\n",
1050         "    }\n",
1051         "\n",
1052         "    if (buttonGroup.hasChildNodes()) {\n",
1053         "        toolbar.appendChild(buttonGroup);\n",
1054         "    }\n",
1055         "\n",
1056         "    var fmt_picker = document.createElement('select');\n",
1057         "    fmt_picker.classList = 'mpl-widget';\n",
1058         "    toolbar.appendChild(fmt_picker);\n",
1059         "    this.format_dropdown = fmt_picker;\n",
1060         "\n",
1061         "    for (var ind in mpl.extensions) {\n",
1062         "        var fmt = mpl.extensions[ind];\n",
1063         "        var option = document.createElement('option');\n",
1064         "        option.selected = fmt === mpl.default_extension;\n",
1065         "        option.innerHTML = fmt;\n",
1066         "        fmt_picker.appendChild(option);\n",
1067         "    }\n",
1068         "\n",
1069         "    var status_bar = document.createElement('span');\n",
1070         "    status_bar.classList = 'mpl-message';\n",
1071         "    toolbar.appendChild(status_bar);\n",
1072         "    this.message = status_bar;\n",
1073         "};\n",
1074         "\n",
1075         "mpl.figure.prototype.request_resize = function (x_pixels, y_pixels) {\n",
1076         "    // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n",
1077         "    // which will in turn request a refresh of the image.\n",
1078         "    this.send_message('resize', { width: x_pixels, height: y_pixels });\n",
1079         "};\n",
1080         "\n",
1081         "mpl.figure.prototype.send_message = function (type, properties) {\n",
1082         "    properties['type'] = type;\n",
1083         "    properties['figure_id'] = this.id;\n",
1084         "    this.ws.send(JSON.stringify(properties));\n",
1085         "};\n",
1086         "\n",
1087         "mpl.figure.prototype.send_draw_message = function () {\n",
1088         "    if (!this.waiting) {\n",
1089         "        this.waiting = true;\n",
1090         "        this.ws.send(JSON.stringify({ type: 'draw', figure_id: this.id }));\n",
1091         "    }\n",
1092         "};\n",
1093         "\n",
1094         "mpl.figure.prototype.handle_save = function (fig, _msg) {\n",
1095         "    var format_dropdown = fig.format_dropdown;\n",
1096         "    var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n",
1097         "    fig.ondownload(fig, format);\n",
1098         "};\n",
1099         "\n",
1100         "mpl.figure.prototype.handle_resize = function (fig, msg) {\n",
1101         "    var size = msg['size'];\n",
1102         "    if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) {\n",
1103         "        fig._resize_canvas(size[0], size[1], msg['forward']);\n",
1104         "        fig.send_message('refresh', {});\n",
1105         "    }\n",
1106         "};\n",
1107         "\n",
1108         "mpl.figure.prototype.handle_rubberband = function (fig, msg) {\n",
1109         "    var x0 = msg['x0'] / fig.ratio;\n",
1110         "    var y0 = (fig.canvas.height - msg['y0']) / fig.ratio;\n",
1111         "    var x1 = msg['x1'] / fig.ratio;\n",
1112         "    var y1 = (fig.canvas.height - msg['y1']) / fig.ratio;\n",
1113         "    x0 = Math.floor(x0) + 0.5;\n",
1114         "    y0 = Math.floor(y0) + 0.5;\n",
1115         "    x1 = Math.floor(x1) + 0.5;\n",
1116         "    y1 = Math.floor(y1) + 0.5;\n",
1117         "    var min_x = Math.min(x0, x1);\n",
1118         "    var min_y = Math.min(y0, y1);\n",
1119         "    var width = Math.abs(x1 - x0);\n",
1120         "    var height = Math.abs(y1 - y0);\n",
1121         "\n",
1122         "    fig.rubberband_context.clearRect(\n",
1123         "        0,\n",
1124         "        0,\n",
1125         "        fig.canvas.width / fig.ratio,\n",
1126         "        fig.canvas.height / fig.ratio\n",
1127         "    );\n",
1128         "\n",
1129         "    fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n",
1130         "};\n",
1131         "\n",
1132         "mpl.figure.prototype.handle_figure_label = function (fig, msg) {\n",
1133         "    // Updates the figure title.\n",
1134         "    fig.header.textContent = msg['label'];\n",
1135         "};\n",
1136         "\n",
1137         "mpl.figure.prototype.handle_cursor = function (fig, msg) {\n",
1138         "    var cursor = msg['cursor'];\n",
1139         "    switch (cursor) {\n",
1140         "        case 0:\n",
1141         "            cursor = 'pointer';\n",
1142         "            break;\n",
1143         "        case 1:\n",
1144         "            cursor = 'default';\n",
1145         "            break;\n",
1146         "        case 2:\n",
1147         "            cursor = 'crosshair';\n",
1148         "            break;\n",
1149         "        case 3:\n",
1150         "            cursor = 'move';\n",
1151         "            break;\n",
1152         "    }\n",
1153         "    fig.rubberband_canvas.style.cursor = cursor;\n",
1154         "};\n",
1155         "\n",
1156         "mpl.figure.prototype.handle_message = function (fig, msg) {\n",
1157         "    fig.message.textContent = msg['message'];\n",
1158         "};\n",
1159         "\n",
1160         "mpl.figure.prototype.handle_draw = function (fig, _msg) {\n",
1161         "    // Request the server to send over a new figure.\n",
1162         "    fig.send_draw_message();\n",
1163         "};\n",
1164         "\n",
1165         "mpl.figure.prototype.handle_image_mode = function (fig, msg) {\n",
1166         "    fig.image_mode = msg['mode'];\n",
1167         "};\n",
1168         "\n",
1169         "mpl.figure.prototype.handle_history_buttons = function (fig, msg) {\n",
1170         "    for (var key in msg) {\n",
1171         "        if (!(key in fig.buttons)) {\n",
1172         "            continue;\n",
1173         "        }\n",
1174         "        fig.buttons[key].disabled = !msg[key];\n",
1175         "        fig.buttons[key].setAttribute('aria-disabled', !msg[key]);\n",
1176         "    }\n",
1177         "};\n",
1178         "\n",
1179         "mpl.figure.prototype.handle_navigate_mode = function (fig, msg) {\n",
1180         "    if (msg['mode'] === 'PAN') {\n",
1181         "        fig.buttons['Pan'].classList.add('active');\n",
1182         "        fig.buttons['Zoom'].classList.remove('active');\n",
1183         "    } else if (msg['mode'] === 'ZOOM') {\n",
1184         "        fig.buttons['Pan'].classList.remove('active');\n",
1185         "        fig.buttons['Zoom'].classList.add('active');\n",
1186         "    } else {\n",
1187         "        fig.buttons['Pan'].classList.remove('active');\n",
1188         "        fig.buttons['Zoom'].classList.remove('active');\n",
1189         "    }\n",
1190         "};\n",
1191         "\n",
1192         "mpl.figure.prototype.updated_canvas_event = function () {\n",
1193         "    // Called whenever the canvas gets updated.\n",
1194         "    this.send_message('ack', {});\n",
1195         "};\n",
1196         "\n",
1197         "// A function to construct a web socket function for onmessage handling.\n",
1198         "// Called in the figure constructor.\n",
1199         "mpl.figure.prototype._make_on_message_function = function (fig) {\n",
1200         "    return function socket_on_message(evt) {\n",
1201         "        if (evt.data instanceof Blob) {\n",
1202         "            /* FIXME: We get \"Resource interpreted as Image but\n",
1203         "             * transferred with MIME type text/plain:\" errors on\n",
1204         "             * Chrome.  But how to set the MIME type?  It doesn't seem\n",
1205         "             * to be part of the websocket stream */\n",
1206         "            evt.data.type = 'image/png';\n",
1207         "\n",
1208         "            /* Free the memory for the previous frames */\n",
1209         "            if (fig.imageObj.src) {\n",
1210         "                (window.URL || window.webkitURL).revokeObjectURL(\n",
1211         "                    fig.imageObj.src\n",
1212         "                );\n",
1213         "            }\n",
1214         "\n",
1215         "            fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n",
1216         "                evt.data\n",
1217         "            );\n",
1218         "            fig.updated_canvas_event();\n",
1219         "            fig.waiting = false;\n",
1220         "            return;\n",
1221         "        } else if (\n",
1222         "            typeof evt.data === 'string' &&\n",
1223         "            evt.data.slice(0, 21) === 'data:image/png;base64'\n",
1224         "        ) {\n",
1225         "            fig.imageObj.src = evt.data;\n",
1226         "            fig.updated_canvas_event();\n",
1227         "            fig.waiting = false;\n",
1228         "            return;\n",
1229         "        }\n",
1230         "\n",
1231         "        var msg = JSON.parse(evt.data);\n",
1232         "        var msg_type = msg['type'];\n",
1233         "\n",
1234         "        // Call the  \"handle_{type}\" callback, which takes\n",
1235         "        // the figure and JSON message as its only arguments.\n",
1236         "        try {\n",
1237         "            var callback = fig['handle_' + msg_type];\n",
1238         "        } catch (e) {\n",
1239         "            console.log(\n",
1240         "                \"No handler for the '\" + msg_type + \"' message type: \",\n",
1241         "                msg\n",
1242         "            );\n",
1243         "            return;\n",
1244         "        }\n",
1245         "\n",
1246         "        if (callback) {\n",
1247         "            try {\n",
1248         "                // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n",
1249         "                callback(fig, msg);\n",
1250         "            } catch (e) {\n",
1251         "                console.log(\n",
1252         "                    \"Exception inside the 'handler_\" + msg_type + \"' callback:\",\n",
1253         "                    e,\n",
1254         "                    e.stack,\n",
1255         "                    msg\n",
1256         "                );\n",
1257         "            }\n",
1258         "        }\n",
1259         "    };\n",
1260         "};\n",
1261         "\n",
1262         "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n",
1263         "mpl.findpos = function (e) {\n",
1264         "    //this section is from http://www.quirksmode.org/js/events_properties.html\n",
1265         "    var targ;\n",
1266         "    if (!e) {\n",
1267         "        e = window.event;\n",
1268         "    }\n",
1269         "    if (e.target) {\n",
1270         "        targ = e.target;\n",
1271         "    } else if (e.srcElement) {\n",
1272         "        targ = e.srcElement;\n",
1273         "    }\n",
1274         "    if (targ.nodeType === 3) {\n",
1275         "        // defeat Safari bug\n",
1276         "        targ = targ.parentNode;\n",
1277         "    }\n",
1278         "\n",
1279         "    // pageX,Y are the mouse positions relative to the document\n",
1280         "    var boundingRect = targ.getBoundingClientRect();\n",
1281         "    var x = e.pageX - (boundingRect.left + document.body.scrollLeft);\n",
1282         "    var y = e.pageY - (boundingRect.top + document.body.scrollTop);\n",
1283         "\n",
1284         "    return { x: x, y: y };\n",
1285         "};\n",
1286         "\n",
1287         "/*\n",
1288         " * return a copy of an object with only non-object keys\n",
1289         " * we need this to avoid circular references\n",
1290         " * http://stackoverflow.com/a/24161582/3208463\n",
1291         " */\n",
1292         "function simpleKeys(original) {\n",
1293         "    return Object.keys(original).reduce(function (obj, key) {\n",
1294         "        if (typeof original[key] !== 'object') {\n",
1295         "            obj[key] = original[key];\n",
1296         "        }\n",
1297         "        return obj;\n",
1298         "    }, {});\n",
1299         "}\n",
1300         "\n",
1301         "mpl.figure.prototype.mouse_event = function (event, name) {\n",
1302         "    var canvas_pos = mpl.findpos(event);\n",
1303         "\n",
1304         "    if (name === 'button_press') {\n",
1305         "        this.canvas.focus();\n",
1306         "        this.canvas_div.focus();\n",
1307         "    }\n",
1308         "\n",
1309         "    var x = canvas_pos.x * this.ratio;\n",
1310         "    var y = canvas_pos.y * this.ratio;\n",
1311         "\n",
1312         "    this.send_message(name, {\n",
1313         "        x: x,\n",
1314         "        y: y,\n",
1315         "        button: event.button,\n",
1316         "        step: event.step,\n",
1317         "        guiEvent: simpleKeys(event),\n",
1318         "    });\n",
1319         "\n",
1320         "    /* This prevents the web browser from automatically changing to\n",
1321         "     * the text insertion cursor when the button is pressed.  We want\n",
1322         "     * to control all of the cursor setting manually through the\n",
1323         "     * 'cursor' event from matplotlib */\n",
1324         "    event.preventDefault();\n",
1325         "    return false;\n",
1326         "};\n",
1327         "\n",
1328         "mpl.figure.prototype._key_event_extra = function (_event, _name) {\n",
1329         "    // Handle any extra behaviour associated with a key event\n",
1330         "};\n",
1331         "\n",
1332         "mpl.figure.prototype.key_event = function (event, name) {\n",
1333         "    // Prevent repeat events\n",
1334         "    if (name === 'key_press') {\n",
1335         "        if (event.which === this._key) {\n",
1336         "            return;\n",
1337         "        } else {\n",
1338         "            this._key = event.which;\n",
1339         "        }\n",
1340         "    }\n",
1341         "    if (name === 'key_release') {\n",
1342         "        this._key = null;\n",
1343         "    }\n",
1344         "\n",
1345         "    var value = '';\n",
1346         "    if (event.ctrlKey && event.which !== 17) {\n",
1347         "        value += 'ctrl+';\n",
1348         "    }\n",
1349         "    if (event.altKey && event.which !== 18) {\n",
1350         "        value += 'alt+';\n",
1351         "    }\n",
1352         "    if (event.shiftKey && event.which !== 16) {\n",
1353         "        value += 'shift+';\n",
1354         "    }\n",
1355         "\n",
1356         "    value += 'k';\n",
1357         "    value += event.which.toString();\n",
1358         "\n",
1359         "    this._key_event_extra(event, name);\n",
1360         "\n",
1361         "    this.send_message(name, { key: value, guiEvent: simpleKeys(event) });\n",
1362         "    return false;\n",
1363         "};\n",
1364         "\n",
1365         "mpl.figure.prototype.toolbar_button_onclick = function (name) {\n",
1366         "    if (name === 'download') {\n",
1367         "        this.handle_save(this, null);\n",
1368         "    } else {\n",
1369         "        this.send_message('toolbar_button', { name: name });\n",
1370         "    }\n",
1371         "};\n",
1372         "\n",
1373         "mpl.figure.prototype.toolbar_button_onmouseover = function (tooltip) {\n",
1374         "    this.message.textContent = tooltip;\n",
1375         "};\n",
1376         "\n",
1377         "///////////////// REMAINING CONTENT GENERATED BY embed_js.py /////////////////\n",
1378         "// prettier-ignore\n",
1379         "var _JSXTOOLS_RESIZE_OBSERVER=function(A){var t,i=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakMap,o=new Set;function s(e){if(!(this instanceof s))throw new TypeError(\"Constructor requires 'new' operator\");i.set(this,e)}function h(){throw new TypeError(\"Function is not a constructor\")}function c(e,t,i,n){e=0 in arguments?Number(arguments[0]):0,t=1 in arguments?Number(arguments[1]):0,i=2 in arguments?Number(arguments[2]):0,n=3 in arguments?Number(arguments[3]):0,this.right=(this.x=this.left=e)+(this.width=i),this.bottom=(this.y=this.top=t)+(this.height=n),Object.freeze(this)}function d(){t=requestAnimationFrame(d);var s=new WeakMap,p=new Set;o.forEach((function(t){r.get(t).forEach((function(i){var r=t instanceof window.SVGElement,o=a.get(t),d=r?0:parseFloat(o.paddingTop),f=r?0:parseFloat(o.paddingRight),l=r?0:parseFloat(o.paddingBottom),u=r?0:parseFloat(o.paddingLeft),g=r?0:parseFloat(o.borderTopWidth),m=r?0:parseFloat(o.borderRightWidth),w=r?0:parseFloat(o.borderBottomWidth),b=u+f,F=d+l,v=(r?0:parseFloat(o.borderLeftWidth))+m,W=g+w,y=r?0:t.offsetHeight-W-t.clientHeight,E=r?0:t.offsetWidth-v-t.clientWidth,R=b+v,z=F+W,M=r?t.width:parseFloat(o.width)-R-E,O=r?t.height:parseFloat(o.height)-z-y;if(n.has(t)){var k=n.get(t);if(k[0]===M&&k[1]===O)return}n.set(t,[M,O]);var S=Object.create(h.prototype);S.target=t,S.contentRect=new c(u,d,M,O),s.has(i)||(s.set(i,[]),p.add(i)),s.get(i).push(S)}))})),p.forEach((function(e){i.get(e).call(e,s.get(e),e)}))}return s.prototype.observe=function(i){if(i instanceof window.Element){r.has(i)||(r.set(i,new Set),o.add(i),a.set(i,window.getComputedStyle(i)));var n=r.get(i);n.has(this)||n.add(this),cancelAnimationFrame(t),t=requestAnimationFrame(d)}},s.prototype.unobserve=function(i){if(i instanceof window.Element&&r.has(i)){var n=r.get(i);n.has(this)&&(n.delete(this),n.size||(r.delete(i),o.delete(i))),n.size||r.delete(i),o.size||cancelAnimationFrame(t)}},A.DOMRectReadOnly=c,A.ResizeObserver=s,A.ResizeObserverEntry=h,A}; // eslint-disable-line\n",
1380         "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Left button pans, Right button zooms\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n",
1381         "\n",
1382         "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n",
1383         "\n",
1384         "mpl.default_extension = \"png\";/* global mpl */\n",
1385         "\n",
1386         "var comm_websocket_adapter = function (comm) {\n",
1387         "    // Create a \"websocket\"-like object which calls the given IPython comm\n",
1388         "    // object with the appropriate methods. Currently this is a non binary\n",
1389         "    // socket, so there is still some room for performance tuning.\n",
1390         "    var ws = {};\n",
1391         "\n",
1392         "    ws.close = function () {\n",
1393         "        comm.close();\n",
1394         "    };\n",
1395         "    ws.send = function (m) {\n",
1396         "        //console.log('sending', m);\n",
1397         "        comm.send(m);\n",
1398         "    };\n",
1399         "    // Register the callback with on_msg.\n",
1400         "    comm.on_msg(function (msg) {\n",
1401         "        //console.log('receiving', msg['content']['data'], msg);\n",
1402         "        // Pass the mpl event to the overridden (by mpl) onmessage function.\n",
1403         "        ws.onmessage(msg['content']['data']);\n",
1404         "    });\n",
1405         "    return ws;\n",
1406         "};\n",
1407         "\n",
1408         "mpl.mpl_figure_comm = function (comm, msg) {\n",
1409         "    // This is the function which gets called when the mpl process\n",
1410         "    // starts-up an IPython Comm through the \"matplotlib\" channel.\n",
1411         "\n",
1412         "    var id = msg.content.data.id;\n",
1413         "    // Get hold of the div created by the display call when the Comm\n",
1414         "    // socket was opened in Python.\n",
1415         "    var element = document.getElementById(id);\n",
1416         "    var ws_proxy = comm_websocket_adapter(comm);\n",
1417         "\n",
1418         "    function ondownload(figure, _format) {\n",
1419         "        window.open(figure.canvas.toDataURL());\n",
1420         "    }\n",
1421         "\n",
1422         "    var fig = new mpl.figure(id, ws_proxy, ondownload, element);\n",
1423         "\n",
1424         "    // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n",
1425         "    // web socket which is closed, not our websocket->open comm proxy.\n",
1426         "    ws_proxy.onopen();\n",
1427         "\n",
1428         "    fig.parent_element = element;\n",
1429         "    fig.cell_info = mpl.find_output_cell(\"<div id='\" + id + \"'></div>\");\n",
1430         "    if (!fig.cell_info) {\n",
1431         "        console.error('Failed to find cell for figure', id, fig);\n",
1432         "        return;\n",
1433         "    }\n",
1434         "    fig.cell_info[0].output_area.element.on(\n",
1435         "        'cleared',\n",
1436         "        { fig: fig },\n",
1437         "        fig._remove_fig_handler\n",
1438         "    );\n",
1439         "};\n",
1440         "\n",
1441         "mpl.figure.prototype.handle_close = function (fig, msg) {\n",
1442         "    var width = fig.canvas.width / fig.ratio;\n",
1443         "    fig.cell_info[0].output_area.element.off(\n",
1444         "        'cleared',\n",
1445         "        fig._remove_fig_handler\n",
1446         "    );\n",
1447         "    fig.resizeObserverInstance.unobserve(fig.canvas_div);\n",
1448         "\n",
1449         "    // Update the output cell to use the data from the current canvas.\n",
1450         "    fig.push_to_output();\n",
1451         "    var dataURL = fig.canvas.toDataURL();\n",
1452         "    // Re-enable the keyboard manager in IPython - without this line, in FF,\n",
1453         "    // the notebook keyboard shortcuts fail.\n",
1454         "    IPython.keyboard_manager.enable();\n",
1455         "    fig.parent_element.innerHTML =\n",
1456         "        '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
1457         "    fig.close_ws(fig, msg);\n",
1458         "};\n",
1459         "\n",
1460         "mpl.figure.prototype.close_ws = function (fig, msg) {\n",
1461         "    fig.send_message('closing', msg);\n",
1462         "    // fig.ws.close()\n",
1463         "};\n",
1464         "\n",
1465         "mpl.figure.prototype.push_to_output = function (_remove_interactive) {\n",
1466         "    // Turn the data on the canvas into data in the output cell.\n",
1467         "    var width = this.canvas.width / this.ratio;\n",
1468         "    var dataURL = this.canvas.toDataURL();\n",
1469         "    this.cell_info[1]['text/html'] =\n",
1470         "        '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
1471         "};\n",
1472         "\n",
1473         "mpl.figure.prototype.updated_canvas_event = function () {\n",
1474         "    // Tell IPython that the notebook contents must change.\n",
1475         "    IPython.notebook.set_dirty(true);\n",
1476         "    this.send_message('ack', {});\n",
1477         "    var fig = this;\n",
1478         "    // Wait a second, then push the new image to the DOM so\n",
1479         "    // that it is saved nicely (might be nice to debounce this).\n",
1480         "    setTimeout(function () {\n",
1481         "        fig.push_to_output();\n",
1482         "    }, 1000);\n",
1483         "};\n",
1484         "\n",
1485         "mpl.figure.prototype._init_toolbar = function () {\n",
1486         "    var fig = this;\n",
1487         "\n",
1488         "    var toolbar = document.createElement('div');\n",
1489         "    toolbar.classList = 'btn-toolbar';\n",
1490         "    this.root.appendChild(toolbar);\n",
1491         "\n",
1492         "    function on_click_closure(name) {\n",
1493         "        return function (_event) {\n",
1494         "            return fig.toolbar_button_onclick(name);\n",
1495         "        };\n",
1496         "    }\n",
1497         "\n",
1498         "    function on_mouseover_closure(tooltip) {\n",
1499         "        return function (event) {\n",
1500         "            if (!event.currentTarget.disabled) {\n",
1501         "                return fig.toolbar_button_onmouseover(tooltip);\n",
1502         "            }\n",
1503         "        };\n",
1504         "    }\n",
1505         "\n",
1506         "    fig.buttons = {};\n",
1507         "    var buttonGroup = document.createElement('div');\n",
1508         "    buttonGroup.classList = 'btn-group';\n",
1509         "    var button;\n",
1510         "    for (var toolbar_ind in mpl.toolbar_items) {\n",
1511         "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
1512         "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
1513         "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
1514         "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
1515         "\n",
1516         "        if (!name) {\n",
1517         "            /* Instead of a spacer, we start a new button group. */\n",
1518         "            if (buttonGroup.hasChildNodes()) {\n",
1519         "                toolbar.appendChild(buttonGroup);\n",
1520         "            }\n",
1521         "            buttonGroup = document.createElement('div');\n",
1522         "            buttonGroup.classList = 'btn-group';\n",
1523         "            continue;\n",
1524         "        }\n",
1525         "\n",
1526         "        button = fig.buttons[name] = document.createElement('button');\n",
1527         "        button.classList = 'btn btn-default';\n",
1528         "        button.href = '#';\n",
1529         "        button.title = name;\n",
1530         "        button.innerHTML = '<i class=\"fa ' + image + ' fa-lg\"></i>';\n",
1531         "        button.addEventListener('click', on_click_closure(method_name));\n",
1532         "        button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n",
1533         "        buttonGroup.appendChild(button);\n",
1534         "    }\n",
1535         "\n",
1536         "    if (buttonGroup.hasChildNodes()) {\n",
1537         "        toolbar.appendChild(buttonGroup);\n",
1538         "    }\n",
1539         "\n",
1540         "    // Add the status bar.\n",
1541         "    var status_bar = document.createElement('span');\n",
1542         "    status_bar.classList = 'mpl-message pull-right';\n",
1543         "    toolbar.appendChild(status_bar);\n",
1544         "    this.message = status_bar;\n",
1545         "\n",
1546         "    // Add the close button to the window.\n",
1547         "    var buttongrp = document.createElement('div');\n",
1548         "    buttongrp.classList = 'btn-group inline pull-right';\n",
1549         "    button = document.createElement('button');\n",
1550         "    button.classList = 'btn btn-mini btn-primary';\n",
1551         "    button.href = '#';\n",
1552         "    button.title = 'Stop Interaction';\n",
1553         "    button.innerHTML = '<i class=\"fa fa-power-off icon-remove icon-large\"></i>';\n",
1554         "    button.addEventListener('click', function (_evt) {\n",
1555         "        fig.handle_close(fig, {});\n",
1556         "    });\n",
1557         "    button.addEventListener(\n",
1558         "        'mouseover',\n",
1559         "        on_mouseover_closure('Stop Interaction')\n",
1560         "    );\n",
1561         "    buttongrp.appendChild(button);\n",
1562         "    var titlebar = this.root.querySelector('.ui-dialog-titlebar');\n",
1563         "    titlebar.insertBefore(buttongrp, titlebar.firstChild);\n",
1564         "};\n",
1565         "\n",
1566         "mpl.figure.prototype._remove_fig_handler = function (event) {\n",
1567         "    var fig = event.data.fig;\n",
1568         "    if (event.target !== this) {\n",
1569         "        // Ignore bubbled events from children.\n",
1570         "        return;\n",
1571         "    }\n",
1572         "    fig.close_ws(fig, {});\n",
1573         "};\n",
1574         "\n",
1575         "mpl.figure.prototype._root_extra_style = function (el) {\n",
1576         "    el.style.boxSizing = 'content-box'; // override notebook setting of border-box.\n",
1577         "};\n",
1578         "\n",
1579         "mpl.figure.prototype._canvas_extra_style = function (el) {\n",
1580         "    // this is important to make the div 'focusable\n",
1581         "    el.setAttribute('tabindex', 0);\n",
1582         "    // reach out to IPython and tell the keyboard manager to turn it's self\n",
1583         "    // off when our div gets focus\n",
1584         "\n",
1585         "    // location in version 3\n",
1586         "    if (IPython.notebook.keyboard_manager) {\n",
1587         "        IPython.notebook.keyboard_manager.register_events(el);\n",
1588         "    } else {\n",
1589         "        // location in version 2\n",
1590         "        IPython.keyboard_manager.register_events(el);\n",
1591         "    }\n",
1592         "};\n",
1593         "\n",
1594         "mpl.figure.prototype._key_event_extra = function (event, _name) {\n",
1595         "    var manager = IPython.notebook.keyboard_manager;\n",
1596         "    if (!manager) {\n",
1597         "        manager = IPython.keyboard_manager;\n",
1598         "    }\n",
1599         "\n",
1600         "    // Check for shift+enter\n",
1601         "    if (event.shiftKey && event.which === 13) {\n",
1602         "        this.canvas_div.blur();\n",
1603         "        // select the cell after this one\n",
1604         "        var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
1605         "        IPython.notebook.select(index + 1);\n",
1606         "    }\n",
1607         "};\n",
1608         "\n",
1609         "mpl.figure.prototype.handle_save = function (fig, _msg) {\n",
1610         "    fig.ondownload(fig, null);\n",
1611         "};\n",
1612         "\n",
1613         "mpl.find_output_cell = function (html_output) {\n",
1614         "    // Return the cell and output element which can be found *uniquely* in the notebook.\n",
1615         "    // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n",
1616         "    // IPython event is triggered only after the cells have been serialised, which for\n",
1617         "    // our purposes (turning an active figure into a static one), is too late.\n",
1618         "    var cells = IPython.notebook.get_cells();\n",
1619         "    var ncells = cells.length;\n",
1620         "    for (var i = 0; i < ncells; i++) {\n",
1621         "        var cell = cells[i];\n",
1622         "        if (cell.cell_type === 'code') {\n",
1623         "            for (var j = 0; j < cell.output_area.outputs.length; j++) {\n",
1624         "                var data = cell.output_area.outputs[j];\n",
1625         "                if (data.data) {\n",
1626         "                    // IPython >= 3 moved mimebundle to data attribute of output\n",
1627         "                    data = data.data;\n",
1628         "                }\n",
1629         "                if (data['text/html'] === html_output) {\n",
1630         "                    return [cell, data, j];\n",
1631         "                }\n",
1632         "            }\n",
1633         "        }\n",
1634         "    }\n",
1635         "};\n",
1636         "\n",
1637         "// Register the function which deals with the matplotlib target/channel.\n",
1638         "// The kernel may be null if the page has been refreshed.\n",
1639         "if (IPython.notebook.kernel !== null) {\n",
1640         "    IPython.notebook.kernel.comm_manager.register_target(\n",
1641         "        'matplotlib',\n",
1642         "        mpl.mpl_figure_comm\n",
1643         "    );\n",
1644         "}\n"
1645        ],
1646        "text/plain": [
1647         "<IPython.core.display.Javascript object>"
1648        ]
1649       },
1650       "metadata": {},
1651       "output_type": "display_data"
1652      },
1653      {
1654       "data": {
1655        "text/html": [
1656         "<div id='64a7cce9-537c-43aa-9f74-d293f7d04b50'></div>"
1657        ],
1658        "text/plain": [
1659         "<IPython.core.display.HTML object>"
1660        ]
1661       },
1662       "metadata": {},
1663       "output_type": "display_data"
1664      },
1665      {
1666       "ename": "AttributeError",
1667       "evalue": "'dict' object has no attribute 'reshape'",
1668       "output_type": "error",
1669       "traceback": [
1670        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
1671        "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
1672        "\u001b[1;32m<ipython-input-27-40a969f0ab22>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      8\u001b[0m     \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0myticks\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mrotation\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 10\u001b[1;33m \u001b[0mGridSearch_Heatmap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0manswer_six\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
1673        "\u001b[1;32m<ipython-input-27-40a969f0ab22>\u001b[0m in \u001b[0;36mGridSearch_Heatmap\u001b[1;34m(scores)\u001b[0m\n\u001b[0;32m      5\u001b[0m     \u001b[1;32mimport\u001b[0m \u001b[0mmatplotlib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpyplot\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m     \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfigure\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 7\u001b[1;33m     \u001b[0msns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mheatmap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mscores\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mxticklabels\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'l1'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'l2'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0myticklabels\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0.01\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m0.1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m10\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m100\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      8\u001b[0m     \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0myticks\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mrotation\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
1674        "\u001b[1;31mAttributeError\u001b[0m: 'dict' object has no attribute 'reshape'"
1675       ]
1676      }
1677     ],
1678     "source": [
1679      "# Use the following function to help visualize results from the grid search\n",
1680      "def GridSearch_Heatmap(scores):\n",
1681      "    %matplotlib notebook\n",
1682      "    import seaborn as sns\n",
1683      "    import matplotlib.pyplot as plt\n",
1684      "    plt.figure()\n",
1685      "    sns.heatmap(scores.reshape(5,2), xticklabels=['l1','l2'], yticklabels=[0.01, 0.1, 1, 10, 100])\n",
1686      "    plt.yticks(rotation=0);\n",
1687      "\n",
1688      "GridSearch_Heatmap(answer_six())"
1689     ]
1690    },
1691    {
1692     "cell_type": "code",
1693     "execution_count": null,
1694     "metadata": {},
1695     "outputs": [],
1696     "source": []
1697    }
1698   ],
1699   "metadata": {
1700    "coursera": {
1701     "course_slug": "python-machine-learning",
1702     "graded_item_id": "5yX9Z",
1703     "launcher_item_id": "eqnV3",
1704     "part_id": "Msnj0"
1705    },
1706    "kernelspec": {
1707     "display_name": "Python 3",
1708     "language": "python",
1709     "name": "python3"
1710    },
1711    "language_info": {
1712     "codemirror_mode": {
1713      "name": "ipython",
1714      "version": 3
1715     },
1716     "file_extension": ".py",
1717     "mimetype": "text/x-python",
1718     "name": "python",
1719     "nbconvert_exporter": "python",
1720     "pygments_lexer": "ipython3",
1721     "version": "3.8.8"
1722    }
1723   },
1724   "nbformat": 4,
1725   "nbformat_minor": 2
1726  }
1727