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