blocks-transformer/post_processing.py
admin user 8f303a4993
All checks were successful
Build and Push Docker Image / test (push) Successful in 2m8s
Build and Push Docker Image / build_and_push (push) Successful in 2m13s
Early Term Default/Fraud indicator v1 block
2025-01-21 21:17:40 +00:00

28 lines
1.2 KiB
Python

import logging
import math
# Configure logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s - %(message)s",
)
logger = logging.getLogger(__name__)
def post_processing(value):
try:
part1 = min(value * 100 + 0.00001, 1) * 85
part2 = max(math.log(value * 100 + 0.000001, 2) * 185, 0)
score = round((part1 + part2), 0)
score_threshold = 1230
action = "Application Decline" if score >= score_threshold else "Application Pass"
description = (
f"HD Fraud Score is above the risk threshold {score_threshold}, Recommended action: {action}."
if score >= score_threshold
else f"HD Fraud Score is below the risk threshold {score_threshold}, Recommended action: {action}."
)
# logger.info({'score': score, 'action': action, 'description': description})
return {'score': score, 'action': action, 'description': description}
except Exception as e:
logger.error(f"Error in post_processing: {e}")
return {'score': None, 'action': 'Unknown', 'description': 'Error processing the score'}