The challenge
A credit union receives applications every day and needs to answer one concrete question: would this new application be approved or rejected under the current policy, and which rules are being applied?
The second half of that question matters as much as the first. In a financial institution, a model that’s simply “accurate” isn’t enough: you have to be able to explain each decision to a loan officer, an auditor or the member themselves. That’s why explainability was a requirement from day one, not a nice-to-have.
I worked on it with Vanesa Contreras at the School of Engineering (UNLPam), using a dataset of 962 applications with socioeconomic and credit variables.
What the data told us
Before modeling, we ran an exploratory analysis to understand the typical applicant and which variables drive the decision. (Chart labels are in Spanish, as in the original notebook.)
The typical applicant earns around $780,000 (ARS) and asks for about $1.5 million, almost twice their salary. Both distributions are right-skewed (a few very high values pull the mean up), so we used the median to describe them.
No single numeric variable decides on its own. The strongest correlation is between requested amount and the installment-to-income ratio (r = 0.33): the bigger the loan, the more the installment weighs on the salary. By contrast, what applicants earn and what they borrow are practically unrelated (r = −0.04).
Bigger loans, more rejections. Splitting applications by outcome, the largest amounts cluster on the rejected side (r = −0.27 between amount and approval).
Default history is almost decisive: out of 140 applications from defaulters (“Moroso”), 134 were rejected (96%).
Earning more helps, but it isn’t enough. Approved applicants have a somewhat higher median income (about $840,000 vs. $700,000), but the ranges overlap almost completely: plenty of rejected applicants earn more than many approved ones.
That was the key takeaway for choosing the model: since no variable explains the decision on its own, we needed one that could combine several rules at once.
Cleaning strategy
Two variables had a lot of missing data, and we handled them differently depending on how much they contributed to the problem:
relacion_cuota_ingreso(installment-to-income ratio) → median imputation. About 40% of records were missing, but it’s the variable that best measures ability to pay. Dropping it would have meant losing the most important signal (and, as shown below, it became the tree’s second rule), so we filled the gaps with the median, which is robust to outliers.nro_sucursal(branch number) → dropped. More than 83% of values were missing, and the branch says nothing about a person’s risk. Imputing it would only have added noise.- Records without a date → dropped. These were the only rows we removed; every other risk variable was kept.
Model and results
We framed it as a supervised binary classification problem (approved / rejected) and chose a decision tree (Scikit-Learn’s DecisionTreeClassifier, max depth 5) for two reasons:
- It’s explainable: every prediction reads as a sequence of if… then… rules that anyone in the credit department can understand and challenge, and that make it possible to justify a rejection to the member.
- It doesn’t assume linear relationships, which mattered once the exploratory analysis showed that no variable relates linearly to the decision.
Why prioritize precision? For the credit union, the most expensive mistake is a false positive: approving a loan for someone who then can’t repay it. So we optimized precision for the “Approved” class: when the model says “approve”, we want it to be wrong as rarely as possible, even if that means being more conservative with some borderline cases.
To avoid depending on a single data split, we validated with stratified 5-fold cross-validation (each fold keeps the same approved/rejected ratio). The result: an average precision of 84.82%.
From data to business rules
Reading the tree’s first levels, the credit union’s policy boils down to three rules:
Next steps
- Try different maximum depths (
max_depth) and split criteria to push precision further. - Compare the tree against other models, such as Random Forest, to see whether precision can go up without losing too much explainability.