|
179 | 179 | "cell_type": "markdown",
|
180 | 180 | "metadata": {},
|
181 | 181 | "source": [
|
182 |
| - "# PART A: Capturing real-time inference data from Amazon SageMaker endpoints\n", |
| 182 | + "## PART A: Capturing real-time inference data from Amazon SageMaker endpoints\n", |
183 | 183 | "Create an endpoint to showcase the data capture capability in action. (In next parts, model monitors will be created to process the data.)\n",
|
184 | 184 | "\n",
|
185 |
| - "## Upload the pre-trained model to Amazon S3\n", |
| 185 | + "### Upload the pre-trained model to Amazon S3\n", |
186 | 186 | "As an example, this code uploads a pre-trained XGBoost model that is ready for to be deployed. This model was trained using the [XGBoost Churn Prediction Notebook](https://github.com/aws/amazon-sagemaker-examples/blob/master/introduction_to_applying_machine_learning/xgboost_customer_churn/xgboost_customer_churn.ipynb) in SageMaker."
|
187 | 187 | ]
|
188 | 188 | },
|
|
200 | 200 | "cell_type": "markdown",
|
201 | 201 | "metadata": {},
|
202 | 202 | "source": [
|
203 |
| - "## Deploy the model to Amazon SageMaker\n", |
| 203 | + "### Deploy the model to Amazon SageMaker\n", |
204 | 204 | "Start with deploying a pre-trained churn prediction model. Here, create the SageMaker `Model` object with the image and model data."
|
205 | 205 | ]
|
206 | 206 | },
|
|
257 | 257 | "cell_type": "markdown",
|
258 | 258 | "metadata": {},
|
259 | 259 | "source": [
|
260 |
| - "## Invoke the deployed model\n", |
| 260 | + "### Invoke the deployed model\n", |
261 | 261 | "\n",
|
262 | 262 | "Now send data to this endpoint to get inferences in real time. Because data capture is enabled in the previous steps, the request and response payload, along with some additional metadata, is saved in the Amazon S3 location specified in the DataCaptureConfig."
|
263 | 263 | ]
|
|
292 | 292 | "cell_type": "markdown",
|
293 | 293 | "metadata": {},
|
294 | 294 | "source": [
|
295 |
| - "## View captured data\n", |
| 295 | + "### View captured data\n", |
296 | 296 | "\n",
|
297 | 297 | "Now list the data capture files stored in Amazon S3. There should be different files from different time periods organized based on the hour in which the invocation occurred. The format of the Amazon S3 path is:\n",
|
298 | 298 | "\n",
|
|
354 | 354 | "cell_type": "markdown",
|
355 | 355 | "metadata": {},
|
356 | 356 | "source": [
|
357 |
| - "## Start generating some artificial traffic\n", |
| 357 | + "### Start generating some artificial traffic\n", |
358 | 358 | "The cell below starts a thread to send some traffic to the endpoint. If there is no traffic, the monitoring jobs are marked as `Failed` since there is no data to process."
|
359 | 359 | ]
|
360 | 360 | },
|
|
421 | 421 | "cell_type": "markdown",
|
422 | 422 | "metadata": {},
|
423 | 423 | "source": [
|
424 |
| - "## Start generating some fake ground truth\n", |
| 424 | + "### Start generating some fake ground truth\n", |
425 | 425 | "\n",
|
426 | 426 | "Besides captures, model bias monitoring execution also requires ground truth data. In real use cases, ground truth data should be regularly collected and uploaded to designated S3 location. In this example notebook, below code snippet is used to generate fake ground truth data. The first-party merge container will combine captures and ground truth data, and the merged data will be passed to model bias monitoring job for analysis. Similar to captures, the model bias monitoring execution will fail if there's no data to merge."
|
427 | 427 | ]
|
|
493 | 493 | "cell_type": "markdown",
|
494 | 494 | "metadata": {},
|
495 | 495 | "source": [
|
496 |
| - "# PART B: Model Bias Monitor" |
| 496 | + "## PART B: Model Bias Monitor" |
497 | 497 | ]
|
498 | 498 | },
|
499 | 499 | {
|
|
521 | 521 | "metadata": {},
|
522 | 522 | "source": [
|
523 | 523 | "\n",
|
524 |
| - "## Create a baselining job\n", |
| 524 | + "### Create a baselining job\n", |
525 | 525 | "\n",
|
526 | 526 | "A baselining job runs predictions on training dataset and suggests constraints. `suggest_baseline()` method starts a `SageMakerClarifyProcessor` processing job using SageMaker Clarify container to generate the constraints.\n",
|
527 | 527 | "\n",
|
|
532 | 532 | "cell_type": "markdown",
|
533 | 533 | "metadata": {},
|
534 | 534 | "source": [
|
535 |
| - "### Configurations\n", |
| 535 | + "#### Configurations\n", |
536 | 536 | "\n",
|
537 | 537 | "Information about the input data need to be provided to the processor."
|
538 | 538 | ]
|
|
624 | 624 | "cell_type": "markdown",
|
625 | 625 | "metadata": {},
|
626 | 626 | "source": [
|
627 |
| - "### Kick off baselining job" |
| 627 | + "#### Kick off baselining job" |
628 | 628 | ]
|
629 | 629 | },
|
630 | 630 | {
|
|
666 | 666 | "cell_type": "markdown",
|
667 | 667 | "metadata": {},
|
668 | 668 | "source": [
|
669 |
| - "## Schedule model bias monitor\n", |
| 669 | + "### Schedule model bias monitor\n", |
670 | 670 | "\n",
|
671 | 671 | "With above constraints collected, now call `create_monitoring_schedule()` method to schedule a hourly monitor, to analyze the data with monitoring schedule. If a baselining job has been submitted, then the monitor will automatically pick up analysis configuration from the baselining job. But if the baselining step is skipped, or the capture dataset has different nature than the training dataset, then analysis configuration has to be provided.\n",
|
672 | 672 | "\n",
|
|
709 | 709 | "cell_type": "markdown",
|
710 | 710 | "metadata": {},
|
711 | 711 | "source": [
|
712 |
| - "## Wait for the first execution\n", |
| 712 | + "### Wait for the first execution\n", |
713 | 713 | "\n",
|
714 | 714 | "The schedule starts jobs at the previously specified intervals. Code below wait util time crosses the hour boundary (in UTC) to see executions kick off.\n",
|
715 | 715 | "\n",
|
|
775 | 775 | "cell_type": "markdown",
|
776 | 776 | "metadata": {},
|
777 | 777 | "source": [
|
778 |
| - "## Wait for the execution to finish\n", |
| 778 | + "### Wait for the execution to finish\n", |
779 | 779 | "\n",
|
780 | 780 | "In the previous cell, the first execution has started. This section waits for the execution to finish so that its analysis results are available. Here are the possible terminal states and what each of them mean:\n",
|
781 | 781 | "\n",
|
|
826 | 826 | "cell_type": "markdown",
|
827 | 827 | "metadata": {},
|
828 | 828 | "source": [
|
829 |
| - "## Inspect execution results\n", |
| 829 | + "### Inspect execution results\n", |
830 | 830 | "\n",
|
831 | 831 | "List the generated reports,"
|
832 | 832 | ]
|
|
890 | 890 | "cell_type": "markdown",
|
891 | 891 | "metadata": {},
|
892 | 892 | "source": [
|
893 |
| - "# PART C: Model Explainability Monitor\n", |
| 893 | + "## PART C: Model Explainability Monitor\n", |
894 | 894 | "\n",
|
895 | 895 | "Model explainability monitor can explain the predictions of a deployed model producing inferences and detect feature attribution drift on a regular basis."
|
896 | 896 | ]
|
|
912 | 912 | "cell_type": "markdown",
|
913 | 913 | "metadata": {},
|
914 | 914 | "source": [
|
915 |
| - "## Create a baselining job\n", |
| 915 | + "### Create a baselining job\n", |
916 | 916 | "\n",
|
917 | 917 | "Similary, a baselining job can be scheduled to suggest constraints for model explainability monitor."
|
918 | 918 | ]
|
|
921 | 921 | "cell_type": "markdown",
|
922 | 922 | "metadata": {},
|
923 | 923 | "source": [
|
924 |
| - "### Configuration" |
| 924 | + "#### Configuration" |
925 | 925 | ]
|
926 | 926 | },
|
927 | 927 | {
|
|
984 | 984 | "cell_type": "markdown",
|
985 | 985 | "metadata": {},
|
986 | 986 | "source": [
|
987 |
| - "### Kick off baselining job\n", |
| 987 | + "#### Kick off baselining job\n", |
988 | 988 | "\n",
|
989 | 989 | "The same model_config is required, because the explainability baselining job needs to create shadow endpoint to get predictions for generated synthetic dataset."
|
990 | 990 | ]
|
|
1031 | 1031 | "cell_type": "markdown",
|
1032 | 1032 | "metadata": {},
|
1033 | 1033 | "source": [
|
1034 |
| - "## Schedule model explainability monitor" |
| 1034 | + "### Schedule model explainability monitor" |
1035 | 1035 | ]
|
1036 | 1036 | },
|
1037 | 1037 | {
|
|
1070 | 1070 | "cell_type": "markdown",
|
1071 | 1071 | "metadata": {},
|
1072 | 1072 | "source": [
|
1073 |
| - "## Wait for execution and inspect analysis results\n", |
| 1073 | + "### Wait for execution and inspect analysis results\n", |
1074 | 1074 | "\n",
|
1075 | 1075 | "Once created the schedule is started by default, here wait for the its first execution to start, then stop the schedule to avoid incurring charges."
|
1076 | 1076 | ]
|
|
1170 | 1170 | "cell_type": "markdown",
|
1171 | 1171 | "metadata": {},
|
1172 | 1172 | "source": [
|
1173 |
| - "# PART D: Cleanup\n", |
| 1173 | + "## PART D: Cleanup\n", |
1174 | 1174 | "\n",
|
1175 | 1175 | "The endpoint can keep running and capturing data, but if there is no plan to collect more data or use this endpoint further, it should be deleted to avoid incurring additional charges. Note that deleting endpoint does not delete the data that was captured during the model invocations."
|
1176 | 1176 | ]
|
|
0 commit comments