Skip to content

Instantly share code, notes, and snippets.

@mikeapted
Created October 3, 2018 14:42
Show Gist options
  • Save mikeapted/67a8cbb77eda0d9b55a589bba1ffc5b3 to your computer and use it in GitHub Desktop.
Save mikeapted/67a8cbb77eda0d9b55a589bba1ffc5b3 to your computer and use it in GitHub Desktop.
import boto3
import json
def lambda_handler(event, context):
payload = '1,13000 \n 1,20000 \n 2,3500 \n 2,5000 \n 3,3000 \n 3,3300 \n 4,2 \n 4,10'
endpoint_name = 'YourInitials-kmeans-anomalydetection'
runtime = boto3.client('runtime.sagemaker')
response = runtime.invoke_endpoint(EndpointName=endpoint_name,
ContentType='text/csv',
Body=payload)
result = json.loads(response['Body'].read().decode())
for p in result['predictions']:
print (p)
return 'Complete'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment