problem.ipynb 14.5 KB
Newer Older
Mathilde Rineau's avatar
Mathilde Rineau committed
1
2
3
4
5
6
7
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5c8980bd",
   "metadata": {},
   "source": [
Rémy Huet's avatar
Rémy Huet committed
8
9
    "# AOS1 - Assignment\n",
    "## Improving the accuracy and speed of support vector machines\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
10
    "\n",
Rémy Huet's avatar
Rémy Huet committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    "Authors : Mathilde Rineau, Rémy Huet\n",
    "\n",
    "### Abstract\n",
    "\n",
    "The paper \"Improving the Accuracy and Speed of Support Vector Machines\" by Burges and Schölkopf is investigating a method to improve ht speed an accuracy of a support vector machine.\n",
    "\n",
    "As the authors say, SVM are wildly used for several applications.\n",
    "To improve this method, the authors make the difference between two types of improvements to achieve :\n",
    "- improving the generalization performance;\n",
    "- improving the speed in test phase.\n",
    "\n",
    "The authors propose and combine two methods to improve SVM performances : the \"virtual support vector\" method and the \"reduced set\" method.\n",
    "With those two improvements, they announce a machine much faster (22 times than the original one) and more precise (1.1% vs 1.4% error) than the original one.\n",
    "\n",
    "In this work, we will describe and program the two techniques they are used to see if these method are working as they say."
Mathilde Rineau's avatar
Mathilde Rineau committed
26
27
   ]
  },
Rémy Huet's avatar
Rémy Huet committed
28
29
  {
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
30
   "id": "12aaeba6",
Rémy Huet's avatar
Rémy Huet committed
31
32
33
34
35
   "metadata": {},
   "source": [
    "### First part : tests with a vanilla SVM\n",
    "\n",
    "In this first part, we will use a vanilla SVM on the MINST dataset with the provided params.\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
36
    "We will observe the error of the SVM and the time for the test phase to compare them with the improved version"
Rémy Huet's avatar
Rémy Huet committed
37
38
   ]
  },
Mathilde Rineau's avatar
Mathilde Rineau committed
39
40
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
41
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
42
43
   "id": "9f152334",
   "metadata": {},
Rémy Huet's avatar
Rémy Huet committed
44
   "outputs": [],
Mathilde Rineau's avatar
Mathilde Rineau committed
45
   "source": [
Rémy Huet's avatar
Rémy Huet committed
46
47
    "# We will work on the mnist data set\n",
    "# We load it from fetch_openml\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
48
49
50
    "from sklearn.datasets import fetch_openml\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
Rémy Huet's avatar
Rémy Huet committed
51
    "import numpy as np\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
52
    "\n",
Rémy Huet's avatar
Rémy Huet committed
53
54
55
56
57
    "X, y = fetch_openml('mnist_784', version=1, return_X_y=True, as_frame=False)"
   ]
  },
  {
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
58
   "id": "855cdb06",
Rémy Huet's avatar
Rémy Huet committed
59
60
61
62
63
64
65
   "metadata": {},
   "source": [
    "We do some inspection on the dataset :"
   ]
  },
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
66
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
67
   "id": "708c8ea1",
Rémy Huet's avatar
Rémy Huet committed
68
   "metadata": {},
Mathilde Rineau's avatar
Mathilde Rineau committed
69
   "outputs": [],
Rémy Huet's avatar
Rémy Huet committed
70
71
   "source": [
    "# We print the caracteristics of X and Y\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
72
    "print(X.shape)\n",
Rémy Huet's avatar
Rémy Huet committed
73
74
75
76
77
78
79
80
81
82
    "print(y.shape)\n",
    "# Values taken by y\n",
    "print(np.unique(y))\n",
    "\n",
    "image = np.reshape(X[0], (28, 28))\n",
    "plt.imshow(image, cmap='gray')"
   ]
  },
  {
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
83
   "id": "4e49be54",
Rémy Huet's avatar
Rémy Huet committed
84
85
86
87
88
89
90
91
92
93
94
95
   "metadata": {},
   "source": [
    "The dataset contains 70k samples of 784 features.\n",
    "The classes are 0 to 9 (the digits on the images).\n",
    "\n",
    "The features are the pixels of a 28 x 28 image that we can retrieve using numpy's reshape function.\n",
    "\n",
    "For example, the 1st image is a 5."
   ]
  },
  {
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
96
   "id": "60f31892",
Rémy Huet's avatar
Rémy Huet committed
97
98
99
100
101
102
   "metadata": {},
   "source": [
    "With our dataset, we can generate a training dataset and a testing dataset.\n",
    "As in the article, we will use 60k samples as training samples and 10k as testing.\n",
    "\n",
    "We split the dataset using the `train_test_split` function from `sklearn`."
Mathilde Rineau's avatar
Mathilde Rineau committed
103
104
105
106
   ]
  },
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
107
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
108
109
110
111
   "id": "4d3fa1c7",
   "metadata": {},
   "outputs": [],
   "source": [
Rémy Huet's avatar
Rémy Huet committed
112
113
    "# We divide the data set in two parts: train set and test set\n",
    "# According to the recommended values the train set's size is 60000 and the test set's size is 10000\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
114
115
116
117
118
    "from sklearn.model_selection import train_test_split\n",
    "X_train, X_test, y_train, y_test = train_test_split(\n",
    "    X, y, train_size=60000, test_size=10000)"
   ]
  },
