Spaces:
Sleeping
Sleeping
Create loan_model.py
Browse files- loan_model.py +14 -0
loan_model.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
def predict_default(income, loan_amount, credit_score, employment):
|
| 4 |
+
# Mock risk calculation (replace with real model)
|
| 5 |
+
base_risk = loan_amount / (income * 12) * 0.3
|
| 6 |
+
credit_factor = 1 - (credit_score / 850)
|
| 7 |
+
emp_factor = 1.2 if employment == "Unemployed" else 1.0
|
| 8 |
+
risk = min(0.95, base_risk * credit_factor * emp_factor)
|
| 9 |
+
|
| 10 |
+
return {
|
| 11 |
+
"High Risk": risk,
|
| 12 |
+
"Medium Risk": max(0, (1 - risk) * 0.7),
|
| 13 |
+
"Low Risk": max(0, (1 - risk) * 0.3)
|
| 14 |
+
}
|