bartmiller commited on
Commit
6bb6d93
·
1 Parent(s): 0b6725c

Delete kaggle_data_and_huggingface.ipynb

Browse files
Files changed (1) hide show
  1. kaggle_data_and_huggingface.ipynb +0 -956
kaggle_data_and_huggingface.ipynb DELETED
@@ -1,956 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "source": [
6
- "https://www.kdnuggets.com/deploying-your-first-machine-learning-model"
7
- ],
8
- "metadata": {
9
- "id": "MP7O1gtliL6n"
10
- }
11
- },
12
- {
13
- "cell_type": "code",
14
- "source": [
15
- "try:\n",
16
- " import opendatasets as od\n",
17
- " import pandas as pd\n",
18
- "except:\n",
19
- " !pip install opendatasets\n",
20
- " import opendatasets as od\n",
21
- "from os import path\n",
22
- "\n",
23
- "url = \"https://www.kaggle.com/datasets/uciml/glass\" ### kaggle dataset url here\n",
24
- "data_dir = \"/content/\" ### directory where you want to save data\n",
25
- "\n",
26
- "# Go to the account tab and under API section, click Create New API Token.\n",
27
- "\n",
28
- "# A JSON file will be downloaded, open it locally or you can also use any online JSON viewer and upload it there.\n",
29
- "\n",
30
- "# On opening this file, you will find the username and key in it. Copy the username and password and paste it into the prompted Notebook cell.\n",
31
- "# The content of the downloaded file would look like this.\n",
32
- "\n",
33
- "# {\"username\":<KAGGLE USERNAME>,\"key\":<KAGGLE KEY>}\n",
34
- "\n",
35
- "\n",
36
- "def download_data(url, data_dir):\n",
37
- " od.download(url, data_dir)"
38
- ],
39
- "metadata": {
40
- "id": "5ewudtMkfnPL",
41
- "outputId": "6abe70ec-7a22-4872-b0e6-623d9e18e1fe",
42
- "colab": {
43
- "base_uri": "https://localhost:8080/"
44
- }
45
- },
46
- "execution_count": 1,
47
- "outputs": [
48
- {
49
- "output_type": "stream",
50
- "name": "stdout",
51
- "text": [
52
- "Collecting opendatasets\n",
53
- " Downloading opendatasets-0.1.22-py3-none-any.whl (15 kB)\n",
54
- "Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from opendatasets) (4.66.1)\n",
55
- "Requirement already satisfied: kaggle in /usr/local/lib/python3.10/dist-packages (from opendatasets) (1.5.16)\n",
56
- "Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from opendatasets) (8.1.7)\n",
57
- "Requirement already satisfied: six>=1.10 in /usr/local/lib/python3.10/dist-packages (from kaggle->opendatasets) (1.16.0)\n",
58
- "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from kaggle->opendatasets) (2023.11.17)\n",
59
- "Requirement already satisfied: python-dateutil in /usr/local/lib/python3.10/dist-packages (from kaggle->opendatasets) (2.8.2)\n",
60
- "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from kaggle->opendatasets) (2.31.0)\n",
61
- "Requirement already satisfied: python-slugify in /usr/local/lib/python3.10/dist-packages (from kaggle->opendatasets) (8.0.1)\n",
62
- "Requirement already satisfied: urllib3 in /usr/local/lib/python3.10/dist-packages (from kaggle->opendatasets) (2.0.7)\n",
63
- "Requirement already satisfied: bleach in /usr/local/lib/python3.10/dist-packages (from kaggle->opendatasets) (6.1.0)\n",
64
- "Requirement already satisfied: webencodings in /usr/local/lib/python3.10/dist-packages (from bleach->kaggle->opendatasets) (0.5.1)\n",
65
- "Requirement already satisfied: text-unidecode>=1.3 in /usr/local/lib/python3.10/dist-packages (from python-slugify->kaggle->opendatasets) (1.3)\n",
66
- "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->kaggle->opendatasets) (3.3.2)\n",
67
- "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->kaggle->opendatasets) (3.6)\n",
68
- "Installing collected packages: opendatasets\n",
69
- "Successfully installed opendatasets-0.1.22\n"
70
- ]
71
- }
72
- ]
73
- },
74
- {
75
- "cell_type": "code",
76
- "source": [
77
- "download_data(url, data_dir)"
78
- ],
79
- "metadata": {
80
- "id": "y-gTjPFggtAM",
81
- "outputId": "02890664-5063-4698-d664-ee458de7b125",
82
- "colab": {
83
- "base_uri": "https://localhost:8080/"
84
- }
85
- },
86
- "execution_count": 2,
87
- "outputs": [
88
- {
89
- "output_type": "stream",
90
- "name": "stdout",
91
- "text": [
92
- "Please provide your Kaggle credentials to download this dataset. Learn more: http://bit.ly/kaggle-creds\n",
93
- "Your Kaggle username: bartmiller\n",
94
- "Your Kaggle Key: ··········\n",
95
- "Downloading glass.zip to /content/glass\n"
96
- ]
97
- },
98
- {
99
- "output_type": "stream",
100
- "name": "stderr",
101
- "text": [
102
- "100%|██████████| 3.42k/3.42k [00:00<00:00, 2.36MB/s]"
103
- ]
104
- },
105
- {
106
- "output_type": "stream",
107
- "name": "stdout",
108
- "text": [
109
- "\n"
110
- ]
111
- },
112
- {
113
- "output_type": "stream",
114
- "name": "stderr",
115
- "text": [
116
- "\n"
117
- ]
118
- }
119
- ]
120
- },
121
- {
122
- "cell_type": "code",
123
- "execution_count": 3,
124
- "metadata": {
125
- "colab": {
126
- "base_uri": "https://localhost:8080/",
127
- "height": 143
128
- },
129
- "id": "lIYdn1woOS1n",
130
- "outputId": "046caad7-0e5b-4f95-ebb1-ea972539b936"
131
- },
132
- "outputs": [
133
- {
134
- "output_type": "execute_result",
135
- "data": {
136
- "text/plain": [
137
- " RI Na Mg Al Si K Ca Ba Fe Type\n",
138
- "6 1.51743 13.30 3.60 1.14 73.09 0.58 8.17 0.0 0.0 1\n",
139
- "138 1.51674 12.79 3.52 1.54 73.36 0.66 7.90 0.0 0.0 2\n",
140
- "40 1.51793 12.79 3.50 1.12 73.03 0.64 8.77 0.0 0.0 1"
141
- ],
142
- "text/html": [
143
- "\n",
144
- " <div id=\"df-cbce004c-2373-4269-b108-792cb1bca131\" class=\"colab-df-container\">\n",
145
- " <div>\n",
146
- "<style scoped>\n",
147
- " .dataframe tbody tr th:only-of-type {\n",
148
- " vertical-align: middle;\n",
149
- " }\n",
150
- "\n",
151
- " .dataframe tbody tr th {\n",
152
- " vertical-align: top;\n",
153
- " }\n",
154
- "\n",
155
- " .dataframe thead th {\n",
156
- " text-align: right;\n",
157
- " }\n",
158
- "</style>\n",
159
- "<table border=\"1\" class=\"dataframe\">\n",
160
- " <thead>\n",
161
- " <tr style=\"text-align: right;\">\n",
162
- " <th></th>\n",
163
- " <th>RI</th>\n",
164
- " <th>Na</th>\n",
165
- " <th>Mg</th>\n",
166
- " <th>Al</th>\n",
167
- " <th>Si</th>\n",
168
- " <th>K</th>\n",
169
- " <th>Ca</th>\n",
170
- " <th>Ba</th>\n",
171
- " <th>Fe</th>\n",
172
- " <th>Type</th>\n",
173
- " </tr>\n",
174
- " </thead>\n",
175
- " <tbody>\n",
176
- " <tr>\n",
177
- " <th>6</th>\n",
178
- " <td>1.51743</td>\n",
179
- " <td>13.30</td>\n",
180
- " <td>3.60</td>\n",
181
- " <td>1.14</td>\n",
182
- " <td>73.09</td>\n",
183
- " <td>0.58</td>\n",
184
- " <td>8.17</td>\n",
185
- " <td>0.0</td>\n",
186
- " <td>0.0</td>\n",
187
- " <td>1</td>\n",
188
- " </tr>\n",
189
- " <tr>\n",
190
- " <th>138</th>\n",
191
- " <td>1.51674</td>\n",
192
- " <td>12.79</td>\n",
193
- " <td>3.52</td>\n",
194
- " <td>1.54</td>\n",
195
- " <td>73.36</td>\n",
196
- " <td>0.66</td>\n",
197
- " <td>7.90</td>\n",
198
- " <td>0.0</td>\n",
199
- " <td>0.0</td>\n",
200
- " <td>2</td>\n",
201
- " </tr>\n",
202
- " <tr>\n",
203
- " <th>40</th>\n",
204
- " <td>1.51793</td>\n",
205
- " <td>12.79</td>\n",
206
- " <td>3.50</td>\n",
207
- " <td>1.12</td>\n",
208
- " <td>73.03</td>\n",
209
- " <td>0.64</td>\n",
210
- " <td>8.77</td>\n",
211
- " <td>0.0</td>\n",
212
- " <td>0.0</td>\n",
213
- " <td>1</td>\n",
214
- " </tr>\n",
215
- " </tbody>\n",
216
- "</table>\n",
217
- "</div>\n",
218
- " <div class=\"colab-df-buttons\">\n",
219
- "\n",
220
- " <div class=\"colab-df-container\">\n",
221
- " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-cbce004c-2373-4269-b108-792cb1bca131')\"\n",
222
- " title=\"Convert this dataframe to an interactive table.\"\n",
223
- " style=\"display:none;\">\n",
224
- "\n",
225
- " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
226
- " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
227
- " </svg>\n",
228
- " </button>\n",
229
- "\n",
230
- " <style>\n",
231
- " .colab-df-container {\n",
232
- " display:flex;\n",
233
- " gap: 12px;\n",
234
- " }\n",
235
- "\n",
236
- " .colab-df-convert {\n",
237
- " background-color: #E8F0FE;\n",
238
- " border: none;\n",
239
- " border-radius: 50%;\n",
240
- " cursor: pointer;\n",
241
- " display: none;\n",
242
- " fill: #1967D2;\n",
243
- " height: 32px;\n",
244
- " padding: 0 0 0 0;\n",
245
- " width: 32px;\n",
246
- " }\n",
247
- "\n",
248
- " .colab-df-convert:hover {\n",
249
- " background-color: #E2EBFA;\n",
250
- " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
251
- " fill: #174EA6;\n",
252
- " }\n",
253
- "\n",
254
- " .colab-df-buttons div {\n",
255
- " margin-bottom: 4px;\n",
256
- " }\n",
257
- "\n",
258
- " [theme=dark] .colab-df-convert {\n",
259
- " background-color: #3B4455;\n",
260
- " fill: #D2E3FC;\n",
261
- " }\n",
262
- "\n",
263
- " [theme=dark] .colab-df-convert:hover {\n",
264
- " background-color: #434B5C;\n",
265
- " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
266
- " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
267
- " fill: #FFFFFF;\n",
268
- " }\n",
269
- " </style>\n",
270
- "\n",
271
- " <script>\n",
272
- " const buttonEl =\n",
273
- " document.querySelector('#df-cbce004c-2373-4269-b108-792cb1bca131 button.colab-df-convert');\n",
274
- " buttonEl.style.display =\n",
275
- " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
276
- "\n",
277
- " async function convertToInteractive(key) {\n",
278
- " const element = document.querySelector('#df-cbce004c-2373-4269-b108-792cb1bca131');\n",
279
- " const dataTable =\n",
280
- " await google.colab.kernel.invokeFunction('convertToInteractive',\n",
281
- " [key], {});\n",
282
- " if (!dataTable) return;\n",
283
- "\n",
284
- " const docLinkHtml = 'Like what you see? Visit the ' +\n",
285
- " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
286
- " + ' to learn more about interactive tables.';\n",
287
- " element.innerHTML = '';\n",
288
- " dataTable['output_type'] = 'display_data';\n",
289
- " await google.colab.output.renderOutput(dataTable, element);\n",
290
- " const docLink = document.createElement('div');\n",
291
- " docLink.innerHTML = docLinkHtml;\n",
292
- " element.appendChild(docLink);\n",
293
- " }\n",
294
- " </script>\n",
295
- " </div>\n",
296
- "\n",
297
- "\n",
298
- "<div id=\"df-5f58b948-c3a9-4d61-8174-2c1825c6237e\">\n",
299
- " <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-5f58b948-c3a9-4d61-8174-2c1825c6237e')\"\n",
300
- " title=\"Suggest charts\"\n",
301
- " style=\"display:none;\">\n",
302
- "\n",
303
- "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
304
- " width=\"24px\">\n",
305
- " <g>\n",
306
- " <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
307
- " </g>\n",
308
- "</svg>\n",
309
- " </button>\n",
310
- "\n",
311
- "<style>\n",
312
- " .colab-df-quickchart {\n",
313
- " --bg-color: #E8F0FE;\n",
314
- " --fill-color: #1967D2;\n",
315
- " --hover-bg-color: #E2EBFA;\n",
316
- " --hover-fill-color: #174EA6;\n",
317
- " --disabled-fill-color: #AAA;\n",
318
- " --disabled-bg-color: #DDD;\n",
319
- " }\n",
320
- "\n",
321
- " [theme=dark] .colab-df-quickchart {\n",
322
- " --bg-color: #3B4455;\n",
323
- " --fill-color: #D2E3FC;\n",
324
- " --hover-bg-color: #434B5C;\n",
325
- " --hover-fill-color: #FFFFFF;\n",
326
- " --disabled-bg-color: #3B4455;\n",
327
- " --disabled-fill-color: #666;\n",
328
- " }\n",
329
- "\n",
330
- " .colab-df-quickchart {\n",
331
- " background-color: var(--bg-color);\n",
332
- " border: none;\n",
333
- " border-radius: 50%;\n",
334
- " cursor: pointer;\n",
335
- " display: none;\n",
336
- " fill: var(--fill-color);\n",
337
- " height: 32px;\n",
338
- " padding: 0;\n",
339
- " width: 32px;\n",
340
- " }\n",
341
- "\n",
342
- " .colab-df-quickchart:hover {\n",
343
- " background-color: var(--hover-bg-color);\n",
344
- " box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
345
- " fill: var(--button-hover-fill-color);\n",
346
- " }\n",
347
- "\n",
348
- " .colab-df-quickchart-complete:disabled,\n",
349
- " .colab-df-quickchart-complete:disabled:hover {\n",
350
- " background-color: var(--disabled-bg-color);\n",
351
- " fill: var(--disabled-fill-color);\n",
352
- " box-shadow: none;\n",
353
- " }\n",
354
- "\n",
355
- " .colab-df-spinner {\n",
356
- " border: 2px solid var(--fill-color);\n",
357
- " border-color: transparent;\n",
358
- " border-bottom-color: var(--fill-color);\n",
359
- " animation:\n",
360
- " spin 1s steps(1) infinite;\n",
361
- " }\n",
362
- "\n",
363
- " @keyframes spin {\n",
364
- " 0% {\n",
365
- " border-color: transparent;\n",
366
- " border-bottom-color: var(--fill-color);\n",
367
- " border-left-color: var(--fill-color);\n",
368
- " }\n",
369
- " 20% {\n",
370
- " border-color: transparent;\n",
371
- " border-left-color: var(--fill-color);\n",
372
- " border-top-color: var(--fill-color);\n",
373
- " }\n",
374
- " 30% {\n",
375
- " border-color: transparent;\n",
376
- " border-left-color: var(--fill-color);\n",
377
- " border-top-color: var(--fill-color);\n",
378
- " border-right-color: var(--fill-color);\n",
379
- " }\n",
380
- " 40% {\n",
381
- " border-color: transparent;\n",
382
- " border-right-color: var(--fill-color);\n",
383
- " border-top-color: var(--fill-color);\n",
384
- " }\n",
385
- " 60% {\n",
386
- " border-color: transparent;\n",
387
- " border-right-color: var(--fill-color);\n",
388
- " }\n",
389
- " 80% {\n",
390
- " border-color: transparent;\n",
391
- " border-right-color: var(--fill-color);\n",
392
- " border-bottom-color: var(--fill-color);\n",
393
- " }\n",
394
- " 90% {\n",
395
- " border-color: transparent;\n",
396
- " border-bottom-color: var(--fill-color);\n",
397
- " }\n",
398
- " }\n",
399
- "</style>\n",
400
- "\n",
401
- " <script>\n",
402
- " async function quickchart(key) {\n",
403
- " const quickchartButtonEl =\n",
404
- " document.querySelector('#' + key + ' button');\n",
405
- " quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
406
- " quickchartButtonEl.classList.add('colab-df-spinner');\n",
407
- " try {\n",
408
- " const charts = await google.colab.kernel.invokeFunction(\n",
409
- " 'suggestCharts', [key], {});\n",
410
- " } catch (error) {\n",
411
- " console.error('Error during call to suggestCharts:', error);\n",
412
- " }\n",
413
- " quickchartButtonEl.classList.remove('colab-df-spinner');\n",
414
- " quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
415
- " }\n",
416
- " (() => {\n",
417
- " let quickchartButtonEl =\n",
418
- " document.querySelector('#df-5f58b948-c3a9-4d61-8174-2c1825c6237e button');\n",
419
- " quickchartButtonEl.style.display =\n",
420
- " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
421
- " })();\n",
422
- " </script>\n",
423
- "</div>\n",
424
- "\n",
425
- " </div>\n",
426
- " </div>\n"
427
- ]
428
- },
429
- "metadata": {},
430
- "execution_count": 3
431
- }
432
- ],
433
- "source": [
434
- "import pandas as pd\n",
435
- "glass_df = pd.read_csv(\"/content/glass/glass.csv\")\n",
436
- "glass_df = glass_df.sample(frac = 1)\n",
437
- "glass_df.head(3)"
438
- ]
439
- },
440
- {
441
- "cell_type": "code",
442
- "source": [
443
- "from sklearn.model_selection import train_test_split\n",
444
- "\n",
445
- "X = glass_df.drop(\"Type\",axis=1)\n",
446
- "y = glass_df.Type\n",
447
- "\n",
448
- "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=125)"
449
- ],
450
- "metadata": {
451
- "id": "7_eWUKS6hV2o"
452
- },
453
- "execution_count": 4,
454
- "outputs": []
455
- },
456
- {
457
- "cell_type": "code",
458
- "source": [
459
- "from sklearn.ensemble import RandomForestClassifier\n",
460
- "from sklearn.preprocessing import StandardScaler\n",
461
- "from sklearn.impute import SimpleImputer\n",
462
- "from sklearn.pipeline import Pipeline\n",
463
- "\n",
464
- "\n",
465
- "pipe = Pipeline(\n",
466
- " steps=[\n",
467
- " (\"imputer\", SimpleImputer()),\n",
468
- " (\"scaler\", StandardScaler()),\n",
469
- " (\"model\", RandomForestClassifier(n_estimators=100, random_state=125)),\n",
470
- " ]\n",
471
- ")\n",
472
- "pipe.fit(X_train, y_train)\n",
473
- "\n",
474
- "pipe.score(X_test, y_test)"
475
- ],
476
- "metadata": {
477
- "colab": {
478
- "base_uri": "https://localhost:8080/"
479
- },
480
- "id": "MTMLGHGuhvAA",
481
- "outputId": "cb35ca9e-8e24-49ec-8c9b-06d195905fd1"
482
- },
483
- "execution_count": 5,
484
- "outputs": [
485
- {
486
- "output_type": "execute_result",
487
- "data": {
488
- "text/plain": [
489
- "0.8"
490
- ]
491
- },
492
- "metadata": {},
493
- "execution_count": 5
494
- }
495
- ]
496
- },
497
- {
498
- "cell_type": "code",
499
- "source": [
500
- "from sklearn.metrics import classification_report\n",
501
- "\n",
502
- "y_pred = pipe.predict(X_test)\n",
503
- "print(classification_report(y_test,y_pred))"
504
- ],
505
- "metadata": {
506
- "colab": {
507
- "base_uri": "https://localhost:8080/"
508
- },
509
- "id": "EREHPUy_h0Zq",
510
- "outputId": "46d7bc64-0ddb-4be1-fbfb-b43c7ded4e35"
511
- },
512
- "execution_count": 6,
513
- "outputs": [
514
- {
515
- "output_type": "stream",
516
- "name": "stdout",
517
- "text": [
518
- " precision recall f1-score support\n",
519
- "\n",
520
- " 1 0.81 0.92 0.86 24\n",
521
- " 2 0.75 0.88 0.81 17\n",
522
- " 3 0.67 0.25 0.36 8\n",
523
- " 5 0.67 0.67 0.67 3\n",
524
- " 6 1.00 1.00 1.00 3\n",
525
- " 7 0.89 0.80 0.84 10\n",
526
- "\n",
527
- " accuracy 0.80 65\n",
528
- " macro avg 0.80 0.75 0.76 65\n",
529
- "weighted avg 0.79 0.80 0.78 65\n",
530
- "\n"
531
- ]
532
- }
533
- ]
534
- },
535
- {
536
- "cell_type": "code",
537
- "source": [
538
- "!pip install skops"
539
- ],
540
- "metadata": {
541
- "colab": {
542
- "base_uri": "https://localhost:8080/"
543
- },
544
- "id": "56jjXsBxiAiB",
545
- "outputId": "27f71a89-8eec-4e8a-b23b-f3f1f7329cbe"
546
- },
547
- "execution_count": 8,
548
- "outputs": [
549
- {
550
- "output_type": "stream",
551
- "name": "stdout",
552
- "text": [
553
- "Collecting skops\n",
554
- " Downloading skops-0.9.0-py3-none-any.whl (120 kB)\n",
555
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m120.7/120.7 kB\u001b[0m \u001b[31m1.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
556
- "\u001b[?25hRequirement already satisfied: scikit-learn>=0.24 in /usr/local/lib/python3.10/dist-packages (from skops) (1.2.2)\n",
557
- "Requirement already satisfied: huggingface-hub>=0.17.0 in /usr/local/lib/python3.10/dist-packages (from skops) (0.19.4)\n",
558
- "Requirement already satisfied: tabulate>=0.8.8 in /usr/local/lib/python3.10/dist-packages (from skops) (0.9.0)\n",
559
- "Requirement already satisfied: packaging>=17.0 in /usr/local/lib/python3.10/dist-packages (from skops) (23.2)\n",
560
- "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.17.0->skops) (3.13.1)\n",
561
- "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.17.0->skops) (2023.6.0)\n",
562
- "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.17.0->skops) (2.31.0)\n",
563
- "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.17.0->skops) (4.66.1)\n",
564
- "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.17.0->skops) (6.0.1)\n",
565
- "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.17.0->skops) (4.5.0)\n",
566
- "Requirement already satisfied: numpy>=1.17.3 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.24->skops) (1.23.5)\n",
567
- "Requirement already satisfied: scipy>=1.3.2 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.24->skops) (1.11.4)\n",
568
- "Requirement already satisfied: joblib>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.24->skops) (1.3.2)\n",
569
- "Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.24->skops) (3.2.0)\n",
570
- "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.17.0->skops) (3.3.2)\n",
571
- "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.17.0->skops) (3.6)\n",
572
- "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.17.0->skops) (2.0.7)\n",
573
- "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.17.0->skops) (2023.11.17)\n",
574
- "Installing collected packages: skops\n",
575
- "Successfully installed skops-0.9.0\n"
576
- ]
577
- }
578
- ]
579
- },
580
- {
581
- "cell_type": "code",
582
- "source": [
583
- "import skops.io as sio\n",
584
- "sio.dump(pipe, \"glass_pipeline.skops\")"
585
- ],
586
- "metadata": {
587
- "id": "wZARmF26h4S9"
588
- },
589
- "execution_count": 9,
590
- "outputs": []
591
- },
592
- {
593
- "cell_type": "code",
594
- "source": [
595
- "sio.load(\"glass_pipeline.skops\", trusted=True)\n"
596
- ],
597
- "metadata": {
598
- "colab": {
599
- "base_uri": "https://localhost:8080/",
600
- "height": 161
601
- },
602
- "id": "DQ1zj-mjiIRL",
603
- "outputId": "00d4ebb0-2f95-45f7-972f-05c257a3af53"
604
- },
605
- "execution_count": 10,
606
- "outputs": [
607
- {
608
- "output_type": "execute_result",
609
- "data": {
610
- "text/plain": [
611
- "Pipeline(steps=[('imputer', SimpleImputer()), ('scaler', StandardScaler()),\n",
612
- " ('model', RandomForestClassifier(random_state=125))])"
613
- ],
614
- "text/html": [
615
- "<style>#sk-container-id-1 {color: black;background-color: white;}#sk-container-id-1 pre{padding: 0;}#sk-container-id-1 div.sk-toggleable {background-color: white;}#sk-container-id-1 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-1 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-1 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-1 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-1 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-1 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-1 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-1 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-1 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-1 div.sk-item {position: relative;z-index: 1;}#sk-container-id-1 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-1 div.sk-item::before, #sk-container-id-1 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-1 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-1 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-1 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-1 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-1 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-1 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-1 div.sk-label-container {text-align: center;}#sk-container-id-1 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-1 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>Pipeline(steps=[(&#x27;imputer&#x27;, SimpleImputer()), (&#x27;scaler&#x27;, StandardScaler()),\n",
616
- " (&#x27;model&#x27;, RandomForestClassifier(random_state=125))])</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item sk-dashed-wrapped\"><div class=\"sk-label-container\"><div class=\"sk-label sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" ><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">Pipeline</label><div class=\"sk-toggleable__content\"><pre>Pipeline(steps=[(&#x27;imputer&#x27;, SimpleImputer()), (&#x27;scaler&#x27;, StandardScaler()),\n",
617
- " (&#x27;model&#x27;, RandomForestClassifier(random_state=125))])</pre></div></div></div><div class=\"sk-serial\"><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-2\" type=\"checkbox\" ><label for=\"sk-estimator-id-2\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">SimpleImputer</label><div class=\"sk-toggleable__content\"><pre>SimpleImputer()</pre></div></div></div><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-3\" type=\"checkbox\" ><label for=\"sk-estimator-id-3\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">StandardScaler</label><div class=\"sk-toggleable__content\"><pre>StandardScaler()</pre></div></div></div><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-4\" type=\"checkbox\" ><label for=\"sk-estimator-id-4\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">RandomForestClassifier</label><div class=\"sk-toggleable__content\"><pre>RandomForestClassifier(random_state=125)</pre></div></div></div></div></div></div></div>"
618
- ]
619
- },
620
- "metadata": {},
621
- "execution_count": 10
622
- }
623
- ]
624
- },
625
- {
626
- "cell_type": "code",
627
- "source": [
628
- "!pip install gradio"
629
- ],
630
- "metadata": {
631
- "colab": {
632
- "base_uri": "https://localhost:8080/"
633
- },
634
- "id": "beFfVpBQiWMo",
635
- "outputId": "2ade8915-50a8-44c2-c53a-b7bd0583f8fb"
636
- },
637
- "execution_count": 12,
638
- "outputs": [
639
- {
640
- "output_type": "stream",
641
- "name": "stdout",
642
- "text": [
643
- "Collecting gradio\n",
644
- " Downloading gradio-4.12.0-py3-none-any.whl (16.6 MB)\n",
645
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m16.6/16.6 MB\u001b[0m \u001b[31m42.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
646
- "\u001b[?25hCollecting aiofiles<24.0,>=22.0 (from gradio)\n",
647
- " Downloading aiofiles-23.2.1-py3-none-any.whl (15 kB)\n",
648
- "Requirement already satisfied: altair<6.0,>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.2.2)\n",
649
- "Collecting fastapi (from gradio)\n",
650
- " Downloading fastapi-0.108.0-py3-none-any.whl (92 kB)\n",
651
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m92.0/92.0 kB\u001b[0m \u001b[31m12.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
652
- "\u001b[?25hCollecting ffmpy (from gradio)\n",
653
- " Downloading ffmpy-0.3.1.tar.gz (5.5 kB)\n",
654
- " Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
655
- "Collecting gradio-client==0.8.0 (from gradio)\n",
656
- " Downloading gradio_client-0.8.0-py3-none-any.whl (305 kB)\n",
657
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m305.1/305.1 kB\u001b[0m \u001b[31m30.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
658
- "\u001b[?25hCollecting httpx (from gradio)\n",
659
- " Downloading httpx-0.26.0-py3-none-any.whl (75 kB)\n",
660
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.9/75.9 kB\u001b[0m \u001b[31m8.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
661
- "\u001b[?25hRequirement already satisfied: huggingface-hub>=0.19.3 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.19.4)\n",
662
- "Requirement already satisfied: importlib-resources<7.0,>=1.3 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.1.1)\n",
663
- "Requirement already satisfied: jinja2<4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.1.2)\n",
664
- "Requirement already satisfied: markupsafe~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.3)\n",
665
- "Requirement already satisfied: matplotlib~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n",
666
- "Requirement already satisfied: numpy~=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.23.5)\n",
667
- "Collecting orjson~=3.0 (from gradio)\n",
668
- " Downloading orjson-3.9.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (138 kB)\n",
669
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m138.7/138.7 kB\u001b[0m \u001b[31m15.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
670
- "\u001b[?25hRequirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gradio) (23.2)\n",
671
- "Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.5.3)\n",
672
- "Requirement already satisfied: pillow<11.0,>=8.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (9.4.0)\n",
673
- "Collecting pydantic>=2.0 (from gradio)\n",
674
- " Downloading pydantic-2.5.3-py3-none-any.whl (381 kB)\n",
675
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m381.9/381.9 kB\u001b[0m \u001b[31m34.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
676
- "\u001b[?25hCollecting pydub (from gradio)\n",
677
- " Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n",
678
- "Collecting python-multipart (from gradio)\n",
679
- " Downloading python_multipart-0.0.6-py3-none-any.whl (45 kB)\n",
680
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.7/45.7 kB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
681
- "\u001b[?25hRequirement already satisfied: pyyaml<7.0,>=5.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.0.1)\n",
682
- "Collecting semantic-version~=2.0 (from gradio)\n",
683
- " Downloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n",
684
- "Collecting tomlkit==0.12.0 (from gradio)\n",
685
- " Downloading tomlkit-0.12.0-py3-none-any.whl (37 kB)\n",
686
- "Requirement already satisfied: typer[all]<1.0,>=0.9 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.9.0)\n",
687
- "Requirement already satisfied: typing-extensions~=4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.5.0)\n",
688
- "Collecting uvicorn>=0.14.0 (from gradio)\n",
689
- " Downloading uvicorn-0.25.0-py3-none-any.whl (60 kB)\n",
690
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m60.3/60.3 kB\u001b[0m \u001b[31m7.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
691
- "\u001b[?25hRequirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from gradio-client==0.8.0->gradio) (2023.6.0)\n",
692
- "Collecting websockets<12.0,>=10.0 (from gradio-client==0.8.0->gradio)\n",
693
- " Downloading websockets-11.0.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129 kB)\n",
694
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m129.9/129.9 kB\u001b[0m \u001b[31m14.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
695
- "\u001b[?25hRequirement already satisfied: entrypoints in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio) (0.4)\n",
696
- "Requirement already satisfied: jsonschema>=3.0 in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio) (4.19.2)\n",
697
- "Requirement already satisfied: toolz in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio) (0.12.0)\n",
698
- "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (3.13.1)\n",
699
- "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (2.31.0)\n",
700
- "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.3->gradio) (4.66.1)\n",
701
- "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.2.0)\n",
702
- "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (0.12.1)\n",
703
- "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (4.46.0)\n",
704
- "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.4.5)\n",
705
- "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (3.1.1)\n",
706
- "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (2.8.2)\n",
707
- "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2023.3.post1)\n",
708
- "Collecting annotated-types>=0.4.0 (from pydantic>=2.0->gradio)\n",
709
- " Downloading annotated_types-0.6.0-py3-none-any.whl (12 kB)\n",
710
- "Collecting pydantic-core==2.14.6 (from pydantic>=2.0->gradio)\n",
711
- " Downloading pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB)\n",
712
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.1/2.1 MB\u001b[0m \u001b[31m40.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
713
- "\u001b[?25hCollecting typing-extensions~=4.0 (from gradio)\n",
714
- " Downloading typing_extensions-4.9.0-py3-none-any.whl (32 kB)\n",
715
- "Requirement already satisfied: click<9.0.0,>=7.1.1 in /usr/local/lib/python3.10/dist-packages (from typer[all]<1.0,>=0.9->gradio) (8.1.7)\n",
716
- "Collecting colorama<0.5.0,>=0.4.3 (from typer[all]<1.0,>=0.9->gradio)\n",
717
- " Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)\n",
718
- "Collecting shellingham<2.0.0,>=1.3.0 (from typer[all]<1.0,>=0.9->gradio)\n",
719
- " Downloading shellingham-1.5.4-py2.py3-none-any.whl (9.8 kB)\n",
720
- "Requirement already satisfied: rich<14.0.0,>=10.11.0 in /usr/local/lib/python3.10/dist-packages (from typer[all]<1.0,>=0.9->gradio) (13.7.0)\n",
721
- "Collecting h11>=0.8 (from uvicorn>=0.14.0->gradio)\n",
722
- " Downloading h11-0.14.0-py3-none-any.whl (58 kB)\n",
723
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m7.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
724
- "\u001b[?25hCollecting starlette<0.33.0,>=0.29.0 (from fastapi->gradio)\n",
725
- " Downloading starlette-0.32.0.post1-py3-none-any.whl (70 kB)\n",
726
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m70.0/70.0 kB\u001b[0m \u001b[31m8.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
727
- "\u001b[?25hRequirement already satisfied: anyio in /usr/local/lib/python3.10/dist-packages (from httpx->gradio) (3.7.1)\n",
728
- "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx->gradio) (2023.11.17)\n",
729
- "Collecting httpcore==1.* (from httpx->gradio)\n",
730
- " Downloading httpcore-1.0.2-py3-none-any.whl (76 kB)\n",
731
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.9/76.9 kB\u001b[0m \u001b[31m10.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
732
- "\u001b[?25hRequirement already satisfied: idna in /usr/local/lib/python3.10/dist-packages (from httpx->gradio) (3.6)\n",
733
- "Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx->gradio) (1.3.0)\n",
734
- "Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (23.1.0)\n",
735
- "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (2023.11.2)\n",
736
- "Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (0.32.0)\n",
737
- "Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (0.15.2)\n",
738
- "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\n",
739
- "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich<14.0.0,>=10.11.0->typer[all]<1.0,>=0.9->gradio) (3.0.0)\n",
740
- "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich<14.0.0,>=10.11.0->typer[all]<1.0,>=0.9->gradio) (2.16.1)\n",
741
- "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio->httpx->gradio) (1.2.0)\n",
742
- "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.3->gradio) (3.3.2)\n",
743
- "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.3->gradio) (2.0.7)\n",
744
- "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich<14.0.0,>=10.11.0->typer[all]<1.0,>=0.9->gradio) (0.1.2)\n",
745
- "Building wheels for collected packages: ffmpy\n",
746
- " Building wheel for ffmpy (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
747
- " Created wheel for ffmpy: filename=ffmpy-0.3.1-py3-none-any.whl size=5579 sha256=88940a0ba2d1088e0d93a684f25374ff2dfc47a1278ffaa94013d7b19a45d13f\n",
748
- " Stored in directory: /root/.cache/pip/wheels/01/a6/d1/1c0828c304a4283b2c1639a09ad86f83d7c487ef34c6b4a1bf\n",
749
- "Successfully built ffmpy\n",
750
- "Installing collected packages: pydub, ffmpy, websockets, typing-extensions, tomlkit, shellingham, semantic-version, python-multipart, orjson, h11, colorama, annotated-types, aiofiles, uvicorn, starlette, pydantic-core, httpcore, pydantic, httpx, gradio-client, fastapi, gradio\n",
751
- " Attempting uninstall: typing-extensions\n",
752
- " Found existing installation: typing_extensions 4.5.0\n",
753
- " Uninstalling typing_extensions-4.5.0:\n",
754
- " Successfully uninstalled typing_extensions-4.5.0\n",
755
- " Attempting uninstall: pydantic\n",
756
- " Found existing installation: pydantic 1.10.13\n",
757
- " Uninstalling pydantic-1.10.13:\n",
758
- " Successfully uninstalled pydantic-1.10.13\n",
759
- "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
760
- "lida 0.0.10 requires kaleido, which is not installed.\n",
761
- "llmx 0.0.15a0 requires cohere, which is not installed.\n",
762
- "llmx 0.0.15a0 requires openai, which is not installed.\n",
763
- "llmx 0.0.15a0 requires tiktoken, which is not installed.\n",
764
- "tensorflow-probability 0.22.0 requires typing-extensions<4.6.0, but you have typing-extensions 4.9.0 which is incompatible.\u001b[0m\u001b[31m\n",
765
- "\u001b[0mSuccessfully installed aiofiles-23.2.1 annotated-types-0.6.0 colorama-0.4.6 fastapi-0.108.0 ffmpy-0.3.1 gradio-4.12.0 gradio-client-0.8.0 h11-0.14.0 httpcore-1.0.2 httpx-0.26.0 orjson-3.9.10 pydantic-2.5.3 pydantic-core-2.14.6 pydub-0.25.1 python-multipart-0.0.6 semantic-version-2.10.0 shellingham-1.5.4 starlette-0.32.0.post1 tomlkit-0.12.0 typing-extensions-4.9.0 uvicorn-0.25.0 websockets-11.0.3\n"
766
- ]
767
- }
768
- ]
769
- },
770
- {
771
- "cell_type": "code",
772
- "source": [
773
- "!pip install --upgrade typing\n",
774
- "\n"
775
- ],
776
- "metadata": {
777
- "colab": {
778
- "base_uri": "https://localhost:8080/",
779
- "height": 324
780
- },
781
- "id": "hkRt-nm-i7n3",
782
- "outputId": "c5674dce-ad3d-4d5b-c6e5-2c6b32b1f8dd"
783
- },
784
- "execution_count": 16,
785
- "outputs": [
786
- {
787
- "output_type": "stream",
788
- "name": "stdout",
789
- "text": [
790
- "Collecting typing\n",
791
- " Downloading typing-3.7.4.3.tar.gz (78 kB)\n",
792
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m78.6/78.6 kB\u001b[0m \u001b[31m1.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
793
- "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
794
- "Building wheels for collected packages: typing\n",
795
- " Building wheel for typing (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
796
- " Created wheel for typing: filename=typing-3.7.4.3-py3-none-any.whl size=26304 sha256=bf404f3c867298c09d5af2c5776ea8cc26cf0f9dd1dddf01a02d6bf8226939a3\n",
797
- " Stored in directory: /root/.cache/pip/wheels/7c/d0/9e/1f26ebb66d9e1732e4098bc5a6c2d91f6c9a529838f0284890\n",
798
- "Successfully built typing\n",
799
- "Installing collected packages: typing\n",
800
- "Successfully installed typing-3.7.4.3\n"
801
- ]
802
- },
803
- {
804
- "output_type": "display_data",
805
- "data": {
806
- "application/vnd.colab-display-data+json": {
807
- "pip_warning": {
808
- "packages": [
809
- "typing"
810
- ]
811
- }
812
- }
813
- },
814
- "metadata": {}
815
- }
816
- ]
817
- },
818
- {
819
- "cell_type": "code",
820
- "source": [
821
- "import gradio as gr\n",
822
- "import skops.io as sio\n",
823
- "\n",
824
- "pipe = sio.load(\"glass_pipeline.skops\", trusted=True)\n",
825
- "\n",
826
- "classes = [\n",
827
- " \"None\",\n",
828
- " \"Building Windows Float Processed\",\n",
829
- " \"Building Windows Non Float Processed\",\n",
830
- " \"Vehicle Windows Float Processed\",\n",
831
- " \"Vehicle Windows Non Float Processed\",\n",
832
- " \"Containers\",\n",
833
- " \"Tableware\",\n",
834
- " \"Headlamps\",\n",
835
- "]\n",
836
- "\n",
837
- "\n",
838
- "def classifier(RI, Na, Mg, Al, Si, K, Ca, Ba, Fe):\n",
839
- " pred_glass = pipe.predict([[RI, Na, Mg, Al, Si, K, Ca, Ba, Fe]])[0]\n",
840
- " label = f\"Predicted Glass label: **{classes[pred_glass]}**\"\n",
841
- " return label\n",
842
- "\n",
843
- "\n",
844
- "inputs = [\n",
845
- " gr.Slider(1.51, 1.54, step=0.01, label=\"Refractive Index\"),\n",
846
- " gr.Slider(10, 17, step=1, label=\"Sodium\"),\n",
847
- " gr.Slider(0, 4.5, step=0.5, label=\"Magnesium\"),\n",
848
- " gr.Slider(0.3, 3.5, step=0.1, label=\"Aluminum\"),\n",
849
- " gr.Slider(69.8, 75.4, step=0.1, label=\"Silicon\"),\n",
850
- " gr.Slider(0, 6.2, step=0.1, label=\"Potassium\"),\n",
851
- " gr.Slider(5.4, 16.19, step=0.1, label=\"Calcium\"),\n",
852
- " gr.Slider(0, 3, step=0.1, label=\"Barium\"),\n",
853
- " gr.Slider(0, 0.5, step=0.1, label=\"Iron\"),\n",
854
- "]\n",
855
- "outputs = [gr.Label(num_top_classes=7)]\n",
856
- "\n",
857
- "title = \"Glass Classification\"\n",
858
- "description = \"Enter the details to correctly identify glass type?\"\n",
859
- "\n",
860
- "gr.Interface(\n",
861
- " fn=classifier,\n",
862
- " inputs=inputs,\n",
863
- " outputs=outputs,\n",
864
- " title=title,\n",
865
- " description=description,\n",
866
- ").launch()"
867
- ],
868
- "metadata": {
869
- "colab": {
870
- "base_uri": "https://localhost:8080/",
871
- "height": 1000
872
- },
873
- "id": "A8KXp_EFiS1U",
874
- "outputId": "c021cdbf-b938-4951-f5e7-8bc0988e9d8a"
875
- },
876
- "execution_count": 1,
877
- "outputs": [
878
- {
879
- "output_type": "stream",
880
- "name": "stderr",
881
- "text": [
882
- "Exception in thread Thread-5 (attachment_entry):\n",
883
- "Traceback (most recent call last):\n",
884
- " File \"/usr/local/lib/python3.10/dist-packages/debugpy/server/api.py\", line 237, in listen\n",
885
- " sock, _ = endpoints_listener.accept()\n",
886
- " File \"/usr/lib/python3.10/socket.py\", line 293, in accept\n",
887
- " fd, addr = self._accept()\n",
888
- "TimeoutError: timed out\n",
889
- "\n",
890
- "During handling of the above exception, another exception occurred:\n",
891
- "\n",
892
- "Traceback (most recent call last):\n",
893
- " File \"/usr/lib/python3.10/threading.py\", line 1016, in _bootstrap_inner\n",
894
- " self.run()\n",
895
- " File \"/usr/lib/python3.10/threading.py\", line 953, in run\n",
896
- " self._target(*self._args, **self._kwargs)\n",
897
- " File \"/usr/local/lib/python3.10/dist-packages/google/colab/_debugpy.py\", line 52, in attachment_entry\n",
898
- " debugpy.listen(_dap_port)\n",
899
- " File \"/usr/local/lib/python3.10/dist-packages/debugpy/public_api.py\", line 31, in wrapper\n",
900
- " return wrapped(*args, **kwargs)\n",
901
- " File \"/usr/local/lib/python3.10/dist-packages/debugpy/server/api.py\", line 143, in debug\n",
902
- " log.reraise_exception(\"{0}() failed:\", func.__name__, level=\"info\")\n",
903
- " File \"/usr/local/lib/python3.10/dist-packages/debugpy/server/api.py\", line 141, in debug\n",
904
- " return func(address, settrace_kwargs, **kwargs)\n",
905
- " File \"/usr/local/lib/python3.10/dist-packages/debugpy/server/api.py\", line 251, in listen\n",
906
- " raise RuntimeError(\"timed out waiting for adapter to connect\")\n",
907
- "RuntimeError: timed out waiting for adapter to connect\n"
908
- ]
909
- },
910
- {
911
- "output_type": "stream",
912
- "name": "stdout",
913
- "text": [
914
- "Setting queue=True in a Colab notebook requires sharing enabled. Setting `share=True` (you can turn this off by setting `share=False` in `launch()` explicitly).\n",
915
- "\n",
916
- "Colab notebook detected. To show errors in colab notebook, set debug=True in launch()\n",
917
- "Running on public URL: https://efa6ecf31e4b5a440c.gradio.live\n",
918
- "\n",
919
- "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
920
- ]
921
- },
922
- {
923
- "output_type": "display_data",
924
- "data": {
925
- "text/plain": [
926
- "<IPython.core.display.HTML object>"
927
- ],
928
- "text/html": [
929
- "<div><iframe src=\"https://efa6ecf31e4b5a440c.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
930
- ]
931
- },
932
- "metadata": {}
933
- },
934
- {
935
- "output_type": "execute_result",
936
- "data": {
937
- "text/plain": []
938
- },
939
- "metadata": {},
940
- "execution_count": 1
941
- }
942
- ]
943
- }
944
- ],
945
- "metadata": {
946
- "colab": {
947
- "provenance": []
948
- },
949
- "kernelspec": {
950
- "display_name": "Python 3",
951
- "name": "python3"
952
- }
953
- },
954
- "nbformat": 4,
955
- "nbformat_minor": 0
956
- }