Rémy Huet's avatar
Rémy Huet committed
119
120
  {
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
121
   "id": "d0532cc1",
Rémy Huet's avatar
Rémy Huet committed
122
123
124
125
126
127
128
129
130
   "metadata": {},
   "source": [
    "From the article, we retrieve the parameters of the SVM used.\n",
    "We get C = 10, and a polynomial kernel of degree 5.\n",
    "Coefficients `gamma` and `coef0` are respectively equals to 1 and 0.\n",
    "\n",
    "We can now train a SVM with these params on the training dataset."
   ]
  },
Mathilde Rineau's avatar
Mathilde Rineau committed
131
132
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
133
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
134
135
   "id": "d809fc87",
   "metadata": {},
Mathilde Rineau's avatar
Mathilde Rineau committed
136
   "outputs": [],
Mathilde Rineau's avatar
Mathilde Rineau committed
137
   "source": [
Rémy Huet's avatar
Rémy Huet committed
138
    "# First, we perform a SVC without preprocessing or improving in terms of accuracy or speed\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
139
    "from sklearn.svm import SVC\n",
Rémy Huet's avatar
Rémy Huet committed
140
141
142
    "# we perform the default SVC, with the hyperparameter C=10 and a polynomial kernel of degree 5\n",
    "# according to the recommandations\n",
    "svc = SVC(C=10, kernel = 'poly', degree = 5, gamma=1, coef0=0)\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
143
144
145
    "svc.fit(X_train, y_train)"
   ]
  },
Rémy Huet's avatar
Rémy Huet committed
146
147
  {
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
148
   "id": "a8cf4850",
Rémy Huet's avatar
Rémy Huet committed
149
150
151
152
153
154
155
156
   "metadata": {},
   "source": [
    "Using the previously trained SVM, we make a prediction on the test dataset.\n",
    "\n",
    "One of the measured performance of the SVM in this article is the speed of the test phase.\n",
    "We thus measure it."
   ]
  },
Mathilde Rineau's avatar
Mathilde Rineau committed
157
158
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
159
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
160
161
   "id": "8cb28178",
   "metadata": {},
Mathilde Rineau's avatar
Mathilde Rineau committed
162
   "outputs": [],
Mathilde Rineau's avatar
Mathilde Rineau committed
163
   "source": [
Rémy Huet's avatar
Rémy Huet committed
164
165
166
167
168
169
170
171
172
173
174
175
176
177
    "import time\n",
    "\n",
    "start = time.time()\n",
    "# We predict the values for our test set\n",
    "y_pred = svc.predict(X_test)\n",
    "end = time.time()\n",
    "\n",
    "# We predict 10 times to have a mean elapsed time\n",
    "\n",
    "print(f'Elapsed time : {end - start}')"
   ]
  },
  {
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
178
   "id": "90f08e8b",
Rémy Huet's avatar
Rémy Huet committed
179
180
181
182
183
   "metadata": {},
   "source": [
    "Of course the prediction time varies between two splits of the dataset and two executions, but we will retain that is is close from 70s.\n",
    "\n",
    "Using `y_test` the real classes of the `X_test` samples and `y_pred` the predicted classes from the SVM, we can compute the confusion matrix and the error to see the how good the predictions are."
Mathilde Rineau's avatar
Mathilde Rineau committed
184
185
186
187
   ]
  },
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
188
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
189
190
   "id": "c1248238",
   "metadata": {},
Mathilde Rineau's avatar
Mathilde Rineau committed
191
   "outputs": [],
