I have implemented machine learning algorithms through sagemaker.
I have installed SDK for .net, and tried by executing below code.
Uri sagemakerEndPointURI = new Uri("https://runtime.sagemaker.us-east-2.amazonaws.com/endpoints/MyEndpointName/invocations");
Amazon.SageMakerRuntime.Model.InvokeEndpointRequest request = new Amazon.SageMakerRuntime.Model.InvokeEndpointRequest();
request.EndpointName = "MyEndpointName";
AmazonSageMakerRuntimeClient aawsClient = new AmazonSageMakerRuntimeClient(myAwsAccessKey,myAwsSecreteKey);
Amazon.SageMakerRuntime.Model.InvokeEndpointResponse resposnse= aawsClient.InvokeEndpoint(request);
By executing this, I am getting validation error as "1 validation error detected: Value at 'body' failed to satisfy constraint: Member must not be null
"
Can anyone guide me on how and what more input data I need to pass to call the given API?
EDIT
Further I'd tried by provinding body parameter which contains a MemoryStream written by a '.gz' or '.pkl' file, and it giving me error as : "Error unmarshalling response back from AWS, HTTP content length exceeded 5246976 bytes."
EDIT 1/23/2018
Further I came up with the error message as
ERROR - model server - 'TypeError' object has no attribute 'message'
Thanks
Later solved it by Encoding.ASCII.GetBytes
as in below code.
byte[] bytes = System.IO.File.ReadAllBytes(@"EXCEL_FILE_PATH");
string listA = "";
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
listA = listA + line + "\n";
}
byte[] bytes = Encoding.ASCII.GetBytes(listA);
request.Body = new MemoryStream(bytes);
InvokeEndpointResponse response = sagemakerRunTimeClient.InvokeEndpoint(request);
string predictions = Encoding.UTF8.GetString(response.Body.ToArray());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With