I have a endpoint up and running in AWS Sagemaker. However, I'm not sure how to send data to this endpoint and get back a prediction.
The documentation is also not clear on this. Any help would be appreciated.
I have a endpoint up and running in AWS Sagemaker. However, I'm not sure how to send data to this endpoint and get back a prediction.
The documentation is also not clear on this. Any help would be appreciated.
As Guy suggested, use AWS SDKs to invoke Sagemaker endpoint and retrieve predictions.
To test using Postman, you can follow these steps:
The way to call the endpoint is through the invoke-endpoint that you can find in Amazon SageMaker runtime API: https://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html
You can use this API through different SDKs, including the CLI, JavaScript, Java, C#, Python and others.
Please note that you have a couple of SDKs versions for Python. One is based on the boto as you can see above, and the other python SDK is more concise and can be used inside of a Jypther notebook. See here for an example: https://docs.aws.amazon.com/sagemaker/latest/dg/tf-example1-invoke.html or https://docs.aws.amazon.com/sagemaker/latest/dg/mxnet-example-invoke.html
The simplest way to invoke the endpoint if you are not integrating it with an existing code in one of the languages above is to call it through a Lambda function. The lambda function should have the IAM permissions to call that specific endpoint, and then you can trigger the Lambda function from various sources such as API-GW, mobile device etc.
I am using Nodejs for invoking the sagemaker endpoint as below:
var AWS = require('aws-sdk');
var sageMakerRuntime = new AWS.SageMakerRuntime({region: 'us-east-1'});
var params = {
Body: new Buffer('{"instances": [1.0,2.0,5.0]}'),
EndpointName: 'EndpointName-XXX'
};
sageMakerRuntime.invokeEndpoint(params, function(err, data) {
responseData = JSON.parse(Buffer.from(data.Body).toString('utf8'))
console.log(responseData);
});