Mathilde Rineau's avatar
Mathilde Rineau committed
192
   "source": [
Rémy Huet's avatar
Rémy Huet committed
193
194
195
196
197
198
    "# We compute the confusion matrix\n",
    "from sklearn.metrics import ConfusionMatrixDisplay, classification_report, accuracy_score\n",
    "\n",
    "disp = ConfusionMatrixDisplay.from_predictions(y_test, y_pred)\n",
    "disp.figure_.suptitle('Confusion matrix for the vanilla SVM')\n",
    "plt.show()"
Mathilde Rineau's avatar
Mathilde Rineau committed
199
200
201
202
   ]
  },
  {
   "cell_type": "code",
Rémy Huet's avatar
Rémy Huet committed
203
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
204
205
   "id": "ba4e38ac",
   "metadata": {},
Rémy Huet's avatar
Rémy Huet committed
206
   "outputs": [],
Mathilde Rineau's avatar
Mathilde Rineau committed
207
   "source": [
Rémy Huet's avatar
Rémy Huet committed
208
    "# We print the classification report\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
209
210
211
212
213
    "print(classification_report(y_test, y_pred))"
   ]
  },
  {
   "cell_type": "code",
Rémy Huet's avatar
Rémy Huet committed
214
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
215
216
   "id": "947b0895",
   "metadata": {},
Rémy Huet's avatar
Rémy Huet committed
217
   "outputs": [],
Mathilde Rineau's avatar
Mathilde Rineau committed
218
   "source": [
Rémy Huet's avatar
Rémy Huet committed
219
220
221
222
223
224
225
226
227
    "# We print the accuracy of the SVC and the error rate\n",
    "acc = accuracy_score(y_test, y_pred)\n",
    "\n",
    "print(\"Accuracy: \", acc)\n",
    "print(\"Error rate: \", (1-acc) * 100, \"%\")"
   ]
  },
  {
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
228
   "id": "8f780139",
Rémy Huet's avatar
Rémy Huet committed
229
230
231
232
233
234
   "metadata": {},
   "source": [
    "As earlier, the values are affected by the selection of the training and testing dateset. Wi will retain a value of 3 % for the error.\n",
    "\n",
    "The method described py the authors relies on the support vectors of the previously trained SVM.\n",
    "We will thus do some inspection on them before going further."
Mathilde Rineau's avatar
Mathilde Rineau committed
235
236
237
238
   ]
  },
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
239
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
240
241
   "id": "81b09df7",
   "metadata": {},
Mathilde Rineau's avatar
Mathilde Rineau committed
242
   "outputs": [],
