aliosmankaya commited on
Commit
b0de23a
·
1 Parent(s): 5967a0e

Delete reg_arr_model_1_dim.ipynb

Browse files
Files changed (1) hide show
  1. reg_arr_model_1_dim.ipynb +0 -413
reg_arr_model_1_dim.ipynb DELETED
@@ -1,413 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 1,
6
- "id": "e1bdbd46-1f35-4373-80ec-727f0e26f009",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import numpy as np\n",
11
- "import pandas as pd\n",
12
- "from sklearn.datasets import load_iris\n",
13
- "from sklearn.model_selection import train_test_split\n",
14
- "from sklearn.linear_model import LinearRegression\n",
15
- "from sklearn.metrics import accuracy_score\n",
16
- "\n",
17
- "import warnings\n",
18
- "warnings.filterwarnings(\"ignore\")"
19
- ]
20
- },
21
- {
22
- "cell_type": "code",
23
- "execution_count": 2,
24
- "id": "327dafe0-68d4-4200-a889-b03bc97a1057",
25
- "metadata": {},
26
- "outputs": [],
27
- "source": [
28
- "iris = load_iris()"
29
- ]
30
- },
31
- {
32
- "cell_type": "code",
33
- "execution_count": 3,
34
- "id": "5ced7579-bb9f-4a20-abe2-c0c258ef4073",
35
- "metadata": {},
36
- "outputs": [],
37
- "source": [
38
- "X = iris.data[:, :1]\n",
39
- "y = iris.target"
40
- ]
41
- },
42
- {
43
- "cell_type": "code",
44
- "execution_count": 4,
45
- "id": "50359601-4b0d-4a94-a1c8-44a833b8f4e5",
46
- "metadata": {
47
- "tags": []
48
- },
49
- "outputs": [],
50
- "source": [
51
- "x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)"
52
- ]
53
- },
54
- {
55
- "cell_type": "code",
56
- "execution_count": 5,
57
- "id": "17fc4619-c5c0-4beb-81df-81617b1c7a56",
58
- "metadata": {},
59
- "outputs": [
60
- {
61
- "data": {
62
- "text/plain": [
63
- "(array([[6.3],\n",
64
- " [6.5],\n",
65
- " [5.6],\n",
66
- " [5.7],\n",
67
- " [6.4]]),\n",
68
- " array([1, 2, 1, 1, 2]))"
69
- ]
70
- },
71
- "execution_count": 5,
72
- "metadata": {},
73
- "output_type": "execute_result"
74
- }
75
- ],
76
- "source": [
77
- "x_train[:5], y_train[:5]"
78
- ]
79
- },
80
- {
81
- "cell_type": "code",
82
- "execution_count": 6,
83
- "id": "510d7a07-7746-4305-96d6-a74bc5a7f144",
84
- "metadata": {},
85
- "outputs": [],
86
- "source": [
87
- "model = LinearRegression()"
88
- ]
89
- },
90
- {
91
- "cell_type": "code",
92
- "execution_count": 7,
93
- "id": "733f81f4-fc25-41a2-8c7d-e6e4abd70143",
94
- "metadata": {},
95
- "outputs": [
96
- {
97
- "data": {
98
- "text/plain": [
99
- "LinearRegression()"
100
- ]
101
- },
102
- "execution_count": 7,
103
- "metadata": {},
104
- "output_type": "execute_result"
105
- }
106
- ],
107
- "source": [
108
- "model.fit(x_train, y_train)"
109
- ]
110
- },
111
- {
112
- "cell_type": "code",
113
- "execution_count": 8,
114
- "id": "267ed05e-7285-4873-ae8c-2396f986bf31",
115
- "metadata": {},
116
- "outputs": [],
117
- "source": [
118
- "y_pred = model.predict(x_test)"
119
- ]
120
- },
121
- {
122
- "cell_type": "code",
123
- "execution_count": 9,
124
- "id": "0dd6f9d6-89d4-461f-9110-601d44126512",
125
- "metadata": {},
126
- "outputs": [
127
- {
128
- "data": {
129
- "text/plain": [
130
- "array([1.22816565, 0.91925051, 2.46382623, 1.15093687, 1.76876716,\n",
131
- " 0.68756415, 0.84202172, 1.84599594, 1.30539444, 0.99647929,\n",
132
- " 1.5370808 , 0.22419143, 0.76479293, 0.30142022, 0.45587779])"
133
- ]
134
- },
135
- "execution_count": 9,
136
- "metadata": {},
137
- "output_type": "execute_result"
138
- }
139
- ],
140
- "source": [
141
- "y_pred"
142
- ]
143
- },
144
- {
145
- "cell_type": "code",
146
- "execution_count": 10,
147
- "id": "6a65cd71-b625-4f31-894d-a4d0403fd1b1",
148
- "metadata": {},
149
- "outputs": [
150
- {
151
- "data": {
152
- "text/plain": [
153
- "array([1., 1., 2., 1., 2., 1., 1., 2., 1., 1., 2., 0., 1., 0., 0.])"
154
- ]
155
- },
156
- "execution_count": 10,
157
- "metadata": {},
158
- "output_type": "execute_result"
159
- }
160
- ],
161
- "source": [
162
- "y_pred = np.round(y_pred)\n",
163
- "y_pred"
164
- ]
165
- },
166
- {
167
- "cell_type": "code",
168
- "execution_count": 11,
169
- "id": "ef5d8327-7ee8-43a6-b4f9-0785e8467d23",
170
- "metadata": {},
171
- "outputs": [
172
- {
173
- "data": {
174
- "text/plain": [
175
- "array([1, 0, 2, 1, 1, 0, 1, 2, 1, 1, 2, 0, 0, 0, 0])"
176
- ]
177
- },
178
- "execution_count": 11,
179
- "metadata": {},
180
- "output_type": "execute_result"
181
- }
182
- ],
183
- "source": [
184
- "y_test"
185
- ]
186
- },
187
- {
188
- "cell_type": "code",
189
- "execution_count": 12,
190
- "id": "b28aa4ac-87ab-45a4-b5c8-e7b125895c25",
191
- "metadata": {},
192
- "outputs": [
193
- {
194
- "data": {
195
- "text/plain": [
196
- "0.7333333333333333"
197
- ]
198
- },
199
- "execution_count": 12,
200
- "metadata": {},
201
- "output_type": "execute_result"
202
- }
203
- ],
204
- "source": [
205
- "accuracy_score(y_test, np.round(y_pred))"
206
- ]
207
- },
208
- {
209
- "cell_type": "code",
210
- "execution_count": 13,
211
- "id": "d5cf8629-f623-4a3e-9400-8d7f6215383e",
212
- "metadata": {},
213
- "outputs": [],
214
- "source": [
215
- "from joblib import dump, load"
216
- ]
217
- },
218
- {
219
- "cell_type": "code",
220
- "execution_count": 14,
221
- "id": "caa6d389-b358-4160-a342-215013c5b2d9",
222
- "metadata": {},
223
- "outputs": [
224
- {
225
- "data": {
226
- "text/plain": [
227
- "['reg_arr_model_1_dim.joblib']"
228
- ]
229
- },
230
- "execution_count": 14,
231
- "metadata": {},
232
- "output_type": "execute_result"
233
- }
234
- ],
235
- "source": [
236
- "dump(model, \"reg_arr_model_1_dim.joblib\")"
237
- ]
238
- },
239
- {
240
- "cell_type": "code",
241
- "execution_count": 15,
242
- "id": "f0804a91-46d4-4cec-bd60-bb5f022443bf",
243
- "metadata": {},
244
- "outputs": [],
245
- "source": [
246
- "model = load(\"reg_arr_model_1_dim.joblib\")"
247
- ]
248
- },
249
- {
250
- "cell_type": "code",
251
- "execution_count": 16,
252
- "id": "07584f03-f1da-4014-a539-ca0e033a6356",
253
- "metadata": {},
254
- "outputs": [
255
- {
256
- "data": {
257
- "text/plain": [
258
- "array([1.22816565])"
259
- ]
260
- },
261
- "execution_count": 16,
262
- "metadata": {},
263
- "output_type": "execute_result"
264
- }
265
- ],
266
- "source": [
267
- "model.predict(x_test[:1])"
268
- ]
269
- },
270
- {
271
- "cell_type": "code",
272
- "execution_count": 17,
273
- "id": "06cf5cbb-0a96-4501-8fa6-bfc680d8aa20",
274
- "metadata": {},
275
- "outputs": [],
276
- "source": [
277
- "import skops.hub_utils as hub_utils"
278
- ]
279
- },
280
- {
281
- "cell_type": "code",
282
- "execution_count": 18,
283
- "id": "f4349089-88c9-49d2-8b65-351cabb74fd8",
284
- "metadata": {},
285
- "outputs": [
286
- {
287
- "data": {
288
- "text/plain": [
289
- "array([[6.1],\n",
290
- " [5.7],\n",
291
- " [7.7],\n",
292
- " [6. ],\n",
293
- " [6.8],\n",
294
- " [5.4],\n",
295
- " [5.6],\n",
296
- " [6.9],\n",
297
- " [6.2],\n",
298
- " [5.8],\n",
299
- " [6.5],\n",
300
- " [4.8],\n",
301
- " [5.5],\n",
302
- " [4.9],\n",
303
- " [5.1]])"
304
- ]
305
- },
306
- "execution_count": 18,
307
- "metadata": {},
308
- "output_type": "execute_result"
309
- }
310
- ],
311
- "source": [
312
- "x_test"
313
- ]
314
- },
315
- {
316
- "cell_type": "code",
317
- "execution_count": 19,
318
- "id": "a4294f1f-5eeb-460f-a872-ba487a229093",
319
- "metadata": {},
320
- "outputs": [],
321
- "source": [
322
- "!rm -rf /Users/macbookpro/MyProjects/dev/dst\n",
323
- "!mkdir /Users/macbookpro/MyProjects/dev/dst"
324
- ]
325
- },
326
- {
327
- "cell_type": "code",
328
- "execution_count": 20,
329
- "id": "41a49678-1a01-439d-8f92-29f1884e5f79",
330
- "metadata": {},
331
- "outputs": [],
332
- "source": [
333
- "hub_utils.init(\n",
334
- " model=\"/Users/macbookpro/MyProjects/dev/structured_arr_model.joblib\",\n",
335
- " requirements=[\"scikit-learn\", \"numpy\"],\n",
336
- " dst=\"/Users/macbookpro/MyProjects/dev/dst\",\n",
337
- " task=\"tabular-classification\",\n",
338
- " data=x_train[:3]\n",
339
- ")"
340
- ]
341
- },
342
- {
343
- "cell_type": "code",
344
- "execution_count": 21,
345
- "id": "fe1a1620-66e3-4543-a506-1195ac39831e",
346
- "metadata": {},
347
- "outputs": [],
348
- "source": [
349
- "from skops.card import metadata_from_config"
350
- ]
351
- },
352
- {
353
- "cell_type": "code",
354
- "execution_count": 22,
355
- "id": "9e0a6d81-e1c4-4a75-b510-772eb44e924d",
356
- "metadata": {},
357
- "outputs": [
358
- {
359
- "data": {
360
- "text/plain": [
361
- "library_name: sklearn\n",
362
- "tags:\n",
363
- "- sklearn\n",
364
- "- skops\n",
365
- "- tabular-classification\n",
366
- "widget:\n",
367
- " structuredData:\n",
368
- " x0:\n",
369
- " - 6.3\n",
370
- " - 6.5\n",
371
- " - 5.6"
372
- ]
373
- },
374
- "execution_count": 22,
375
- "metadata": {},
376
- "output_type": "execute_result"
377
- }
378
- ],
379
- "source": [
380
- "metadata_from_config(\"/Users/macbookpro/MyProjects/dev/dst/config.json\")"
381
- ]
382
- },
383
- {
384
- "cell_type": "code",
385
- "execution_count": null,
386
- "id": "412fc8e8-ab28-44bf-88be-6cac61c168f1",
387
- "metadata": {},
388
- "outputs": [],
389
- "source": []
390
- }
391
- ],
392
- "metadata": {
393
- "kernelspec": {
394
- "display_name": "Python 3 (ipykernel)",
395
- "language": "python",
396
- "name": "python3"
397
- },
398
- "language_info": {
399
- "codemirror_mode": {
400
- "name": "ipython",
401
- "version": 3
402
- },
403
- "file_extension": ".py",
404
- "mimetype": "text/x-python",
405
- "name": "python",
406
- "nbconvert_exporter": "python",
407
- "pygments_lexer": "ipython3",
408
- "version": "3.9.15"
409
- }
410
- },
411
- "nbformat": 4,
412
- "nbformat_minor": 5
413
- }