chapter eight

8 Serving predictions over the web

 

This chapter covers:

  • How to set up a SageMaker endpoint to serve predictions and decisions over the web
  • How to build and deploy a serverless system to invoke the SageMaker endpoint
  • How to send data to the endpoint and receive back predictions and decisions.

Until now, the machine learning models you built can be used only in SageMaker. If you wanted to provide a prediction or a decision to someone, you would have to submit the query from a Jupyter notebook running in SageMaker and send them the results. This, of course, is not what AWS intended for SageMaker. They intended that your users would be able to access predictions and decisions over the web. In this chapter you’ll enable your users to do just that.

8.1  Serving tweets

In chapter 4, you helped Naomi identify which tweets should be escalated to her support team and which tweets could be handled by an automated bot.

One of the things you didn’t do for Naomi in chapter 4 is provide a way for her to send tweets to the machine learning model and receive back a decision as to whether the tweet should be escalated. In this chapter, you will rectify that.

8.2  Why is serving decisions and predictions over the web so difficult?

8.3  Overview of steps

8.4  The SageMaker endpoint

8.5  Set up the SageMaker endpoint

8.5.1  Uploading the notebook and data for chapter 8

8.5.2  Uploading the data

8.5.3  Running the notebook and creating the endpoint

8.6  Setting up the serverless API endpoint

8.6.1  Setting up your AWS credentials on your AWS account

8.6.2  Setting up your AWS credentials on your local computer

8.6.3  Configure credentials

8.7  Creating the web endpoint

8.7.1  Install Chalice

8.7.2  Create a "Hello World" API

8.7.3  Add the code that serves the Sagemaker endpoint

8.7.4  Configure permissions

8.7.5  Update requirements.txt

8.7.6  Deploy Chalice