Mathilde Rineau's avatar
Mathilde Rineau committed
243
   "source": [
Rémy Huet's avatar
Rémy Huet committed
244
245
246
247
248
249
250
    "s_vects = svc.support_vectors_\n",
    "\n",
    "print(s_vects.shape)\n",
    "\n",
    "v = s_vects[0]\n",
    "v_index = svc.support_[0]\n",
    "v_class = y_train[v_index]\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
251
252
    "print(v_index)\n",
    "print(v_class)\n",
Rémy Huet's avatar
Rémy Huet committed
253
254
255
256
257
258
259
260
    "\n",
    "print(f'Class of the first support vector : {v_class}')\n",
    "img = np.reshape(v, (28, 28))\n",
    "plt.imshow(img, cmap='gray')"
   ]
  },
  {
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
261
   "id": "14cb2622",
Rémy Huet's avatar
Rémy Huet committed
262
263
264
265
266
267
268
269
270
   "metadata": {},
   "source": [
    "There are around 7500 support vectors in the SVM.\n",
    "\n",
    "Each support vector is a sample of `X_train`. We can thus retrieve its class using its index on the train dataset, and display it as an image as above."
   ]
  },
  {
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
271
   "id": "fa1d441f",
Rémy Huet's avatar
Rémy Huet committed
272
273
274
   "metadata": {},
   "source": [
    "### Implementing the \"Virtual Support Vectors\" method"
Mathilde Rineau's avatar
Mathilde Rineau committed
275
276
277
278
   ]
  },
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
279
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
280
281
282
283
   "id": "0e648133",
   "metadata": {},
   "outputs": [],
   "source": [
Mathilde Rineau's avatar
Mathilde Rineau committed
284
    "from math import sqrt\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
285
    "def right_side_rescaling(support_vectors):\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
286
287
288
289
    "    #n,m = support_vectors.shape\n",
    "    n_square = np.array(support_vectors.shape)\n",
    "    n = int(sqrt(int(n_square)))\n",
    "    m = n\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
290
291
292
293
294
295
296
297
298
299
300
301
302
303
    "    #print(n,m)\n",
    "    support_vector_lin =support_vectors.reshape((-1, n*m))\n",
    "    #print(support_vector_lin.shape)\n",
    "    temp = support_vector_lin[0][0]\n",
    "    for i in range (n*m-2):\n",
    "        #print(support_vector_lin[0][i])\n",
    "        support_vector_lin[0][i] = support_vector_lin[0][i+1]\n",
    "    support_vector_lin[0][n*m-1] = temp  \n",
    "    support_vectors = support_vector_lin.reshape(n,m)\n",
    "    return support_vectors"
   ]
  },
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
304
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
   "id": "c402cf0b",
   "metadata": {},
   "outputs": [],
   "source": [
    "def left_side_rescaling(support_vectors):\n",
    "    #n,m = support_vectors.shape\n",
    "    n_square = np.array(support_vectors.shape)\n",
    "    n = int(sqrt(int(n_square)))\n",
    "    m = n\n",
    "    #print(n,m)\n",
    "    support_vector_lin =support_vectors.reshape((-1, n*m))\n",
    "    #print(support_vector_lin.shape)\n",
    "    temp = support_vector_lin[0][n*m-1]\n",
    "    for i in range (n*m-1,0,-1):\n",
    "        #print(support_vector_lin[0][i])\n",
    "        support_vector_lin[0][i] = support_vector_lin[0][i-1]\n",
    "    support_vector_lin[0][0] = temp  \n",
    "    support_vectors = support_vector_lin.reshape(n,m)\n",
    "    return support_vectors"
   ]
  },
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
328
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
   "id": "cfc96a3c",
   "metadata": {},
   "outputs": [],
   "source": [
    "def top_side_rescaling(support_vectors):\n",
    "    #n,m = support_vectors.shape\n",
    "    n_square = np.array(support_vectors.shape)\n",
    "    n = int(sqrt(int(n_square)))\n",
    "    m = n\n",
    "    #print(n,m)\n",
    "    support_vector_lin =support_vectors.reshape((-1, n*m))\n",
    "    #print(support_vector_lin.shape)\n",
    "    #saving of the first line\n",
    "    temp = []\n",
    "    for j in range(m):\n",
    "        temp.append(support_vector_lin[0][j])\n",
    "    print(temp)\n",
    "    for i in range ((n-1)*m):\n",
    "        #print(\"i: \",i)\n",
    "        #print(support_vector_lin[0][i])\n",
    "        support_vector_lin[0][i] = support_vector_lin[0][i+m]\n",
    "    index = 0\n",
    "    #print(temp[1])\n",
    "    for k in range((n-1)*m,n*m):\n",
    "        support_vector_lin[0][k]=temp[index]\n",
    "        #print(\"temp: \",temp[index])\n",
    "        index+=1\n",
    "    support_vectors = support_vector_lin.reshape(n,m)\n",
    "    return support_vectors"
   ]
  },
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
362
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
363
   "id": "e90e0d37",
Mathilde Rineau's avatar
Mathilde Rineau committed
364
   "metadata": {},
Rémy Huet's avatar
Rémy Huet committed
365
   "outputs": [],
Mathilde Rineau's avatar
Mathilde Rineau committed
366
   "source": [
Mathilde Rineau's avatar
Mathilde Rineau committed
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
    "def bottom_side_rescaling(support_vectors):\n",
    "    #n,m = support_vectors.shape\n",
    "    n_square = np.array(support_vectors.shape)\n",
    "    n = int(sqrt(int(n_square)))\n",
    "    m = n\n",
    "    #print(n,m)\n",
    "    support_vector_lin =support_vectors.reshape((-1, n*m))\n",
    "    #saving of the last line\n",
    "    temp = []\n",
    "    for j in range((n-1)*m,n*m):\n",
    "        temp.append(support_vector_lin[0][j])\n",
    "    #print(temp)\n",
    "    for i in range((n-1)*m-1,-1,-1):\n",
    "        support_vector_lin[0][i+m] = support_vector_lin[0][i]\n",
    "    index = 0\n",
    "    for k in range(m):\n",
    "        support_vector_lin[0][k]=temp[index]\n",
    "        index+=1   \n",
    "    support_vectors = support_vector_lin.reshape(n,m)\n",
    "    return support_vectors"
   ]
  },
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
391
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
392
393
   "id": "44b4c207",
   "metadata": {},
