Created
June 14, 2018 01:38
-
-
Save shabazpatel/4a7b91cef2bfd2f90c9e536e7500b2c0 to your computer and use it in GitHub Desktop.
Code for serverless deployments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
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"}} | |
try: | |
# 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