Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Code for serverless deployments
def handler(event, context):
# take input pd data frame and return dictionary with classificaiton
input = json.loads(event['body'])['input']
output_response = {"statusCode": 200, "headers": {"Content-Type": "application/json"}}
# Inference
y_pred = iris_model.predict(input)
y_pred = [round(value) for value in y_pred]
prediction_result = {'Species': Species_class_map[y_pred[0]]}
output_response['body'] = json.dumps(prediction_result)
except Exception as e:
output_response["statusCode"] = 500
return output_response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.