Mathilde Rineau's avatar
Mathilde Rineau committed
394
   "outputs": [],
Mathilde Rineau's avatar
Mathilde Rineau committed
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
   "source": [
    "print(type(svc.support_vectors_))\n",
    "n = sqrt(784) \n",
    "n,m = svc.support_vectors_.shape\n",
    "print(svc.support_vectors_[i].shape)\n",
    "s_vects_right = []\n",
    "s_vects_left = []\n",
    "s_vects_top = []\n",
    "s_vects_bottom = []\n",
    "for i in range(n):\n",
    "    #print(np.array(svc.support_vectors_[i]))\n",
    "    s_vects_right.append(bottom_side_rescaling(np.array(svc.support_vectors_[i])))\n",
    "    s_vects_left.append(bottom_side_rescaling(np.array(svc.support_vectors_[i])))\n",
    "    s_vects_top.append(bottom_side_rescaling(np.array(svc.support_vectors_[i])))\n",
    "    s_vects_bottom.append(bottom_side_rescaling(np.array(svc.support_vectors_[i])))\n"
Mathilde Rineau's avatar
Mathilde Rineau committed
410
411
412
   ]
  },
  {
Rémy Huet's avatar
Rémy Huet committed
413
   "cell_type": "markdown",
Mathilde Rineau's avatar
Mathilde Rineau committed
414
   "id": "1c2840b0",
Mathilde Rineau's avatar
Mathilde Rineau committed
415
   "metadata": {},
Rémy Huet's avatar
Rémy Huet committed
416
   "source": [
Mathilde Rineau's avatar
Mathilde Rineau committed
417
418
419
420
421
    "We have shift the support vectors in the four directions so we have four new dataset which contains respectively the data shifted to the right, to the left, to the top and to the bottom."
   ]
  },
  {
   "cell_type": "code",
Mathilde Rineau's avatar
Mathilde Rineau committed
422
423
   "execution_count": null,
   "id": "2e8dad5b",
Mathilde Rineau's avatar
Mathilde Rineau committed
424
425
426
427
428
429
430
431
   "metadata": {},
   "outputs": [],
   "source": [
    "s_vects_shifted = []\n",
    "s_vects_shifted.append(s_vects_right)\n",
    "s_vects_shifted.append(s_vects_left)\n",
    "s_vects_shifted.append(s_vects_top)\n",
    "s_vects_shifted.append(s_vects_bottom)\n",
Rémy Huet's avatar
Rémy Huet committed
432
    "\n",
Mathilde Rineau's avatar
Mathilde Rineau committed
433
    "#print(s_vects_shifted)"
Rémy Huet's avatar
Rémy Huet committed
434
435
436
437
438
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
Mathilde Rineau's avatar
Mathilde Rineau committed
439
   "id": "2c9480d7",
Rémy Huet's avatar
Rémy Huet committed
440
441
442
   "metadata": {},
   "outputs": [],
   "source": [
Mathilde Rineau's avatar
Mathilde Rineau committed
443
444
445
    "#What can we use for shifted y_train ?\n",
    "svc = SVC(C=10, kernel = 'poly', degree = 5, gamma=1, coef0=0)\n",
    "svc.fit(s_vects_shifted, y_train)"
Rémy Huet's avatar
Rémy Huet committed
446
   ]
Mathilde Rineau's avatar
Mathilde Rineau committed
447
448
449
450
451
452
453
454
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49407e07",
   "metadata": {},
   "outputs": [],
   "source": []
Mathilde Rineau's avatar
Mathilde Rineau committed
455
456
457
  }
 ],
 "metadata": {
Rémy Huet's avatar
Rémy Huet committed
458
459
460
  "interpreter": {
   "hash": "78ff2a7d75990e26f7862f23aec114522929670ec71bbfd9a70bdb18a9100993"
  },
Mathilde Rineau's avatar
Mathilde Rineau committed
461
  "kernelspec": {
Mathilde Rineau's avatar
Mathilde Rineau committed
462
463
   "display_name": "Python 3",
   "language": "python",
Mathilde Rineau's avatar
Mathilde Rineau committed
464
465
466
467
468
469
470
471
472
473
474
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
Mathilde Rineau's avatar
Mathilde Rineau committed
475
476
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
Mathilde Rineau's avatar
Mathilde Rineau committed
477
478
479
480
481
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}