From df14b513f5fe0cac9ef1ba2ba2d6783e2a76f5f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Fri, 7 Jul 2017 21:56:30 +0200 Subject: [PATCH] Fix multilabel typo --- 03_classification.ipynb | 640 +++++++++------------------------------- 1 file changed, 141 insertions(+), 499 deletions(-) diff --git a/03_classification.ipynb b/03_classification.ipynb index 444f52f..74f2b16 100644 --- a/03_classification.ipynb +++ b/03_classification.ipynb @@ -2,10 +2,7 @@ "cells": [ { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "**Chapter 3 – Classification**\n", "\n", @@ -14,20 +11,14 @@ }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "# Setup" ] }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "First, let's make sure this notebook works well in both python 2 and 3, import a few common modules, ensure MatplotLib plots figures inline and prepare a function to save the figures:" ] @@ -35,11 +26,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "# To support both python 2 and python 3\n", @@ -74,10 +61,7 @@ }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "# MNIST" ] @@ -85,11 +69,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "from sklearn.datasets import fetch_mldata\n", @@ -100,11 +80,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "X, y = mnist[\"data\"], mnist[\"target\"]\n", @@ -114,11 +90,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "y.shape" @@ -127,11 +99,7 @@ { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "28*28" @@ -140,11 +108,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", @@ -165,9 +129,7 @@ "cell_type": "code", "execution_count": 7, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -181,11 +143,7 @@ { "cell_type": "code", "execution_count": 8, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "# EXTRA\n", @@ -208,11 +166,7 @@ { "cell_type": "code", "execution_count": 9, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(9,9))\n", @@ -225,11 +179,7 @@ { "cell_type": "code", "execution_count": 10, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "y[36000]" @@ -239,9 +189,7 @@ "cell_type": "code", "execution_count": 11, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -252,9 +200,7 @@ "cell_type": "code", "execution_count": 12, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -266,10 +212,7 @@ }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "# Binary classifier" ] @@ -278,9 +221,7 @@ "cell_type": "code", "execution_count": 13, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -291,11 +232,7 @@ { "cell_type": "code", "execution_count": 14, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "from sklearn.linear_model import SGDClassifier\n", @@ -307,11 +244,7 @@ { "cell_type": "code", "execution_count": 15, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "sgd_clf.predict([some_digit])" @@ -320,11 +253,7 @@ { "cell_type": "code", "execution_count": 16, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "from sklearn.model_selection import cross_val_score\n", @@ -334,11 +263,7 @@ { "cell_type": "code", "execution_count": 17, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "from sklearn.model_selection import StratifiedKFold\n", @@ -363,9 +288,7 @@ "cell_type": "code", "execution_count": 18, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -380,11 +303,7 @@ { "cell_type": "code", "execution_count": 19, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "never_5_clf = Never5Classifier()\n", @@ -394,11 +313,7 @@ { "cell_type": "code", "execution_count": 20, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "from sklearn.model_selection import cross_val_predict\n", @@ -409,11 +324,7 @@ { "cell_type": "code", "execution_count": 21, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "from sklearn.metrics import confusion_matrix\n", @@ -425,9 +336,7 @@ "cell_type": "code", "execution_count": 22, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -437,11 +346,7 @@ { "cell_type": "code", "execution_count": 23, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "confusion_matrix(y_train_5, y_train_perfect_predictions)" @@ -450,11 +355,7 @@ { "cell_type": "code", "execution_count": 24, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "from sklearn.metrics import precision_score, recall_score\n", @@ -465,11 +366,7 @@ { "cell_type": "code", "execution_count": 25, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "4344 / (4344 + 1307)" @@ -478,11 +375,7 @@ { "cell_type": "code", "execution_count": 26, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "recall_score(y_train_5, y_train_pred)" @@ -491,11 +384,7 @@ { "cell_type": "code", "execution_count": 27, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "4344 / (4344 + 1077)" @@ -504,11 +393,7 @@ { "cell_type": "code", "execution_count": 28, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "from sklearn.metrics import f1_score\n", @@ -518,11 +403,7 @@ { "cell_type": "code", "execution_count": 29, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "4344 / (4344 + (1077 + 1307)/2)" @@ -531,11 +412,7 @@ { "cell_type": "code", "execution_count": 30, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "y_scores = sgd_clf.decision_function([some_digit])\n", @@ -546,9 +423,7 @@ "cell_type": "code", "execution_count": 31, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -559,11 +434,7 @@ { "cell_type": "code", "execution_count": 32, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "y_some_digit_pred" @@ -572,11 +443,7 @@ { "cell_type": "code", "execution_count": 33, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "threshold = 200000\n", @@ -588,9 +455,7 @@ "cell_type": "code", "execution_count": 34, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -602,9 +467,7 @@ "cell_type": "code", "execution_count": 35, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -616,11 +479,7 @@ { "cell_type": "code", "execution_count": 36, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "def plot_precision_recall_vs_threshold(precisions, recalls, thresholds):\n", @@ -640,11 +499,7 @@ { "cell_type": "code", "execution_count": 37, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "(y_train_pred == (y_scores > 0)).all()" @@ -653,11 +508,7 @@ { "cell_type": "code", "execution_count": 38, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "y_train_pred_90 = (y_scores > 70000)" @@ -666,11 +517,7 @@ { "cell_type": "code", "execution_count": 39, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "precision_score(y_train_5, y_train_pred_90)" @@ -679,11 +526,7 @@ { "cell_type": "code", "execution_count": 40, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "recall_score(y_train_5, y_train_pred_90)" @@ -692,11 +535,7 @@ { "cell_type": "code", "execution_count": 41, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "def plot_precision_vs_recall(precisions, recalls):\n", @@ -713,10 +552,7 @@ }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "# ROC curves" ] @@ -724,11 +560,7 @@ { "cell_type": "code", "execution_count": 42, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "from sklearn.metrics import roc_curve\n", @@ -739,11 +571,7 @@ { "cell_type": "code", "execution_count": 43, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "def plot_roc_curve(fpr, tpr, label=None):\n", @@ -762,11 +590,7 @@ { "cell_type": "code", "execution_count": 44, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "metadata": {}, "outputs": [], "source": [ "from sklearn.metrics import roc_auc_score\n", @@ -778,9 +602,7 @@ "cell_type": "code", "execution_count": 45, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -794,9 +616,7 @@ "cell_type": "code", "execution_count": 46, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -806,12 +626,8 @@ }, { "cell_type": "code", - "execution_count": 51, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 47, + "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(8, 6))\n", @@ -824,12 +640,8 @@ }, { "cell_type": "code", - "execution_count": 53, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 48, + "metadata": {}, "outputs": [], "source": [ "roc_auc_score(y_train_5, y_scores_forest)" @@ -837,12 +649,8 @@ }, { "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 49, + "metadata": {}, "outputs": [], "source": [ "y_train_pred_forest = cross_val_predict(forest_clf, X_train, y_train_5, cv=3)\n", @@ -851,12 +659,8 @@ }, { "cell_type": "code", - "execution_count": 55, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 50, + "metadata": {}, "outputs": [], "source": [ "recall_score(y_train_5, y_train_pred_forest)" @@ -864,22 +668,15 @@ }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "# Multiclass classification" ] }, { "cell_type": "code", - "execution_count": 56, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 51, + "metadata": {}, "outputs": [], "source": [ "sgd_clf.fit(X_train, y_train)\n", @@ -888,12 +685,8 @@ }, { "cell_type": "code", - "execution_count": 57, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 52, + "metadata": {}, "outputs": [], "source": [ "some_digit_scores = sgd_clf.decision_function([some_digit])\n", @@ -902,12 +695,8 @@ }, { "cell_type": "code", - "execution_count": 58, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 53, + "metadata": {}, "outputs": [], "source": [ "np.argmax(some_digit_scores)" @@ -915,12 +704,8 @@ }, { "cell_type": "code", - "execution_count": 59, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 54, + "metadata": {}, "outputs": [], "source": [ "sgd_clf.classes_" @@ -928,12 +713,8 @@ }, { "cell_type": "code", - "execution_count": 60, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 55, + "metadata": {}, "outputs": [], "source": [ "sgd_clf.classes_[5]" @@ -941,12 +722,8 @@ }, { "cell_type": "code", - "execution_count": 61, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 56, + "metadata": {}, "outputs": [], "source": [ "from sklearn.multiclass import OneVsOneClassifier\n", @@ -957,12 +734,8 @@ }, { "cell_type": "code", - "execution_count": 62, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 57, + "metadata": {}, "outputs": [], "source": [ "len(ovo_clf.estimators_)" @@ -970,12 +743,8 @@ }, { "cell_type": "code", - "execution_count": 63, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 58, + "metadata": {}, "outputs": [], "source": [ "forest_clf.fit(X_train, y_train)\n", @@ -984,12 +753,8 @@ }, { "cell_type": "code", - "execution_count": 64, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 59, + "metadata": {}, "outputs": [], "source": [ "forest_clf.predict_proba([some_digit])" @@ -997,12 +762,8 @@ }, { "cell_type": "code", - "execution_count": 65, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 60, + "metadata": {}, "outputs": [], "source": [ "cross_val_score(sgd_clf, X_train, y_train, cv=3, scoring=\"accuracy\")" @@ -1010,12 +771,8 @@ }, { "cell_type": "code", - "execution_count": 66, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 61, + "metadata": {}, "outputs": [], "source": [ "from sklearn.preprocessing import StandardScaler\n", @@ -1026,12 +783,8 @@ }, { "cell_type": "code", - "execution_count": 67, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 62, + "metadata": {}, "outputs": [], "source": [ "y_train_pred = cross_val_predict(sgd_clf, X_train_scaled, y_train, cv=3)\n", @@ -1041,12 +794,8 @@ }, { "cell_type": "code", - "execution_count": 68, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 63, + "metadata": {}, "outputs": [], "source": [ "def plot_confusion_matrix(matrix):\n", @@ -1059,12 +808,8 @@ }, { "cell_type": "code", - "execution_count": 69, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 64, + "metadata": {}, "outputs": [], "source": [ "plt.matshow(conf_mx, cmap=plt.cm.gray)\n", @@ -1074,12 +819,8 @@ }, { "cell_type": "code", - "execution_count": 70, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 65, + "metadata": {}, "outputs": [], "source": [ "row_sums = conf_mx.sum(axis=1, keepdims=True)\n", @@ -1088,12 +829,8 @@ }, { "cell_type": "code", - "execution_count": 71, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 66, + "metadata": {}, "outputs": [], "source": [ "np.fill_diagonal(norm_conf_mx, 0)\n", @@ -1104,12 +841,8 @@ }, { "cell_type": "code", - "execution_count": 72, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 67, + "metadata": {}, "outputs": [], "source": [ "cl_a, cl_b = 3, 5\n", @@ -1129,22 +862,15 @@ }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "# Multilabel classification" ] }, { "cell_type": "code", - "execution_count": 73, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 68, + "metadata": {}, "outputs": [], "source": [ "from sklearn.neighbors import KNeighborsClassifier\n", @@ -1159,12 +885,8 @@ }, { "cell_type": "code", - "execution_count": 74, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 69, + "metadata": {}, "outputs": [], "source": [ "knn_clf.predict([some_digit])" @@ -1172,36 +894,25 @@ }, { "cell_type": "code", - "execution_count": 77, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 70, + "metadata": {}, "outputs": [], "source": [ - "y_train_knn_pred = cross_val_predict(knn_clf, X_train, y_train, cv=3)\n", - "f1_score(y_train, y_train_knn_pred, average=\"macro\")" + "y_train_knn_pred = cross_val_predict(knn_clf, X_train, y_multilabel, cv=3)\n", + "f1_score(y_multilabel, y_train_knn_pred, average=\"macro\")" ] }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "# Multioutput classification" ] }, { "cell_type": "code", - "execution_count": 78, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 71, + "metadata": {}, "outputs": [], "source": [ "noise = np.random.randint(0, 100, (len(X_train), 784))\n", @@ -1214,12 +925,8 @@ }, { "cell_type": "code", - "execution_count": 79, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 72, + "metadata": {}, "outputs": [], "source": [ "some_index = 5500\n", @@ -1231,12 +938,8 @@ }, { "cell_type": "code", - "execution_count": 82, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 73, + "metadata": {}, "outputs": [], "source": [ "knn_clf.fit(X_train_mod, y_train_mod)\n", @@ -1247,32 +950,22 @@ }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "# Extra material" ] }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "## Dummy (ie. random) classifier" ] }, { "cell_type": "code", - "execution_count": 67, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 74, + "metadata": {}, "outputs": [], "source": [ "from sklearn.dummy import DummyClassifier\n", @@ -1283,11 +976,8 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 75, "metadata": { - "collapsed": false, - "deletable": true, - "editable": true, "scrolled": true }, "outputs": [], @@ -1298,22 +988,15 @@ }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "## KNN classifier" ] }, { "cell_type": "code", - "execution_count": 69, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 76, + "metadata": {}, "outputs": [], "source": [ "from sklearn.neighbors import KNeighborsClassifier\n", @@ -1323,12 +1006,8 @@ }, { "cell_type": "code", - "execution_count": 70, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 77, + "metadata": {}, "outputs": [], "source": [ "y_knn_pred = knn_clf.predict(X_test)" @@ -1336,12 +1015,8 @@ }, { "cell_type": "code", - "execution_count": 71, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 78, + "metadata": {}, "outputs": [], "source": [ "from sklearn.metrics import accuracy_score\n", @@ -1350,12 +1025,8 @@ }, { "cell_type": "code", - "execution_count": 72, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 79, + "metadata": {}, "outputs": [], "source": [ "from scipy.ndimage.interpolation import shift\n", @@ -1367,12 +1038,8 @@ }, { "cell_type": "code", - "execution_count": 73, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 80, + "metadata": {}, "outputs": [], "source": [ "X_train_expanded = [X_train]\n", @@ -1389,12 +1056,8 @@ }, { "cell_type": "code", - "execution_count": 74, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 81, + "metadata": {}, "outputs": [], "source": [ "knn_clf.fit(X_train_expanded, y_train_expanded)" @@ -1402,11 +1065,9 @@ }, { "cell_type": "code", - "execution_count": 75, + "execution_count": 82, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [ @@ -1415,12 +1076,8 @@ }, { "cell_type": "code", - "execution_count": 76, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 83, + "metadata": {}, "outputs": [], "source": [ "accuracy_score(y_test, y_knn_expanded_pred)" @@ -1428,12 +1085,8 @@ }, { "cell_type": "code", - "execution_count": 77, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 84, + "metadata": {}, "outputs": [], "source": [ "ambiguous_digit = X_test[2589]\n", @@ -1442,12 +1095,8 @@ }, { "cell_type": "code", - "execution_count": 78, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, + "execution_count": 85, + "metadata": {}, "outputs": [], "source": [ "plot_digit(ambiguous_digit)" @@ -1456,9 +1105,7 @@ { "cell_type": "markdown", "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "source": [ "# Exercise solutions" @@ -1466,10 +1113,7 @@ }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, + "metadata": {}, "source": [ "**Coming soon**" ] @@ -1478,9 +1122,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": true, - "deletable": true, - "editable": true + "collapsed": true }, "outputs": [], "source": [] @@ -1516,5 +1158,5 @@ } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 }