Part 3: Real-Time Predictions
In Part 2, we focused on building a model with our data and discussed the evaluation of said model. In today’s post, we are going to show the necessary steps for building an endpoint for this model. An endpoint will allow us to send data to Amazon ML and receive a prediction score back in real-time.
Logging into the Amazon ML service, I see my list of saved objects and I’m going to choose the Cat-Dog Model that I saved from last time. I can choose several options from the model’s summary page, investigate the model evaluation (like we did last time), perform additional evaluations if I have new data, try batch predictions or real-time predictions, and create an endpoint for my model. I’m going to click Create endpoint to enable real-time predictions. I should see the following alert.
I’m okay with these charges, so I’ll proceed and Create the endpoint. After a short waiting period, the endpoint will be ready for traffic. I can now click on Try real-time predictions and send a test data point to the model right from my browser. Here is the page I see when I try real-time predictions.
There is an entry box for each variable in a single observation. I’ll put in something like AA, 35, blonde, 171, and M for person, age, hair, height (cm), and gender respectively. When I click Create prediction, I’ll see the grey box on the side populate with the return payload for this API call, which looks like this for this data.
The predictedScores stanza has “’0’: 0.0996” as a value; this is the rounded value for the score and the raw value of this score. According to the model, this person would receive a dog ad for my sale. In my example, I input all 5 values into the API call, but I didn’t have to. I could’ve had my model make a prediction based on gender and hair color alone. In reality, I wouldn’t manually input these values, I’d have the application that sends ad emails to my customers send an API call to Amazon ML. The endpoint for this API call is on the model summary page in the green box under the Predictions category.
If you’re interested in replicating the work in these three blog posts, I’ve put the sample data in a public S3 bucket here.