aliosmankaya commited on
Commit
6099f23
·
1 Parent(s): afbe67c

Upload 2 files

Browse files
reg_arr_model_2_dim.ipynb ADDED
@@ -0,0 +1,418 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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[:, :2]\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, 3.3],\n",
64
+ " [6.5, 3. ],\n",
65
+ " [5.6, 2.5],\n",
66
+ " [5.7, 2.8],\n",
67
+ " [6.4, 2.8]]),\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.39289151, 0.42634152, 2.71549092, 1.2516593 , 1.912959 ,\n",
131
+ " 0.47120288, 0.95447788, 1.78644379, 1.86880801, 1.2369423 ,\n",
132
+ " 1.42232551, 0.29317817, 0.47856138, 0.30053667, -0.01943061])"
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., 0., 3., 1., 2., 0., 1., 2., 2., 1., 1., 0., 0.,\n",
154
+ " 0., -0.])"
155
+ ]
156
+ },
157
+ "execution_count": 10,
158
+ "metadata": {},
159
+ "output_type": "execute_result"
160
+ }
161
+ ],
162
+ "source": [
163
+ "y_pred = np.round(y_pred)\n",
164
+ "y_pred"
165
+ ]
166
+ },
167
+ {
168
+ "cell_type": "code",
169
+ "execution_count": 11,
170
+ "id": "ef5d8327-7ee8-43a6-b4f9-0785e8467d23",
171
+ "metadata": {},
172
+ "outputs": [
173
+ {
174
+ "data": {
175
+ "text/plain": [
176
+ "array([1, 0, 2, 1, 1, 0, 1, 2, 1, 1, 2, 0, 0, 0, 0])"
177
+ ]
178
+ },
179
+ "execution_count": 11,
180
+ "metadata": {},
181
+ "output_type": "execute_result"
182
+ }
183
+ ],
184
+ "source": [
185
+ "y_test"
186
+ ]
187
+ },
188
+ {
189
+ "cell_type": "code",
190
+ "execution_count": 12,
191
+ "id": "b28aa4ac-87ab-45a4-b5c8-e7b125895c25",
192
+ "metadata": {},
193
+ "outputs": [
194
+ {
195
+ "data": {
196
+ "text/plain": [
197
+ "0.7333333333333333"
198
+ ]
199
+ },
200
+ "execution_count": 12,
201
+ "metadata": {},
202
+ "output_type": "execute_result"
203
+ }
204
+ ],
205
+ "source": [
206
+ "accuracy_score(y_test, np.round(y_pred))"
207
+ ]
208
+ },
209
+ {
210
+ "cell_type": "code",
211
+ "execution_count": 13,
212
+ "id": "d5cf8629-f623-4a3e-9400-8d7f6215383e",
213
+ "metadata": {},
214
+ "outputs": [],
215
+ "source": [
216
+ "from joblib import dump, load"
217
+ ]
218
+ },
219
+ {
220
+ "cell_type": "code",
221
+ "execution_count": 14,
222
+ "id": "caa6d389-b358-4160-a342-215013c5b2d9",
223
+ "metadata": {},
224
+ "outputs": [
225
+ {
226
+ "data": {
227
+ "text/plain": [
228
+ "['reg_arr_model_2_dim.joblib']"
229
+ ]
230
+ },
231
+ "execution_count": 14,
232
+ "metadata": {},
233
+ "output_type": "execute_result"
234
+ }
235
+ ],
236
+ "source": [
237
+ "dump(model, \"reg_arr_model_2_dim.joblib\")"
238
+ ]
239
+ },
240
+ {
241
+ "cell_type": "code",
242
+ "execution_count": 15,
243
+ "id": "f0804a91-46d4-4cec-bd60-bb5f022443bf",
244
+ "metadata": {},
245
+ "outputs": [],
246
+ "source": [
247
+ "model = load(\"reg_arr_model_2_dim.joblib\")"
248
+ ]
249
+ },
250
+ {
251
+ "cell_type": "code",
252
+ "execution_count": 16,
253
+ "id": "07584f03-f1da-4014-a539-ca0e033a6356",
254
+ "metadata": {},
255
+ "outputs": [
256
+ {
257
+ "data": {
258
+ "text/plain": [
259
+ "array([1.39289151])"
260
+ ]
261
+ },
262
+ "execution_count": 16,
263
+ "metadata": {},
264
+ "output_type": "execute_result"
265
+ }
266
+ ],
267
+ "source": [
268
+ "model.predict(x_test[:1])"
269
+ ]
270
+ },
271
+ {
272
+ "cell_type": "code",
273
+ "execution_count": 17,
274
+ "id": "06cf5cbb-0a96-4501-8fa6-bfc680d8aa20",
275
+ "metadata": {},
276
+ "outputs": [],
277
+ "source": [
278
+ "import skops.hub_utils as hub_utils"
279
+ ]
280
+ },
281
+ {
282
+ "cell_type": "code",
283
+ "execution_count": 18,
284
+ "id": "f4349089-88c9-49d2-8b65-351cabb74fd8",
285
+ "metadata": {},
286
+ "outputs": [
287
+ {
288
+ "data": {
289
+ "text/plain": [
290
+ "array([[6.1, 2.8],\n",
291
+ " [5.7, 3.8],\n",
292
+ " [7.7, 2.6],\n",
293
+ " [6. , 2.9],\n",
294
+ " [6.8, 2.8],\n",
295
+ " [5.4, 3.4],\n",
296
+ " [5.6, 2.9],\n",
297
+ " [6.9, 3.1],\n",
298
+ " [6.2, 2.2],\n",
299
+ " [5.8, 2.7],\n",
300
+ " [6.5, 3.2],\n",
301
+ " [4.8, 3. ],\n",
302
+ " [5.5, 3.5],\n",
303
+ " [4.9, 3.1],\n",
304
+ " [5.1, 3.8]])"
305
+ ]
306
+ },
307
+ "execution_count": 18,
308
+ "metadata": {},
309
+ "output_type": "execute_result"
310
+ }
311
+ ],
312
+ "source": [
313
+ "x_test"
314
+ ]
315
+ },
316
+ {
317
+ "cell_type": "code",
318
+ "execution_count": 19,
319
+ "id": "a4294f1f-5eeb-460f-a872-ba487a229093",
320
+ "metadata": {},
321
+ "outputs": [],
322
+ "source": [
323
+ "!rm -rf /Users/macbookpro/MyProjects/dev/dst\n",
324
+ "!mkdir /Users/macbookpro/MyProjects/dev/dst"
325
+ ]
326
+ },
327
+ {
328
+ "cell_type": "code",
329
+ "execution_count": 20,
330
+ "id": "41a49678-1a01-439d-8f92-29f1884e5f79",
331
+ "metadata": {},
332
+ "outputs": [],
333
+ "source": [
334
+ "hub_utils.init(\n",
335
+ " model=\"/Users/macbookpro/MyProjects/dev/reg_arr_model_2_dim.joblib\",\n",
336
+ " requirements=[\"scikit-learn\", \"numpy\"],\n",
337
+ " dst=\"/Users/macbookpro/MyProjects/dev/dst\",\n",
338
+ " task=\"tabular-classification\",\n",
339
+ " data=x_train[:3]\n",
340
+ ")"
341
+ ]
342
+ },
343
+ {
344
+ "cell_type": "code",
345
+ "execution_count": 21,
346
+ "id": "fe1a1620-66e3-4543-a506-1195ac39831e",
347
+ "metadata": {},
348
+ "outputs": [],
349
+ "source": [
350
+ "from skops.card import metadata_from_config"
351
+ ]
352
+ },
353
+ {
354
+ "cell_type": "code",
355
+ "execution_count": 22,
356
+ "id": "9e0a6d81-e1c4-4a75-b510-772eb44e924d",
357
+ "metadata": {},
358
+ "outputs": [
359
+ {
360
+ "data": {
361
+ "text/plain": [
362
+ "library_name: sklearn\n",
363
+ "tags:\n",
364
+ "- sklearn\n",
365
+ "- skops\n",
366
+ "- tabular-classification\n",
367
+ "widget:\n",
368
+ " structuredData:\n",
369
+ " x0:\n",
370
+ " - 6.3\n",
371
+ " - 6.5\n",
372
+ " - 5.6\n",
373
+ " x1:\n",
374
+ " - 3.3\n",
375
+ " - 3.0\n",
376
+ " - 2.5"
377
+ ]
378
+ },
379
+ "execution_count": 22,
380
+ "metadata": {},
381
+ "output_type": "execute_result"
382
+ }
383
+ ],
384
+ "source": [
385
+ "metadata_from_config(\"/Users/macbookpro/MyProjects/dev/dst/config.json\")"
386
+ ]
387
+ },
388
+ {
389
+ "cell_type": "code",
390
+ "execution_count": null,
391
+ "id": "412fc8e8-ab28-44bf-88be-6cac61c168f1",
392
+ "metadata": {},
393
+ "outputs": [],
394
+ "source": []
395
+ }
396
+ ],
397
+ "metadata": {
398
+ "kernelspec": {
399
+ "display_name": "Python 3 (ipykernel)",
400
+ "language": "python",
401
+ "name": "python3"
402
+ },
403
+ "language_info": {
404
+ "codemirror_mode": {
405
+ "name": "ipython",
406
+ "version": 3
407
+ },
408
+ "file_extension": ".py",
409
+ "mimetype": "text/x-python",
410
+ "name": "python",
411
+ "nbconvert_exporter": "python",
412
+ "pygments_lexer": "ipython3",
413
+ "version": "3.9.15"
414
+ }
415
+ },
416
+ "nbformat": 4,
417
+ "nbformat_minor": 5
418
+ }
reg_arr_model_2_dim.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4e7a1cb4842d9c5bc91edda5df6d25e6713d08abea0cea4ed67a75237bd30bb
3
+ size 568