def update_result()

in lambda/processor/handler.py [0:0]


def update_result(endpointname: str, record: dict, probabilty: float):
    message_id = str(record["message_id"])
    timestamp = str(record["timestamp"])
    data = record["body"][2:].encode().decode()
    label = int(record["body"][:1])
    prediction = 1 if probabilty >= 0.5 else 0
    score = 1 if label == prediction else 0

    item = {
        "MessageId": {"S": message_id},
        "ModelName": {"S": endpointname},
        "TimeStamp": {"N": timestamp},
        "Data": {"S": data},
        "Label": {"N": str(label)},
        "Prediction": {"N": str(prediction)},
        "Probability": {"N": str(probabilty)},
        "Score": {"S": str(score)},
    }

    ddb.put_item(TableName=RESULT_TABLE_DDB, Item=item)