Skip to content

Commit d8b6ad6

Browse files
authored
Update SageMaker-ModelMonitoring.ipynb to fix Issue #2074 (#2075)
* Update SageMaker-ModelMonitoring.ipynb * Update SageMaker-ModelMonitoring.ipynb * Update SageMaker-ModelMonitoring.ipynb
1 parent 5143be0 commit d8b6ad6

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

sagemaker_model_monitor/introduction/SageMaker-ModelMonitoring.ipynb

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@
126126
"source": [
127127
"from time import gmtime, strftime\n",
128128
"from sagemaker.model import Model\n",
129-
"from sagemaker.amazon.amazon_estimator import get_image_uri\n",
129+
"from sagemaker.image_uris import retrieve\n",
130130
"\n",
131131
"model_name = \"DEMO-xgb-churn-pred-model-monitor-\" + strftime(\"%Y-%m-%d-%H-%M-%S\", gmtime())\n",
132132
"model_url = 'https://{}.s3-{}.amazonaws.com/{}/xgb-churn-prediction-model.tar.gz'.format(bucket, region, prefix)\n",
133-
"image_uri = get_image_uri(boto3.Session().region_name, 'xgboost', '0.90-1')\n",
134133
"\n",
135-
"model = Model(image=image_uri, model_data=model_url, role=role)"
134+
"image_uri = retrieve('xgboost', boto3.Session().region_name, '0.90-1')\n",
135+
"\n",
136+
"model = Model(image_uri=image_uri, model_data=model_url, role=role)"
136137
]
137138
},
138139
{
@@ -177,7 +178,7 @@
177178
"cell_type": "markdown",
178179
"metadata": {},
179180
"source": [
180-
"This step invokes the endpoint with included sample data for about 2 minutes. Data is captured based on the sampling percentage specified and the capture continues until the data capture option is turned off."
181+
"This step invokes the endpoint with included sample data for about 3 minutes. Data is captured based on the sampling percentage specified and the capture continues until the data capture option is turned off."
181182
]
182183
},
183184
{
@@ -186,22 +187,23 @@
186187
"metadata": {},
187188
"outputs": [],
188189
"source": [
189-
"from sagemaker.predictor import RealTimePredictor\n",
190+
"from sagemaker.predictor import Predictor\n",
191+
"from sagemaker.serializers import CSVSerializer\n",
190192
"import time\n",
191193
"\n",
192-
"predictor = RealTimePredictor(endpoint=endpoint_name,content_type='text/csv')\n",
194+
"predictor = Predictor(endpoint_name=endpoint_name, serializer=CSVSerializer())\n",
193195
"\n",
194196
"# get a subset of test data for a quick test\n",
195-
"!head -120 test_data/test-dataset-input-cols.csv > test_data/test_sample.csv\n",
197+
"!head -180 test_data/test-dataset-input-cols.csv > test_data/test_sample.csv\n",
196198
"print(\"Sending test traffic to the endpoint {}. \\nPlease wait...\".format(endpoint_name))\n",
197199
"\n",
198200
"with open('test_data/test_sample.csv', 'r') as f:\n",
199201
" for row in f:\n",
200202
" payload = row.rstrip('\\n')\n",
201203
" response = predictor.predict(data=payload)\n",
202-
" time.sleep(0.5)\n",
204+
" time.sleep(1)\n",
203205
" \n",
204-
"print(\"Done!\") "
206+
"print(\"Done!\")"
205207
]
206208
},
207209
{
@@ -715,6 +717,13 @@
715717
"source": [
716718
"predictor.delete_model()"
717719
]
720+
},
721+
{
722+
"cell_type": "code",
723+
"execution_count": null,
724+
"metadata": {},
725+
"outputs": [],
726+
"source": []
718727
}
719728
],
720729
"metadata": {
@@ -734,7 +743,7 @@
734743
"name": "python",
735744
"nbconvert_exporter": "python",
736745
"pygments_lexer": "ipython3",
737-
"version": "3.6.5"
746+
"version": "3.6.13"
738747
},
739748
"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."
740749
},

0 commit comments

Comments
 (0)