Skip to content

Instantly share code, notes, and snippets.

@mikeapted
Created October 3, 2018 14:42
Show Gist options
  • Select an option

  • Save mikeapted/67a8cbb77eda0d9b55a589bba1ffc5b3 to your computer and use it in GitHub Desktop.

Select an option

Save mikeapted/67a8cbb77eda0d9b55a589bba1ffc5b3 to your computer and use it in GitHub Desktop.

Revisions

  1. mikeapted renamed this gist Oct 3, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. mikeapted created this gist Oct 3, 2018.
    17 changes: 17 additions & 0 deletions lab 3 step 13 #2
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    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'