iris_classification_lambda / lambda_function.py
Clement Vachet
Rename lambda file
e9c74b2
raw
history blame
611 Bytes
from classification.classifier import Classifier
import json
cls = Classifier()
def lambda_handler(event, context):
try:
# Parse the input data
data = json.loads(event.get('body', '{}'))
response = cls.load_and_test(data)
return {
'statusCode': 200,
'body': json.dumps({
'predictions': response["predictions"],
'probabilities': response["probabilities"]
})
}
except Exception as e:
return {
'statusCode': 500,
'body': json.dumps({'error': str(e)})
}