Upload files to "/"
All checks were successful
Build and Push Docker Image / test (push) Successful in 1m19s
Build and Push Docker Image / build_and_push (push) Successful in 2m54s

This commit is contained in:
Admin User 2025-06-18 10:15:49 +00:00
parent 46e6bc30ba
commit 295b9d22a7
3 changed files with 26 additions and 27 deletions

View File

@ -16,33 +16,24 @@ logger = logging.getLogger(__name__)
def __main__(application_id: str, creditBureau: dict) -> Dict:
"""
Process a single application record via the scoring pipeline.
Accepts extra keys; only required features are used and others ignored.
Returns:
A dict containing:
- prediction: float
- grade: str
- reason_description: str or None
"""
# whitelist of required feature keys (lowercase)
required_keys = {
'application_id',
'evtg04','eads66','s004s','utlmag02','cv13','rev231','rev14','g106s','ct320',
'mt34s','trv01','g250a','g960s','re36s','rev232','bc102s','utlmag04','re102s',
'agg911','p02h','g051s','g417s','bc20s','rev225','duemag01','fi21s','us21s',
'us34s','at36s','g102s','bkc14','balmag04','bkc323','bkc84','rev202','cta20',
'cta21','agg902','utlmag03','rev84','mt20s','bc21s','st32s','fi34s','rev201',
'bc97a','balmag01','g232s','balmag02','index02','bc28s','at28a','rev322','bkc322',
'g201a','g416s','walshr02','fi35s','rle904','re28s','rev233','rev224','rev252',
'rev253','cv21','rev321','index01','bkc328','br20s','pb34s','g403s','ct319','at28b',
'mnpmag03','utlmag01','bc36s','bkc321','agg908','cv25','bc107s','bkc327','g990s',
'pb28s','g411s','g221d','bc104s','g405s','p02d','ret12','bc98a','trv02','rev54',
'bkc324','s114s','paymnt08','g105s','rev223','rev12','rev13','all231','agg901',
'g408s','rev203','rvlr75','rvlr77','cv17','cta11','g242b'
}
record = extract_model_variables(creditBureau)
if not record:
final_result = {
'application_id': application_id,
'prediction': 0.99,
'grade': 'M14',
'reason_description': "Lack of account information",
}
logger.info(f"final_result (early exit due to missing or empty extracted variables): {final_result}")
return final_result
processed = pre_processing(record)
out = processing(processed)
@ -62,6 +53,7 @@ def __main__(application_id: str, creditBureau: dict) -> Dict:
return final_result
if __name__ == "__main__":
import json, sys
with open(sys.argv[1]) as f:

View File

@ -125,6 +125,8 @@ def safe_get(d, *keys):
def extract_model_variables(creditBureau: dict) -> dict:
if not creditBureau:
return {}
variable_code_map = VARIABLE_TO_CODE_MAP
score_code_map = SCORE_TO_CODE_MAP
# Step 0: Extract application_id
@ -146,7 +148,7 @@ def extract_model_variables(creditBureau: dict) -> dict:
# Step 2: Flatten values
for product in add_ons:
for product in add_ons if isinstance(add_ons, list) else []:
code = product.get("code")
score_model = safe_get(product, "score_model", "scoreModel")

View File

@ -4,7 +4,7 @@ def post_processing(processing_output):
prediction = processing_output["prediction"]
shape_reasoncode = processing_output["shape_reasoncode"]
# grade mapping: [0.00,0.01]→M1, (0.01,0.02]→M2, … cap at M14
# grade mapping:
if prediction < 0:
grade = "M14"
else:
@ -28,21 +28,26 @@ def post_processing(processing_output):
'ct320': lambda x: x <= 3,
'us21s': lambda x: x <= 3,
'utlmag02': lambda x: x > 300,
'trv01': lambda x: x > 3,
'us34s': lambda x: x > 90
# 'trv01': lambda x: x > 3,
'trv01': lambda x: x <= 3,
'us34s': lambda x: x > 90
}
reason_map = {
'evtg04': "System Generated",
'eads66': "System Generated",
's004s': "Length of time on file is too short",
'mt34s': "Too high open mortgage credit utilization recently",
# 'mt34s': "Too high open mortgage credit utilization recently",
'mt34s': "Not enough balance decreases on mortgage trades in the past 12 months",
'ct320': "Insufficient payment activity",
'us21s': "Length of time since most recent installment account has been established is too short",
'utlmag02': "Too high revolving credit utilization over the last 24 months",
# 'utlmag02': "Too high revolving credit utilization over the last 24 months",
'utlmag02': "Revolving account balances are too high in proportion to credit limits over the last 24 months",
'trv01': "Recency of a balance overlimit on a bankcard account",
'us34s': "Too high open unsecured installment credit utilization recently"
# 'us34s': "Too high open unsecured installment credit utilization recently"
'us34s': "Not enough balance decreases on installment trades in the past 12 months"
}
for item in shape_reasoncode:
feat = item["feature"]
@ -56,6 +61,6 @@ def post_processing(processing_output):
return {
"grade": grade,
"reason_description": None
"reason_description": "No suitable Product Offerings found"
}