File size: 656 Bytes
b51f064
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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)
        print("Lambda response: ", response)

        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)})
        }