2022-12-29 17:27:20 +01:00
{
"cells": [
{
2023-01-12 16:00:39 +01:00
"attachments": {},
"cell_type": "markdown",
"metadata": {},
2022-12-29 17:27:20 +01:00
"source": [
2023-01-12 16:00:39 +01:00
"<span style=\"color:red\">Ajout d'étapes à la fin</span>"
2022-12-29 17:27:20 +01:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"# Recognizing hand-written digits\n",
"\n",
"This example shows how scikit-learn can be used to recognize images of\n",
"hand-written digits, from 0-9.\n"
]
},
{
"cell_type": "code",
2023-01-12 16:00:39 +01:00
"execution_count": 1,
2022-12-29 17:27:20 +01:00
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Author: Gael Varoquaux <gael dot varoquaux at normalesup dot org>\n",
"# License: BSD 3 clause\n",
"\n",
"# Standard scientific Python imports\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Import datasets, classifiers and performance metrics\n",
"from sklearn import datasets, svm, metrics\n",
"from sklearn.model_selection import train_test_split"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Digits dataset\n",
"\n",
"The digits dataset consists of 8x8\n",
"pixel images of digits. The ``images`` attribute of the dataset stores\n",
"8x8 arrays of grayscale values for each image. We will use these arrays to\n",
"visualize the first 4 images. The ``target`` attribute of the dataset stores\n",
"the digit each image represents and this is included in the title of the 4\n",
"plots below.\n",
"\n",
"Note: if we were working from image files (e.g., 'png' files), we would load\n",
"them using :func:`matplotlib.pyplot.imread`.\n",
"\n"
]
},
{
"cell_type": "code",
2023-01-12 16:00:39 +01:00
"execution_count": 2,
2022-12-29 17:27:20 +01:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
2023-01-12 16:00:39 +01:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjwAAACXCAYAAAARS4GeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXM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1T506NZXsEMvLy1NZF1q3tLTUO7u2tjZo7aeeeqp3dv/+/b2zi4uLvbP3339/7+zQtVt19OjRQfmFhYXe2c3Nzd7Zxx57rHf24MGDvbOT4gwPANA8hQcAaJ7CAwA0T+EBAJqn8AAAzVN4AIDmKTwAQPMUHgCgeQoPANA8hQcAaJ7CAwA0T+EBAJqn8AAAzVN4AIDmKTwAQPN2TOrAc3NzvbMnTpwYtPby8nLv7D333NM7u76+3jvL+M3MzAzKLy4u9s4+8sgjvbNra2u9s0tLS72zrZqfn++d3djYGLT2kPzKykrv7JD527VrV+9sMuzvTatmZ2cH5Q8dOjSmnVydgwcP9s6ePHlyjDsZD2d4AIDmKTwAQPMUHgCgeQoPANA8hQcAaJ7CAwA0T+EBAJqn8AAAzVN4AIDmKTwAQPMUHgCgeQoPANA8hQcAaJ7CAwA0r7qum/YeAAAmyhkeAKB5Cg8A0DyFBwBonsIDADRP4QEAmqfwAADN+z+hHt0iyNm/ygAAAABJRU5ErkJggg==",
2022-12-29 17:27:20 +01:00
"text/plain": [
2023-01-12 16:00:39 +01:00
"<Figure size 720x216 with 4 Axes>"
2022-12-29 17:27:20 +01:00
]
},
2023-01-12 16:00:39 +01:00
"metadata": {
"needs_background": "light"
},
2022-12-29 17:27:20 +01:00
"output_type": "display_data"
}
],
"source": [
"digits = datasets.load_digits()\n",
"\n",
"_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))\n",
"for ax, image, label in zip(axes, digits.images, digits.target):\n",
" ax.set_axis_off()\n",
" ax.imshow(image, cmap=plt.cm.gray_r, interpolation=\"nearest\")\n",
" ax.set_title(\"Training: %i\" % label)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Classification\n",
"\n",
"To apply a classifier on this data, we need to flatten the images, turning\n",
"each 2-D array of grayscale values from shape ``(8, 8)`` into shape\n",
"``(64,)``. Subsequently, the entire dataset will be of shape\n",
"``(n_samples, n_features)``, where ``n_samples`` is the number of images and\n",
"``n_features`` is the total number of pixels in each image.\n",
"\n",
"We can then split the data into train and test subsets and fit a support\n",
"vector classifier on the train samples. The fitted classifier can\n",
"subsequently be used to predict the value of the digit for the samples\n",
"in the test subset.\n",
"\n"
]
},
{
"cell_type": "code",
2023-01-12 16:00:39 +01:00
"execution_count": 3,
2022-12-29 17:27:20 +01:00
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# flatten the images\n",
"n_samples = len(digits.images)\n",
"data = digits.images.reshape((n_samples, -1))\n",
"\n",
"# Create a classifier: a support vector classifier\n",
"clf = svm.SVC(gamma=0.001)\n",
"\n",
"# Split data into 50% train and 50% test subsets\n",
"X_train, X_test, y_train, y_test = train_test_split(\n",
" data, digits.target, test_size=0.5, shuffle=False\n",
")\n",
"\n",
"# Learn the digits on the train subset\n",
"clf.fit(X_train, y_train)\n",
"\n",
"# Predict the value of the digit on the test subset\n",
"predicted = clf.predict(X_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Below we visualize the first 4 test samples and show their predicted\n",
"digit value in the title.\n",
"\n"
]
},
{
"cell_type": "code",
2023-01-12 16:00:39 +01:00
"execution_count": 4,
2022-12-29 17:27:20 +01:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
2023-01-12 16:00:39 +01:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjwAAACXCAYAAAARS4GeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAL5UlEQVR4nO3dX4xjZR3G8eeHw4KyOl2MUXZdpojBCAY6iiJR3Ak3JgiZBoKaqNnWhLiJ/8Ybw4W4TVj8d+NIEDBEqdEEkEg6xERjEKYRIYiy7YUxBOJ0ZBd3g0AnrhB18fXiHLSsM7Oz73tKZ37z/SSTzLR9znnb/vb0mdPuroUQBAAA4NlJo14AAADAsFF4AACAexQeAADgHoUHAAC4R+EBAADuU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AAAAPcoPAAAwD0KDwAAcI/CAwAA3KPwAAAA9yg8AADAvbFRL2AYut3uqJdwwvr9/qiXsC6VSqXo7O7du5P23Wg0kvKxxsfHo7NTU1PFLWQdGdUc9Hq96Kwklcvl6Gy73Y7OptznSqUSnfVsZmYmOlutVpP23el0orO1Wi06u7S0FJ2dmJiIzg4LZ3gAAIB7FB4AAOAehQcAALhH4QEAAO5ReAAAgHsUHgAA4B6FBwAAuEfhAQAA7lF4AACAexQeAADgHoUHAAC4R+EBAADuUXgAAIB7FB4AAOAehQcAALhnIYTVrl/1yvWqWq1GZ3u9XnS2VCpFZ1utVnQ2dd+SLGnnxzeSOep0Okn5lDlaXFyMzt5+++3R2VqtFp0twDDnaEMei5rNZnS2Xq9HZxcWFqKz5XI5OlsAl8eiVJVKJTrb7Xajs3v37o3ONhqN6GwBlp0jzvAAAAD3K
2022-12-29 17:27:20 +01:00
"text/plain": [
2023-01-12 16:00:39 +01:00
"<Figure size 720x216 with 4 Axes>"
2022-12-29 17:27:20 +01:00
]
},
2023-01-12 16:00:39 +01:00
"metadata": {
"needs_background": "light"
},
2022-12-29 17:27:20 +01:00
"output_type": "display_data"
}
],
"source": [
"_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))\n",
"for ax, image, prediction in zip(axes, X_test, predicted):\n",
" ax.set_axis_off()\n",
" image = image.reshape(8, 8)\n",
" ax.imshow(image, cmap=plt.cm.gray_r, interpolation=\"nearest\")\n",
" ax.set_title(f\"Prediction: {prediction}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
":func:`~sklearn.metrics.classification_report` builds a text report showing\n",
"the main classification metrics.\n",
"\n"
]
},
{
"cell_type": "code",
2023-01-12 16:00:39 +01:00
"execution_count": 5,
2022-12-29 17:27:20 +01:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Classification report for classifier SVC(gamma=0.001):\n",
" precision recall f1-score support\n",
"\n",
" 0 1.00 0.99 0.99 88\n",
" 1 0.99 0.97 0.98 91\n",
" 2 0.99 0.99 0.99 86\n",
" 3 0.98 0.87 0.92 91\n",
" 4 0.99 0.96 0.97 92\n",
" 5 0.95 0.97 0.96 91\n",
" 6 0.99 0.99 0.99 91\n",
" 7 0.96 0.99 0.97 89\n",
" 8 0.94 1.00 0.97 88\n",
" 9 0.93 0.98 0.95 92\n",
"\n",
" accuracy 0.97 899\n",
" macro avg 0.97 0.97 0.97 899\n",
"weighted avg 0.97 0.97 0.97 899\n",
"\n",
"\n"
]
}
],
"source": [
"print(\n",
" f\"Classification report for classifier {clf}:\\n\"\n",
" f\"{metrics.classification_report(y_test, predicted)}\\n\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also plot a `confusion matrix <confusion_matrix>` of the\n",
"true digit values and the predicted digit values.\n",
"\n"
]
},
{
"cell_type": "code",
2023-01-12 16:00:39 +01:00
"execution_count": 6,
2022-12-29 17:27:20 +01:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Confusion matrix:\n",
"[[87 0 0 0 1 0 0 0 0 0]\n",
" [ 0 88 1 0 0 0 0 0 1 1]\n",
" [ 0 0 85 1 0 0 0 0 0 0]\n",
" [ 0 0 0 79 0 3 0 4 5 0]\n",
" [ 0 0 0 0 88 0 0 0 0 4]\n",
" [ 0 0 0 0 0 88 1 0 0 2]\n",
" [ 0 1 0 0 0 0 90 0 0 0]\n",
" [ 0 0 0 0 0 1 0 88 0 0]\n",
" [ 0 0 0 0 0 0 0 0 88 0]\n",
" [ 0 0 0 1 0 1 0 0 0 90]]\n"
]
},
{
"data": {
2023-01-12 16:00:39 +01:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAATIAAAEjCAYAAACxTI37AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEA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PUHfPgWk4YUk5BYTVPz17M38aWMG1i6hv47d66pxuEdPa2giAa4SNSEbkAeADIBh5X1XvitR/Qv4Va9YuIsOoXBl71i926I6UsdNwJLXTiqx0DtT2h+8a5jVW/CJNIF8Sq6lRgapTfYRhGelGgSpt9ev0gnFjZbxhG5qAINc3/nPAgLJEZhpE0tZpZc2SWyAzDSApv07glMsMwnEaoybA5ssyKxjCMjMerEJsV6EiEiPzI97RcIiITRKSViPQUkVl+sYnnRKRFIp2M6pGtWdQ2kqUSUzZ8ELomwDe7R7CsI6rlDLZMIjqiWtoSBSH8GagKlZr67ywiXYAfAv1UdZ+ITMJbb3oB8HtVnSgijwBXAX+Op2U9MsMwkqYWCXQEIAdoLSI5QB6wGTgbmOxfd8/X0jCMzMeb7E+9D6SqG0XkfuBjPF/L6cBcoMw37IVGik3Ux3pkhmEkiTfZH+QAiuuq2/jHNZ+piLTHK+3VE+gMtAFGNCUi65EZhpEUdZP9AdkeZ4vScGCtqm4DEJEXgNOBdiKS4/fKAhWbsB6ZYRhJU6MS6EjAx8BgEckTEcFzTvoQeAv4lt/GfC0NwwgfRajS1FOHqs4SkcnAPKAamA+MA14FJorI3f65xxJpOZfIwnSNeXn8kbw5oSMi0L1vBaPHrmb5nHyeuvsotBZatalh9O9WU9LzQJP0o3Imc
2022-12-29 17:27:20 +01:00
"text/plain": [
2023-01-12 16:00:39 +01:00
"<Figure size 432x288 with 2 Axes>"
2022-12-29 17:27:20 +01:00
]
},
2023-01-12 16:00:39 +01:00
"metadata": {
"needs_background": "light"
},
2022-12-29 17:27:20 +01:00
"output_type": "display_data"
}
],
"source": [
"disp = metrics.ConfusionMatrixDisplay.from_predictions(y_test, predicted)\n",
"disp.figure_.suptitle(\"Confusion Matrix\")\n",
"print(f\"Confusion matrix:\\n{disp.confusion_matrix}\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If the results from evaluating a classifier are stored in the form of a\n",
"`confusion matrix <confusion_matrix>` and not in terms of `y_true` and\n",
"`y_pred`, one can still build a :func:`~sklearn.metrics.classification_report`\n",
"as follows:\n",
"\n"
]
},
{
"cell_type": "code",
2023-01-12 16:00:39 +01:00
"execution_count": 7,
2022-12-29 17:27:20 +01:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Classification report rebuilt from confusion matrix:\n",
" precision recall f1-score support\n",
"\n",
" 0 1.00 0.99 0.99 88\n",
" 1 0.99 0.97 0.98 91\n",
" 2 0.99 0.99 0.99 86\n",
" 3 0.98 0.87 0.92 91\n",
" 4 0.99 0.96 0.97 92\n",
" 5 0.95 0.97 0.96 91\n",
" 6 0.99 0.99 0.99 91\n",
" 7 0.96 0.99 0.97 89\n",
" 8 0.94 1.00 0.97 88\n",
" 9 0.93 0.98 0.95 92\n",
"\n",
" accuracy 0.97 899\n",
" macro avg 0.97 0.97 0.97 899\n",
"weighted avg 0.97 0.97 0.97 899\n",
"\n",
"\n"
]
}
],
"source": [
"# The ground truth and predicted lists\n",
"y_true = []\n",
"y_pred = []\n",
"cm = disp.confusion_matrix\n",
"\n",
"# For each cell in the confusion matrix, add the corresponding ground truths\n",
"# and predictions to the lists\n",
"for gt in range(len(cm)):\n",
" for pred in range(len(cm)):\n",
" y_true += [gt] * cm[gt][pred]\n",
" y_pred += [pred] * cm[gt][pred]\n",
"\n",
"print(\n",
" \"Classification report rebuilt from confusion matrix:\\n\"\n",
" f\"{metrics.classification_report(y_true, y_pred)}\\n\"\n",
")"
]
2023-01-12 16:00:39 +01:00
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Ajout d'étapes \n",
"On souhaite, à partir de l'exemple précédent, ajouter des étapes dans un problème de machine learning. \n",
"- Choix du bon model (recherche de noyau, et valeur de C)\n",
"- Interprétation"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import GridSearchCV"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'C': 4, 'coef0': 0, 'degree': 1, 'kernel': 'rbf'}\n",
"Confusion matrix:\n",
"[[87 0 0 0 1 0 0 0 0 0]\n",
" [ 0 87 1 0 0 0 0 0 2 1]\n",
" [ 0 0 85 1 0 0 0 0 0 0]\n",
" [ 0 0 0 82 0 3 0 2 4 0]\n",
" [ 0 0 0 0 88 0 0 0 0 4]\n",
" [ 0 0 0 0 0 87 1 0 0 3]\n",
" [ 0 1 0 0 0 0 90 0 0 0]\n",
" [ 0 0 0 0 0 1 0 88 0 0]\n",
" [ 0 0 0 0 0 0 0 0 88 0]\n",
" [ 0 0 0 1 0 1 0 0 0 90]]\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAATIAAAEjCAYAAACxTI37AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAA1PklEQVR4nO2deXwV5fX/3ycLewgkAQyrKAhFyyYquFBUVLCt2k3r1uXnWrXVUtti7bdWq61Waa11q7hXBVGwbggo1SqoyI4gIMgi+5IQCCSQ7fz+mIleYrh3bu7MzQyc9+s1r9w7M/czJ8Pl5HmeeZ7zEVXFMAwjymQ0dgCGYRipYonMMIzIY4nMMIzIY4nMMIzIY4nMMIzIY4nMMIzIY4nsIEZEmovIqyKyU0ReSEHnYhGZ5mdsjYGIvCEiP27sOAz/sUQWAkTkIhGZIyK7RWST+x/uZB+kvw90APJV9QcNFVHVZ1X1TB/i2Q8RGSYiKiIv1dnfz93/jkedP4rIM4nOU9WRqvpUA8M1QowlskZGREYB9wJ/xkk6XYEHgXN9kO8GfKqqVT5oBcU2YIiI5Mfs+zHwqV8XEAf7rh/MqKptjbQBucBu4AdxzmmKk+g2utu9QFP32DBgPfArYCuwCfipe+xWoAKodK9xGfBH4JkY7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F05aAz4HBItJCRATHOekT4G3g++455mtpGIb/KEKlpp46VHWWiLwIzAOqgPnAI8DrwHgRud3d91gircglMj9dY4J2ZwrKmShqjjyHuotSQeE+fj1mFW0KKkGFyePa8fKTh6WsG6TzVTz8GuwHU
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"digits = datasets.load_digits()\n",
"\n",
"# Flattening des données\n",
"n_samples = len(digits.images)\n",
"data = digits.images.reshape((n_samples, -1))\n",
"\n",
"# SVM classifier\n",
"classifier = svm.SVC(gamma=0.001)\n",
"\n",
"# Recherche des meilleurs paramètres\n",
"parameters = {'kernel':('linear','poly', 'rbf', 'sigmoid'), 'C':[0.1, 0.5, 1, 3, 4, 5, 10], 'degree':[1,2,3,5], 'coef0':[0, 0.1, 0.5, 1, 10]}\n",
"classifier = GridSearchCV(classifier, parameters)\n",
"\n",
"# Split data\n",
"X_train, X_test, y_train, y_test = train_test_split(\n",
" data, digits.target, test_size=0.5, shuffle=False\n",
")\n",
"\n",
"classifier.fit(X_train, y_train)\n",
"print(classifier.best_params_)\n",
"\n",
"predicted = classifier.predict(X_test)\n",
"\n",
"disp = metrics.ConfusionMatrixDisplay.from_predictions(y_test, predicted)\n",
"disp.figure_.suptitle(\"Confusion Matrix\")\n",
"print(f\"Confusion matrix:\\n{disp.confusion_matrix}\")\n",
"\n",
"plt.show()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"On peut comprendre pourquoi le kernel n'est pas de type linéaire, polynomial ou sigmoid, il est donc de kernel rbf (gaussien). Le coefficient C est de 4, permettant de ne pas trop rigide avec la classification (0 -> rigide, +inf -> flexible)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Row 32 has been classified as 9 and should be 5\n",
"Row 53 has been classified as 9 and should be 5\n",
"Row 120 has been classified as 9 and should be 5\n",
"Row 197 has been classified as 9 and should be 4\n",
"Row 215 has been classified as 5 and should be 7\n",
"Row 220 has been classified as 7 and should be 3\n",
"Row 280 has been classified as 8 and should be 1\n",
"Row 344 has been classified as 2 and should be 1\n",
"Row 366 has been classified as 8 and should be 1\n",
"Row 390 has been classified as 9 and should be 1\n",
"Row 463 has been classified as 6 and should be 5\n",
"Row 466 has been classified as 3 and should be 2\n",
"Row 653 has been classified as 1 and should be 6\n",
"Row 675 has been classified as 4 and should be 0\n",
"Row 704 has been classified as 8 and should be 3\n",
"Row 707 has been classified as 7 and should be 3\n",
"Row 713 has been classified as 9 and should be 4\n",
"Row 730 has been classified as 9 and should be 4\n",
"Row 760 has been classified as 3 and should be 9\n",
"Row 762 has been classified as 9 and should be 4\n",
"Row 764 has been classified as 5 and should be 9\n",
"Row 792 has been classified as 5 and should be 3\n",
"Row 828 has been classified as 8 and should be 3\n",
"Row 829 has been classified as 8 and should be 3\n",
"Row 831 has been classified as 5 and should be 3\n",
"Row 832 has been classified as 8 and should be 3\n",
"Row 867 has been classified as 5 and should be 3\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPUAAAEICAYAAACHyrIWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAQFUlEQVR4nO3dfZBddX3H8feHhFgwkWRIVJLQLE+mEGYINBOHghBAFCpC6uiUFKxBGJyqlNV2KFDqpDOdWjsdJB06MJaHYElBRRgpJSBPGaWVhzxZIQka4sZsCCQRaUJiiQnf/nHOjpedXfbch3Pu2R+f18ydvfeec8/ve+7uZ3/n/Pbu+SkiMLN0HNDtAsyssxxqs8Q41GaJcajNEuNQmyXGoTZLjENtHSVpuaTL8vsXSfp+i9tZJukzna3uneEdFWpJrzfc3pT064bHF1VUwzxJ/U2+ZpGk3wyq/8g2aghJu/PtbJF0vaQxrW5vO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ZvVQZIaO84BtEbHy7dbzXFpm9VCkpz4FOF9SH3A3cKakO0utysxaNmKoI+KaiJgeET3AhcDjEXFx6ZWZWUv8d2qzxDR1OaOIWA4sL6USM+sI99RmiXGozRLjUJslxqE2S4xDbZYYh9osMQ61WWI87U4TqpwuJmWLFi1Ksi3wtDtmVgKH2iwxDrVZYhxqs8Q41GaJcajNEuNQmyXGoTZLjENtlhiH2iwxhT4mml9JdBewH9gXEXPKLMrMWtfMZ7/PiIgdpVViZh3hw2+zxBQNdQDfl7RS0uVDreBpd8zqoWioT42Ik4BzgS9IOm3wCp52x
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPUAAAEICAYAAACHyrIWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAQSklEQVR4nO3df5BdZX3H8feHQCyYmDAkKkloll+mEJgkNBOHBmkA0aQiiKPTpGABYXCqUqLtUKBU0plOrR0HpUMHxobQWFJQkURKCcivjNLKjyQsFbJBQ9zIhkAScUt+WGLg2z/O2fFm3WXP3nvPuXcfPq+ZO3vvPeee53vu7mefc569ex5FBGaWjoNaXYCZNZdDbZYYh9osMQ61WWIcarPEONRmiXGorakkrZF0WX7/Aknfr3M7qyVd1Nzq3h7eVqGWtLvm9qakX9U8vqCiGuZJ6hnma5ZI+nW/+o9poIaQtCffzlZJN0gaVe/2BhMRKyLiQwXqWSLp9n6vXRARy5td0wBtj5e0XNL2/Lak7DbLdnCrC6hSRIzpuy+pG7gsIh4azjYkHRwR+5tdWwHfiogLm7i9GRGxSdLvAWuAnwC31K7Qwn2t0teAw4AO4N3Aw5K2RMRtLa2qAW+rnnowkuZI+pGkXknbJN0kaXTN8pD0OUk/BX6aP3dVvu5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zxDjUZolxqM0S41CbJcahNkvMiJ92p0pVThdTtfHjx1fW1uLFiytra9WqVZW1BZ52x8xK4FCbJcahNkuMQ22WGIfaLDEOtVliHGqzxDjUZolxqM0S41CbJabQx0TzK4nuAt4A9kfE7DKLMrP6Deez32dExM7SKjGzp
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPUAAAEICAYAAACHyrIWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAQHElEQVR4nO3dfYwc9X3H8fcHAynEDoewk+CHcjzFBSPZUMsRNaEGQmIaAm6UqHYhjQmIqEkokFYUKI2oVDVNVRGIqEApYEhxIQkBJ6UYwpOV0IYH2xwN2CYxzhEOjB9CrhiTQmy+/WPmlOV0x83uzszu/fx5Savb3Zmd33fm7rO/mdm9+SkiMLN07NXpAsysXA61WWIcarPEONRmiXGozRLjUJslxqG2UklaJem8/P5Zkn7Q4nJWSvpMudXtGfaoUEt6reH2lqRfNzw+q6YaFkgaaPI1V0r6zbD6D2ujhpC0M1/Oi5KukjSh1eWNJiKWR8RHCtRzpaRbh732tIi4peyaRmi7R9ItkrbmtyurbrNqe3e6gDpFxMSh+5L6gfMi4oFmliFp74jYVXZtBXwrIs4ucXmzI2KjpN8DVgE/Ba5vnKGD61qnrwH7A73Ae4EHJT0fEcs6WlUb9qieejSS5kn6saRBSZslXStp34bpIekLkn4G/Cx/7pJ83pcknZfPc0Q+7V2S/lnSLyRtkXS9pP0kvRtYCUxt6HGndmSlcxGxAfgRcIyk3nw9zpX0C+AhAEmflbRe0q8k3SfpkKHXSzpV0gZJ/yvpWkAN05ZKeqTh8SxJ90t6Jd8ul0taCFwO/Em+PZ7K523cjd9L0hWSns97029KOiCfN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u4trMrAVFht3ZHBFr8/s7gPXAtKoLM7PWNHVMLakXOBZ4bIRpHnbHrAsUDrWkicB3gYsi4tXh0z3sjll3KBRqSfuQBXp5RNxZbUlm1o4iZ78F3Aisj4irqi/JzNpRpKeeD3waOFlSX377o4rrMrMWFRl25xFANdRiZiXwN8rMEuNQmyXGoTZLjENtlhiH2iwxDrVZYhxqs8Q41GaJGfdjafX19dXW1lNPPVVbW1DvutVpwYIFtbVV9zbs6emptb2RuKc2S4xDbZYYh9osMQ61WWIcarPEONRmiXGozRLjUJslxqE2S0yRCw/+jqTHJT2VD7vzd3UUZmatKfI10TeAkyPitfxSwY9IWhkRj1Zcm5m1oMiFBwN4LX+4T36LKosys9YVvZj/BEl9wFbg/ojwsDtmXapQqCNid0TMAaYD8yQdM8I8HnbHrAs0dfY7IgaBh4GFlVRjZm0rcvZ7iqSe/P5+wKnAhorrMrMWFTn7fTBwi6QJZG8C346Iu6sty8xaVeTs9/+QjUltZuOAv1FmlhiH2iwxDrVZYhxqs8Q41GaJcajNEuNQmyXGoTZLzLgfdmfRokVJtgXQ29tba3t1Wbp0aW1trVixora2oN51G417arPEONRmiXGozRLjUJslxqE2S4xDbZYYh9osMQ61WWIcarPEONRmiSkc6vyC/k9K8kUHzbpYMz31hcD6qgoxs3IUHXZnOvAx4IZqyzGzdhXtqa8GLgHeGm0Gj6Vl1h2KjNBxOrA1Ita803weS8usOxTpqecDZ0jqB24HTpZ0a6VVmVnLxgx1RFwWEdMjohdYDDwUEWdXXpmZtcSfU5slpqnLGUXEKmBVJZWYWSncU5slxqE2S4xDbZYYh9osMQ61WWIcarPEONRmiRn3w+6kOjRNyur8nfX399fWVrdwT22WGIfaLDEOtVliHGqzxDjUZolxqM0S41CbJcahNkuMQ22WGIfaLDGFviaaX0l0B7Ab2BURc6ssysxa18x3v0+KiO2VVWJmpfDut1liioY6gB9IWiPp/JFm8LA7Zt2ha
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background":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eBUSd355ZMV12VmTSoy7c7DgGqoxcxK4G+UmSXGoTZLjENtlhiH2iwxDrVZYhxqs8Q41GaJcajNEjPi59JK2TnnnFNbXzt27Kitr02bNtXWV51zrXUKj9RmiXGozRLjUJslxqE2S4xDbZYYh9osMQ61WWIcarPEONRmiSly4sHfkPSYpJ/l0+78ZR2FmVlzinxN9A3g1Ih4PT9V8MOSlkfEIxXXZmZNKHLiwQBez2/un1+iyqLMrHlFT+Y/SlI3sBW4LyI87Y5ZhyoU6oh4MyJmAVOB4yQdPUAbT7tj1gGGdfQ7InYAK4AzKqnGzFpW5Oj3BEnj8usHAqcD6yuuy8yaVOTo9yTgFkmjyN4EvhcRd1Vblpk1q8jR7/8mm5PazEYAf6PMLDEOtVliHGqzxDjUZolxqM0S41CbJcahNkuMQ22WmBE/7c7ChQvbXUJl6pwKZ/HixbX1NXPmzNr6mjt3bm19dQqP1GaJcajNEuNQmyXGoTZLjENtlhiH2iwxDrVZYhxqs8Q41GaJcajNElM41PkJ/ddK8kkHzTrYcEbqS4F1VRViZuUoOu3OVOBTwI3VlmNmrSo6Ul8LXA68NVgDz6Vl1hmKzNBxFrA1Ila/WzvPpWXWGYqM1CcAZ0vqAW4DTpW0pNKqzKxpQ4Y6Iq6MiKkR0QWcCzwQEedXXpmZNcV/pzZLzLBOZxQRK4GVlVRiZqXwSG2WGIfaLDEOtVliHGqzxDjUZolxqM0S41CbJWbET7tTp7qn+Kmzv507d9bW17Jly2rra1/kkdosMQ61WWIcarPEONRmiXGozRLjUJslxqE2S4xDbZYYh9osMQ61WWIKfU00P5Poa8CbwN6ImF1lUWbWv
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPUAAAEICAYAAACHyrIWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bG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6JiO9XXJuZtaDIwIMB7MyfHpz/RJVFmVnrig7mP07SGmAL8N2I8LQ7Zl2qUKgj4rWImAVMA+ZIeusw63jaHbMu0NTd74jYBtwPnFlJNWbWtiJ3v4+WNDl/fBjwLuCpiusysxYVuft9DPANSePI/gjcEhF3VVuWmbWqyN3vH5LNSW1mY4C/UWaWGIfaLDEOtVliHGqzxDjUZolxqM0S41CbJcahNkvMmJ92Z/ny5bW1dcUVV9TWFsD27dtra2vFihW1tVXntDtLly6trS2Anp6eWtsbjntqs8Q41GaJcajNEuNQmyXGoTZLjENtlhiH2iwxDrVZYhxqs8Q41GaJKRzqfED/1ZI86KBZF2ump14MrKuqEDMrR9Fpd6YBZwPXVluOmbWraE99FXAJ8PpIK3guLbPuUGSGjnOALRGxcn/reS4ts+5QpKc+DThPUj9wMzBP0jcrrcrMWjZqqCPisoiYFhE9wPnAfRHxgcorM7OW+HNqs8Q0NZxRRKwAVlRSiZmVwj21WWIcarPEONRmiXGozRLjUJslxqE2S4xDbZaYMT/tzurVq2trq7+/v7a2ACZNmlRbW90wXYyVwz21WWIcarPEONRmiXGozRLjUJslxqE2S4xDbZYYh9osMQ61WWIcarPEFPqaaD6S6A7gNWBvRPRWWZSZta6Z737/XkS8VFklZlYKn36bJ
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"count = 0\n",
"for row_index, (input, prediction, label) in enumerate(zip (X_test, predicted, y_test)):\n",
" if prediction != label:\n",
" print('Row', row_index, 'has been classified as ', prediction, 'and should be ', label)\n",
" count = count +1\n",
" if count <= 5:\n",
" plt.figure()\n",
" input = input.reshape(8, 8)\n",
" plt.imshow(input, cmap=plt.cm.gray_r, interpolation=\"nearest\")\n",
" plt.title(f\"Target: {label} - Prediction: {prediction}\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"On peut observer que le modèle reste affecté par des niveaux de gris reliés entre eux.\n",
"\n",
"## Conclusion\n",
"Grace à ce TP, nous avons pu découvrir les méthodes de classification avec noyaux et la manière d'optimiser les paramètres du modèle avec la fonction `GridSearchCV`"
]
2022-12-29 17:27:20 +01:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2023-01-12 16:00:39 +01:00
"version": "3.9.4"
2022-12-29 17:27:20 +01:00
},
"vscode": {
"interpreter": {
2023-01-12 16:00:39 +01:00
"hash": "2ef431f6525756fa8a44688585fa332ef3b2e5fcfe8fe75df35bbf7028a8b511"
2022-12-29 17:27:20 +01:00
}
}
},
"nbformat": 4,
"nbformat_minor": 0
}