|
44 | 44 | "cell_type": "code",
|
45 | 45 | "execution_count": null,
|
46 | 46 | "metadata": {
|
47 |
| - "collapsed": true, |
48 | 47 | "isConfigCell": true
|
49 | 48 | },
|
50 | 49 | "outputs": [],
|
|
60 | 59 | "assumed_role = boto3.client('sts').get_caller_identity()['Arn']\n",
|
61 | 60 | "role = re.sub(r'^(.+)sts::(\\d+):assumed-role/(.+?)/.*$', r'\\1iam::\\2:role/\\3', assumed_role)\n",
|
62 | 61 | "\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", |
64 | 63 | "prefix = 'sagemaker/xgboost-byo'\n",
|
65 | 64 | "bucket_path = 'https://s3-{}.amazonaws.com/{}'.format(region,bucket)\n",
|
66 | 65 | "# customize to your bucket where you have stored the data"
|
|
81 | 80 | {
|
82 | 81 | "cell_type": "code",
|
83 | 82 | "execution_count": null,
|
84 |
| - "metadata": { |
85 |
| - "collapsed": true |
86 |
| - }, |
| 83 | + "metadata": {}, |
87 | 84 | "outputs": [],
|
88 | 85 | "source": [
|
89 | 86 | "!conda install -y -c conda-forge xgboost scikit-learn"
|
|
99 | 96 | {
|
100 | 97 | "cell_type": "code",
|
101 | 98 | "execution_count": null,
|
102 |
| - "metadata": { |
103 |
| - "collapsed": true |
104 |
| - }, |
| 99 | + "metadata": {}, |
105 | 100 | "outputs": [],
|
106 | 101 | "source": [
|
107 | 102 | "%%time\n",
|
|
124 | 119 | {
|
125 | 120 | "cell_type": "code",
|
126 | 121 | "execution_count": null,
|
127 |
| - "metadata": { |
128 |
| - "collapsed": true |
129 |
| - }, |
| 122 | + "metadata": {}, |
130 | 123 | "outputs": [],
|
131 | 124 | "source": [
|
132 | 125 | "%%time\n",
|
|
147 | 140 | {
|
148 | 141 | "cell_type": "code",
|
149 | 142 | "execution_count": null,
|
150 |
| - "metadata": { |
151 |
| - "collapsed": true |
152 |
| - }, |
| 143 | + "metadata": {}, |
153 | 144 | "outputs": [],
|
154 | 145 | "source": [
|
155 | 146 | "train_set, valid_set, test_set = get_dataset()\n",
|
|
174 | 165 | {
|
175 | 166 | "cell_type": "code",
|
176 | 167 | "execution_count": null,
|
177 |
| - "metadata": { |
178 |
| - "collapsed": true |
179 |
| - }, |
| 168 | + "metadata": {}, |
180 | 169 | "outputs": [],
|
181 | 170 | "source": [
|
182 | 171 | "import xgboost as xgb\n",
|
|
202 | 191 | {
|
203 | 192 | "cell_type": "code",
|
204 | 193 | "execution_count": null,
|
205 |
| - "metadata": { |
206 |
| - "collapsed": true |
207 |
| - }, |
| 194 | + "metadata": {}, |
208 | 195 | "outputs": [],
|
209 | 196 | "source": [
|
210 | 197 | "model_file_name = \"locally-trained-xgboost-model\"\n",
|
|
214 | 201 | {
|
215 | 202 | "cell_type": "code",
|
216 | 203 | "execution_count": null,
|
217 |
| - "metadata": { |
218 |
| - "collapsed": true |
219 |
| - }, |
| 204 | + "metadata": {}, |
220 | 205 | "outputs": [],
|
221 | 206 | "source": [
|
222 | 207 | "!tar czvf model.tar.gz $model_file_name"
|
|
232 | 217 | {
|
233 | 218 | "cell_type": "code",
|
234 | 219 | "execution_count": null,
|
235 |
| - "metadata": { |
236 |
| - "collapsed": true |
237 |
| - }, |
| 220 | + "metadata": {}, |
238 | 221 | "outputs": [],
|
239 | 222 | "source": [
|
240 | 223 | "fObj = open(\"model.tar.gz\", 'rb')\n",
|
|
255 | 238 | {
|
256 | 239 | "cell_type": "code",
|
257 | 240 | "execution_count": null,
|
258 |
| - "metadata": { |
259 |
| - "collapsed": true |
260 |
| - }, |
| 241 | + "metadata": {}, |
261 | 242 | "outputs": [],
|
262 | 243 | "source": [
|
263 | 244 | "containers = {'us-west-2': '433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest',\n",
|
|
270 | 251 | {
|
271 | 252 | "cell_type": "code",
|
272 | 253 | "execution_count": null,
|
273 |
| - "metadata": { |
274 |
| - "collapsed": true |
275 |
| - }, |
| 254 | + "metadata": {}, |
276 | 255 | "outputs": [],
|
277 | 256 | "source": [
|
278 | 257 | "%%time\n",
|
|
309 | 288 | {
|
310 | 289 | "cell_type": "code",
|
311 | 290 | "execution_count": null,
|
312 |
| - "metadata": { |
313 |
| - "collapsed": true |
314 |
| - }, |
| 291 | + "metadata": {}, |
315 | 292 | "outputs": [],
|
316 | 293 | "source": [
|
317 | 294 | "from time import gmtime, strftime\n",
|
|
341 | 318 | {
|
342 | 319 | "cell_type": "code",
|
343 | 320 | "execution_count": null,
|
344 |
| - "metadata": { |
345 |
| - "collapsed": true |
346 |
| - }, |
| 321 | + "metadata": {}, |
347 | 322 | "outputs": [],
|
348 | 323 | "source": [
|
349 | 324 | "%%time\n",
|
|
381 | 356 | {
|
382 | 357 | "cell_type": "code",
|
383 | 358 | "execution_count": null,
|
384 |
| - "metadata": { |
385 |
| - "collapsed": true |
386 |
| - }, |
| 359 | + "metadata": {}, |
387 | 360 | "outputs": [],
|
388 | 361 | "source": [
|
389 | 362 | "runtime_client = boto3.client('sagemaker-runtime')"
|
|
399 | 372 | {
|
400 | 373 | "cell_type": "code",
|
401 | 374 | "execution_count": null,
|
402 |
| - "metadata": { |
403 |
| - "collapsed": true |
404 |
| - }, |
| 375 | + "metadata": {}, |
405 | 376 | "outputs": [],
|
406 | 377 | "source": [
|
407 | 378 | "import numpy as np\n",
|
|
413 | 384 | {
|
414 | 385 | "cell_type": "code",
|
415 | 386 | "execution_count": null,
|
416 |
| - "metadata": { |
417 |
| - "collapsed": true |
418 |
| - }, |
| 387 | + "metadata": {}, |
419 | 388 | "outputs": [],
|
420 | 389 | "source": [
|
421 | 390 | "%%time\n",
|
|
445 | 414 | {
|
446 | 415 | "cell_type": "code",
|
447 | 416 | "execution_count": null,
|
448 |
| - "metadata": { |
449 |
| - "collapsed": true |
450 |
| - }, |
| 417 | + "metadata": {}, |
451 | 418 | "outputs": [],
|
452 | 419 | "source": [
|
453 | 420 | "arr = result[1:len(result)-1].split(',')\n",
|
|
461 | 428 | "cell_type": "markdown",
|
462 | 429 | "metadata": {},
|
463 | 430 | "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." |
466 | 434 | ]
|
467 | 435 | },
|
468 | 436 | {
|
469 | 437 | "cell_type": "code",
|
470 | 438 | "execution_count": null,
|
471 |
| - "metadata": { |
472 |
| - "collapsed": true |
473 |
| - }, |
| 439 | + "metadata": {}, |
474 | 440 | "outputs": [],
|
475 | 441 | "source": [
|
476 | 442 | "# sm_client.delete_endpoint(EndpointName=endpoint_name)"
|
|
480 | 446 | "metadata": {
|
481 | 447 | "anaconda-cloud": {},
|
482 | 448 | "kernelspec": {
|
483 |
| - "display_name": "Python [conda root]", |
| 449 | + "display_name": "Environment (conda_python3)", |
484 | 450 | "language": "python",
|
485 |
| - "name": "conda-root-py" |
| 451 | + "name": "conda_python3" |
486 | 452 | },
|
487 | 453 | "language_info": {
|
488 | 454 | "codemirror_mode": {
|
489 | 455 | "name": "ipython",
|
490 |
| - "version": 2 |
| 456 | + "version": 3 |
491 | 457 | },
|
492 | 458 | "file_extension": ".py",
|
493 | 459 | "mimetype": "text/x-python",
|
494 | 460 | "name": "python",
|
495 | 461 | "nbconvert_exporter": "python",
|
496 |
| - "pygments_lexer": "ipython2", |
497 |
| - "version": "2.7.12" |
| 462 | + "pygments_lexer": "ipython3", |
| 463 | + "version": "3.6.3" |
498 | 464 | },
|
499 | 465 | "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."
|
500 | 466 | },
|
|
0 commit comments