Skip to content

Commit 700a18f

Browse files
committed
changed save modle tutorial
1 parent 1e6d9f4 commit 700a18f

File tree

3 files changed

+47
-56
lines changed

3 files changed

+47
-56
lines changed

ML/4_save_model/4_save_and_load_model_using_pickle.ipynb

Lines changed: 47 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 51,
13-
"metadata": {
14-
"collapsed": true
15-
},
12+
"execution_count": 1,
13+
"metadata": {},
1614
"outputs": [],
1715
"source": [
1816
"import pandas as pd\n",
@@ -22,7 +20,7 @@
2220
},
2321
{
2422
"cell_type": "code",
25-
"execution_count": 52,
23+
"execution_count": 2,
2624
"metadata": {},
2725
"outputs": [
2826
{
@@ -89,7 +87,7 @@
8987
"4 4000 725000"
9088
]
9189
},
92-
"execution_count": 52,
90+
"execution_count": 2,
9391
"metadata": {},
9492
"output_type": "execute_result"
9593
}
@@ -101,16 +99,17 @@
10199
},
102100
{
103101
"cell_type": "code",
104-
"execution_count": 62,
102+
"execution_count": 3,
105103
"metadata": {},
106104
"outputs": [
107105
{
108106
"data": {
109107
"text/plain": [
110-
"LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)"
108+
"LinearRegression(copy_X=True, fit_intercept=True, n_jobs=None,\n",
109+
" normalize=False)"
111110
]
112111
},
113-
"execution_count": 62,
112+
"execution_count": 3,
114113
"metadata": {},
115114
"output_type": "execute_result"
116115
}
@@ -122,16 +121,16 @@
122121
},
123122
{
124123
"cell_type": "code",
125-
"execution_count": 63,
124+
"execution_count": 4,
126125
"metadata": {},
127126
"outputs": [
128127
{
129128
"data": {
130129
"text/plain": [
131-
"array([ 135.78767123])"
130+
"array([135.78767123])"
132131
]
133132
},
134-
"execution_count": 63,
133+
"execution_count": 4,
135134
"metadata": {},
136135
"output_type": "execute_result"
137136
}
@@ -142,7 +141,7 @@
142141
},
143142
{
144143
"cell_type": "code",
145-
"execution_count": 64,
144+
"execution_count": 5,
146145
"metadata": {},
147146
"outputs": [
148147
{
@@ -151,7 +150,7 @@
151150
"180616.43835616432"
152151
]
153152
},
154-
"execution_count": 64,
153+
"execution_count": 5,
155154
"metadata": {},
156155
"output_type": "execute_result"
157156
}
@@ -162,22 +161,22 @@
162161
},
163162
{
164163
"cell_type": "code",
165-
"execution_count": 65,
164+
"execution_count": 7,
166165
"metadata": {},
167166
"outputs": [
168167
{
169168
"data": {
170169
"text/plain": [
171-
"array([ 859554.79452055])"
170+
"array([859554.79452055])"
172171
]
173172
},
174-
"execution_count": 65,
173+
"execution_count": 7,
175174
"metadata": {},
176175
"output_type": "execute_result"
177176
}
178177
],
179178
"source": [
180-
"model.predict(5000)"
179+
"model.predict([[5000]])"
181180
]
182181
},
183182
{
@@ -189,18 +188,16 @@
189188
},
190189
{
191190
"cell_type": "code",
192-
"execution_count": 34,
193-
"metadata": {
194-
"collapsed": true
195-
},
191+
"execution_count": 8,
192+
"metadata": {},
196193
"outputs": [],
197194
"source": [
198195
"import pickle"
199196
]
200197
},
201198
{
202199
"cell_type": "code",
203-
"execution_count": 66,
200+
"execution_count": 9,
204201
"metadata": {},
205202
"outputs": [],
206203
"source": [
@@ -217,10 +214,8 @@
217214
},
218215
{
219216
"cell_type": "code",
220-
"execution_count": 74,
221-
"metadata": {
222-
"collapsed": true
223-
},
217+
"execution_count": 10,
218+
"metadata": {},
224219
"outputs": [],
225220
"source": [
226221
"with open('model_pickle','rb') as file:\n",
@@ -229,16 +224,16 @@
229224
},
230225
{
231226
"cell_type": "code",
232-
"execution_count": 75,
227+
"execution_count": 11,
233228
"metadata": {},
234229
"outputs": [
235230
{
236231
"data": {
237232
"text/plain": [
238-
"array([ 135.78767123])"
233+
"array([135.78767123])"
239234
]
240235
},
241-
"execution_count": 75,
236+
"execution_count": 11,
242237
"metadata": {},
243238
"output_type": "execute_result"
244239
}
@@ -249,7 +244,7 @@
249244
},
250245
{
251246
"cell_type": "code",
252-
"execution_count": 76,
247+
"execution_count": 12,
253248
"metadata": {
254249
"scrolled": true
255250
},
@@ -260,7 +255,7 @@
260255
"180616.43835616432"
261256
]
262257
},
263-
"execution_count": 76,
258+
"execution_count": 12,
264259
"metadata": {},
265260
"output_type": "execute_result"
266261
}
@@ -271,22 +266,22 @@
271266
},
272267
{
273268
"cell_type": "code",
274-
"execution_count": 77,
269+
"execution_count": 13,
275270
"metadata": {},
276271
"outputs": [
277272
{
278273
"data": {
279274
"text/plain": [
280-
"array([ 859554.79452055])"
275+
"array([859554.79452055])"
281276
]
282277
},
283-
"execution_count": 77,
278+
"execution_count": 13,
284279
"metadata": {},
285280
"output_type": "execute_result"
286281
}
287282
],
288283
"source": [
289-
"mp.predict(5000)"
284+
"mp.predict([[5000]])"
290285
]
291286
},
292287
{
@@ -298,18 +293,16 @@
298293
},
299294
{
300295
"cell_type": "code",
301-
"execution_count": 44,
302-
"metadata": {
303-
"collapsed": true
304-
},
296+
"execution_count": 14,
297+
"metadata": {},
305298
"outputs": [],
306299
"source": [
307300
"from sklearn.externals import joblib"
308301
]
309302
},
310303
{
311304
"cell_type": "code",
312-
"execution_count": 67,
305+
"execution_count": 15,
313306
"metadata": {},
314307
"outputs": [
315308
{
@@ -318,7 +311,7 @@
318311
"['model_joblib']"
319312
]
320313
},
321-
"execution_count": 67,
314+
"execution_count": 15,
322315
"metadata": {},
323316
"output_type": "execute_result"
324317
}
@@ -336,27 +329,25 @@
336329
},
337330
{
338331
"cell_type": "code",
339-
"execution_count": 70,
340-
"metadata": {
341-
"collapsed": true
342-
},
332+
"execution_count": 16,
333+
"metadata": {},
343334
"outputs": [],
344335
"source": [
345336
"mj = joblib.load('model_joblib')"
346337
]
347338
},
348339
{
349340
"cell_type": "code",
350-
"execution_count": 71,
341+
"execution_count": 17,
351342
"metadata": {},
352343
"outputs": [
353344
{
354345
"data": {
355346
"text/plain": [
356-
"array([ 135.78767123])"
347+
"array([135.78767123])"
357348
]
358349
},
359-
"execution_count": 71,
350+
"execution_count": 17,
360351
"metadata": {},
361352
"output_type": "execute_result"
362353
}
@@ -367,7 +358,7 @@
367358
},
368359
{
369360
"cell_type": "code",
370-
"execution_count": 72,
361+
"execution_count": 18,
371362
"metadata": {
372363
"scrolled": true
373364
},
@@ -378,7 +369,7 @@
378369
"180616.43835616432"
379370
]
380371
},
381-
"execution_count": 72,
372+
"execution_count": 18,
382373
"metadata": {},
383374
"output_type": "execute_result"
384375
}
@@ -389,22 +380,22 @@
389380
},
390381
{
391382
"cell_type": "code",
392-
"execution_count": 73,
383+
"execution_count": 19,
393384
"metadata": {},
394385
"outputs": [
395386
{
396387
"data": {
397388
"text/plain": [
398-
"array([ 859554.79452055])"
389+
"array([859554.79452055])"
399390
]
400391
},
401-
"execution_count": 73,
392+
"execution_count": 19,
402393
"metadata": {},
403394
"output_type": "execute_result"
404395
}
405396
],
406397
"source": [
407-
"mj.predict(5000)"
398+
"mj.predict([[5000]])"
408399
]
409400
}
410401
],
@@ -424,7 +415,7 @@
424415
"name": "python",
425416
"nbconvert_exporter": "python",
426417
"pygments_lexer": "ipython3",
427-
"version": "3.6.1"
418+
"version": "3.7.3"
428419
}
429420
},
430421
"nbformat": 4,

ML/4_save_model/model_joblib

-1 Bytes
Binary file not shown.

ML/4_save_model/model_pickle

-1 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)