3

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.

3 Answers 3

1

As Guy suggested, use AWS SDKs to invoke Sagemaker endpoint and retrieve predictions.

To test using Postman, you can follow these steps:

  1. In 'Authorization' tab, select type as 'AWS Signature'.
  2. Enter your Access and Secret key of the IAM user which has permission to Sagemaker resources.
  3. Enter the AWS region. eg.us-east-1
  4. Enter 'Service Name' as 'sagemaker'
  5. Select the right content type. Some ML algorithms only accept 'text/csv'.
  6. Select request type as 'POST'
  7. Enter the Sagemaker Invocation url. eg:'https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/xgboost-xxxx-xx-xx-xx-xx-xx-xxx/invocations'

Here is how your Postman should look - Sagemaker endpoint request - Postman Screenshot

Sign up to request clarification or add additional context in comments.

1 Comment

If it's possible to invoke an AWS SageMaker endpoint via Postman, it suggests that the AWS SDK is not needed, and that we should be able to call these endpoints using the usual cleint-side fetch API, which would be much easier. A fetch example invoking a SageMaker endpoint would be much appreciated.
0

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.

Comments

0

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);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.