A tabular classification model that predicts the probability of a credit card holder defaulting on their next month's payment.
Built as part of an end-to-end ML deployment portfolio project.
1import joblib
2import json
3import pandas as pd
4from huggingface_hub import hf_hub_download
5
6# Load model and features
7model_path = hf_hub_download(repo_id="shrey1905/credit-default-model", filename="model.joblib")
8features_path = hf_hub_download(repo_id="shrey1905/credit-default-model", filename="feature_names.json")
9
10model = joblib.load(model_path)
11with open(features_path) as f:
12 feature_names = json.load(f)
13
14# Build input (all unused features set to 0)
15input_dict = {f: 0 for f in feature_names}
16input_dict["limit_bal"] = 50000
17input_dict["age"] = 35
18input_dict["pay_0"] = 0
19input_dict["bill_amt1"] = 5000
20input_dict["pay_amt1"] = 1000
21input_dict["sex:1"] = 1
22input_dict["education:1"] = 1
23input_dict["marriage:1"] = 1
24
25df = pd.DataFrame([input_dict])[feature_names]
26prob = model.predict_proba(df)[0][1]
27print(f"Default probability: {prob:.1%}")
1from xgboost import XGBClassifier
2
3model = XGBClassifier(
4 n_estimators=200,
5 max_depth=4,
6 learning_rate=0.05,
7 eval_metric="logloss",
8 random_state=42
9)