Skip to content

Commit 02eea40

Browse files
committed
fixing the environment to conda 3
1 parent 308113d commit 02eea40

File tree

1 file changed

+26
-60
lines changed

1 file changed

+26
-60
lines changed

advanced_functionality/xgboost_bring_your_own_model/xgboost_bring_your_own_model.ipynb

Lines changed: 26 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"cell_type": "code",
4545
"execution_count": null,
4646
"metadata": {
47-
"collapsed": true,
4847
"isConfigCell": true
4948
},
5049
"outputs": [],
@@ -60,7 +59,7 @@
6059
"assumed_role = boto3.client('sts').get_caller_identity()['Arn']\n",
6160
"role = re.sub(r'^(.+)sts::(\\d+):assumed-role/(.+?)/.*$', r'\\1iam::\\2:role/\\3', assumed_role)\n",
6261
"\n",
63-
"bucket='<bucket-name>' # put your s3 bucket name here, and create s3 bucket\n",
62+
"bucket='<s3 bucket>' # put your s3 bucket name here, and create s3 bucket\n",
6463
"prefix = 'sagemaker/xgboost-byo'\n",
6564
"bucket_path = 'https://s3-{}.amazonaws.com/{}'.format(region,bucket)\n",
6665
"# customize to your bucket where you have stored the data"
@@ -81,9 +80,7 @@
8180
{
8281
"cell_type": "code",
8382
"execution_count": null,
84-
"metadata": {
85-
"collapsed": true
86-
},
83+
"metadata": {},
8784
"outputs": [],
8885
"source": [
8986
"!conda install -y -c conda-forge xgboost scikit-learn"
@@ -99,9 +96,7 @@
9996
{
10097
"cell_type": "code",
10198
"execution_count": null,
102-
"metadata": {
103-
"collapsed": true
104-
},
99+
"metadata": {},
105100
"outputs": [],
106101
"source": [
107102
"%%time\n",
@@ -124,9 +119,7 @@
124119
{
125120
"cell_type": "code",
126121
"execution_count": null,
127-
"metadata": {
128-
"collapsed": true
129-
},
122+
"metadata": {},
130123
"outputs": [],
131124
"source": [
132125
"%%time\n",
@@ -147,9 +140,7 @@
147140
{
148141
"cell_type": "code",
149142
"execution_count": null,
150-
"metadata": {
151-
"collapsed": true
152-
},
143+
"metadata": {},
153144
"outputs": [],
154145
"source": [
155146
"train_set, valid_set, test_set = get_dataset()\n",
@@ -174,9 +165,7 @@
174165
{
175166
"cell_type": "code",
176167
"execution_count": null,
177-
"metadata": {
178-
"collapsed": true
179-
},
168+
"metadata": {},
180169
"outputs": [],
181170
"source": [
182171
"import xgboost as xgb\n",
@@ -202,9 +191,7 @@
202191
{
203192
"cell_type": "code",
204193
"execution_count": null,
205-
"metadata": {
206-
"collapsed": true
207-
},
194+
"metadata": {},
208195
"outputs": [],
209196
"source": [
210197
"model_file_name = \"locally-trained-xgboost-model\"\n",
@@ -214,9 +201,7 @@
214201
{
215202
"cell_type": "code",
216203
"execution_count": null,
217-
"metadata": {
218-
"collapsed": true
219-
},
204+
"metadata": {},
220205
"outputs": [],
221206
"source": [
222207
"!tar czvf model.tar.gz $model_file_name"
@@ -232,9 +217,7 @@
232217
{
233218
"cell_type": "code",
234219
"execution_count": null,
235-
"metadata": {
236-
"collapsed": true
237-
},
220+
"metadata": {},
238221
"outputs": [],
239222
"source": [
240223
"fObj = open(\"model.tar.gz\", 'rb')\n",
@@ -255,9 +238,7 @@
255238
{
256239
"cell_type": "code",
257240
"execution_count": null,
258-
"metadata": {
259-
"collapsed": true
260-
},
241+
"metadata": {},
261242
"outputs": [],
262243
"source": [
263244
"containers = {'us-west-2': '433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest',\n",
@@ -270,9 +251,7 @@
270251
{
271252
"cell_type": "code",
272253
"execution_count": null,
273-
"metadata": {
274-
"collapsed": true
275-
},
254+
"metadata": {},
276255
"outputs": [],
277256
"source": [
278257
"%%time\n",
@@ -309,9 +288,7 @@
309288
{
310289
"cell_type": "code",
311290
"execution_count": null,
312-
"metadata": {
313-
"collapsed": true
314-
},
291+
"metadata": {},
315292
"outputs": [],
316293
"source": [
317294
"from time import gmtime, strftime\n",
@@ -341,9 +318,7 @@
341318
{
342319
"cell_type": "code",
343320
"execution_count": null,
344-
"metadata": {
345-
"collapsed": true
346-
},
321+
"metadata": {},
347322
"outputs": [],
348323
"source": [
349324
"%%time\n",
@@ -381,9 +356,7 @@
381356
{
382357
"cell_type": "code",
383358
"execution_count": null,
384-
"metadata": {
385-
"collapsed": true
386-
},
359+
"metadata": {},
387360
"outputs": [],
388361
"source": [
389362
"runtime_client = boto3.client('sagemaker-runtime')"
@@ -399,9 +372,7 @@
399372
{
400373
"cell_type": "code",
401374
"execution_count": null,
402-
"metadata": {
403-
"collapsed": true
404-
},
375+
"metadata": {},
405376
"outputs": [],
406377
"source": [
407378
"import numpy as np\n",
@@ -413,9 +384,7 @@
413384
{
414385
"cell_type": "code",
415386
"execution_count": null,
416-
"metadata": {
417-
"collapsed": true
418-
},
387+
"metadata": {},
419388
"outputs": [],
420389
"source": [
421390
"%%time\n",
@@ -445,9 +414,7 @@
445414
{
446415
"cell_type": "code",
447416
"execution_count": null,
448-
"metadata": {
449-
"collapsed": true
450-
},
417+
"metadata": {},
451418
"outputs": [],
452419
"source": [
453420
"arr = result[1:len(result)-1].split(',')\n",
@@ -461,16 +428,15 @@
461428
"cell_type": "markdown",
462429
"metadata": {},
463430
"source": [
464-
"### Delete Endpoint\n",
465-
"Once you are done using the endpoint, you can use the following to delete it. "
431+
"### (Optional) Delete the Endpoint\n",
432+
"\n",
433+
"If you're ready to be done with this notebook, please uncomment the delete_endpoint line in the cell below and then run it. This will remove the hosted endpoint you created and avoid any charges from a stray instance being left on."
466434
]
467435
},
468436
{
469437
"cell_type": "code",
470438
"execution_count": null,
471-
"metadata": {
472-
"collapsed": true
473-
},
439+
"metadata": {},
474440
"outputs": [],
475441
"source": [
476442
"# sm_client.delete_endpoint(EndpointName=endpoint_name)"
@@ -480,21 +446,21 @@
480446
"metadata": {
481447
"anaconda-cloud": {},
482448
"kernelspec": {
483-
"display_name": "Python [conda root]",
449+
"display_name": "Environment (conda_python3)",
484450
"language": "python",
485-
"name": "conda-root-py"
451+
"name": "conda_python3"
486452
},
487453
"language_info": {
488454
"codemirror_mode": {
489455
"name": "ipython",
490-
"version": 2
456+
"version": 3
491457
},
492458
"file_extension": ".py",
493459
"mimetype": "text/x-python",
494460
"name": "python",
495461
"nbconvert_exporter": "python",
496-
"pygments_lexer": "ipython2",
497-
"version": "2.7.12"
462+
"pygments_lexer": "ipython3",
463+
"version": "3.6.3"
498464
},
499465
"notice": "Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."
500466
},

0 commit comments

Comments
 (0)