|
92 | 92 | "import json\n",
|
93 | 93 | "from IPython.display import display\n",
|
94 | 94 | "from time import strftime, gmtime\n",
|
95 |
| - "import sagemaker\n", |
96 |
| - "from sagemaker.predictor import csv_serializer" |
| 95 | + "from sagemaker.inputs import TrainingInput\n", |
| 96 | + "from sagemaker.serializers import CSVSerializer" |
97 | 97 | ]
|
98 | 98 | },
|
99 | 99 | {
|
|
331 | 331 | "metadata": {},
|
332 | 332 | "outputs": [],
|
333 | 333 | "source": [
|
334 |
| - "from sagemaker.amazon.amazon_estimator import get_image_uri\n", |
335 | 334 | "container = sagemaker.image_uris.retrieve('xgboost', boto3.Session().region_name, '1')\n",
|
336 | 335 | "display(container)"
|
337 | 336 | ]
|
|
340 | 339 | "cell_type": "markdown",
|
341 | 340 | "metadata": {},
|
342 | 341 | "source": [
|
343 |
| - "Then, because we're training with the CSV file format, we'll create `s3_input`s that our training function can use as a pointer to the files in S3." |
| 342 | + "Then, because we're training with the CSV file format, we'll create `TrainingInput`s that our training function can use as a pointer to the files in S3." |
344 | 343 | ]
|
345 | 344 | },
|
346 | 345 | {
|
|
349 | 348 | "metadata": {},
|
350 | 349 | "outputs": [],
|
351 | 350 | "source": [
|
352 |
| - "s3_input_train = sagemaker.inputs.TrainingInput(s3_data='s3://{}/{}/train'.format(bucket, prefix), content_type='csv')\n", |
353 |
| - "s3_input_validation = sagemaker.inputs.TrainingInput(s3_data='s3://{}/{}/validation/'.format(bucket, prefix), content_type='csv')" |
| 351 | + "s3_input_train = TrainingInput(s3_data='s3://{}/{}/train'.format(bucket, prefix), content_type='csv')\n", |
| 352 | + "s3_input_validation = TrainingInput(s3_data='s3://{}/{}/validation/'.format(bucket, prefix), content_type='csv')" |
354 | 353 | ]
|
355 | 354 | },
|
356 | 355 | {
|
|
416 | 415 | " framework='xgboost',\n",
|
417 | 416 | " framework_version='latest',\n",
|
418 | 417 | " output_path=output_path)\n",
|
419 |
| - "compiled_model.name = 'deployed-xgboost-customer-churn'\n", |
420 |
| - "compiled_model.image = get_image_uri(sess.boto_region_name, 'xgboost-neo', repo_version='latest')" |
| 418 | + "compiled_model.name = 'deployed-xgboost-customer-churn'" |
421 | 419 | ]
|
422 | 420 | },
|
423 | 421 | {
|
|
439 | 437 | "xgb_predictor = compiled_model.deploy(\n",
|
440 | 438 | " initial_instance_count = 1, \n",
|
441 | 439 | " instance_type = 'ml.m4.xlarge',\n",
|
442 |
| - " serializer=sagemaker.serializers.CSVSerializer())" |
| 440 | + " serializer=CSVSerializer())" |
443 | 441 | ]
|
444 | 442 | },
|
445 | 443 | {
|
|
590 | 588 | "\n",
|
591 | 589 | "costs = np.array(costs)\n",
|
592 | 590 | "plt.plot(cutoffs, costs)\n",
|
593 |
| - "plt.show()\n", |
| 591 | + "plt.show()" |
| 592 | + ] |
| 593 | + }, |
| 594 | + { |
| 595 | + "cell_type": "code", |
| 596 | + "execution_count": null, |
| 597 | + "metadata": {}, |
| 598 | + "outputs": [], |
| 599 | + "source": [ |
594 | 600 | "print('Cost is minimized near a cutoff of:', cutoffs[np.argmin(costs)], 'for a cost of:', np.min(costs))"
|
595 | 601 | ]
|
596 | 602 | },
|
|
651 | 657 | "language": "python",
|
652 | 658 | "name": "conda_python3"
|
653 | 659 | },
|
| 660 | + "language_info": { |
| 661 | + "codemirror_mode": { |
| 662 | + "name": "ipython", |
| 663 | + "version": 3 |
| 664 | + }, |
| 665 | + "file_extension": ".py", |
| 666 | + "mimetype": "text/x-python", |
| 667 | + "name": "python", |
| 668 | + "nbconvert_exporter": "python", |
| 669 | + "pygments_lexer": "ipython3", |
| 670 | + "version": "3.6.10" |
| 671 | + }, |
654 | 672 | "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."
|
655 | 673 | },
|
656 | 674 | "nbformat": 4,
|
|
0 commit comments