Loan Default Predictor
Predict whether a loan applicant is likely to default on a loan based on personal, financial, and credit attributes.
Classification
AutoML (Azure Machine Learning)
—
Given applicant data, the model predicts:
Azure AutoML trained and selected the best performing algorithm based on metrics like AUC-weighted and accuracy.
—
Used the Azure ML Studio UI to upload a CSV dataset (e.g., `loan_applicants.csv`), containing labeled data with these columns:
["ApplicantID", "Age", "MaritalStatus", "Dependents", "Education", "AnnualIncome", "EmploymentType", "JobSector", "CreditScore", "LoanAmount", "LoanTermMonths", "LoanPurpose", "InterestRate", "PastDefaults", "LatePayments", "BankCustomerYears", "OwnsHome", "LoanDefault"]
Where `LoanDefault` is the target label (0 or 1).
Used the Azure ML Studio UI to:
After training:
Deployed the model from Azure ML Studio:
Access keys from Key Vault (Python):
api_key = secret_client.get_secret("max-ml-key").value url = secret_client.get_secret("max-ml-endpoint").value if not api_key or not url: raise Exception("Missing key or URL from Key Vault")
Sample Prediction Request:
import urllib.request import json data = { "input_data": { "columns": [ "Age", "MaritalStatus", "Dependents", "Education", "AnnualIncome", "EmploymentType", "JobSector", "CreditScore", "LoanAmount", "LoanTermMonths", "LoanPurpose", "InterestRate", "PastDefaults", "LatePayments", "BankCustomerYears", "OwnsHome" ], "index": [0], "data": [[35, "Married", 2, "Graduate", 55000, "Full-time", "Private", 710, 25000, 60, "Home", 5.2, 0, 1, 6, "Yes"]] } } body = json.dumps(data).encode("utf-8") headers = { "Content-Type": "application/json", "Authorization": f"Bearer {api_key}" } req = urllib.request.Request(url, body, headers) try: with urllib.request.urlopen(req) as response: decoded = response.read().decode("utf-8") prediction = json.loads(decoded)[0] if prediction == 0: print("Prediction: Will likely default on loan") elif prediction == 1: print("Prediction: Will likely not default on loan") else: print(f"Unexpected prediction value: {prediction}") except urllib.error.HTTPError as error: print("HTTP error:", error.code) print(error.read().decode())
—
{
"input_data": {
"columns": [
"Age", "MaritalStatus", "Dependents", "Education", "AnnualIncome",
"EmploymentType", "JobSector", "CreditScore", "LoanAmount",
"LoanTermMonths", "LoanPurpose", "InterestRate", "PastDefaults",
"LatePayments", "BankCustomerYears", "OwnsHome"
],
"index": [0],
"data": [[35, "Married", 2, "Graduate", 55000, "Full-time", "Private", 710,
25000, 60, "Home", 5.2, 0, 1, 6, "Yes"]]
}
}
—
The endpoint returns either:
Mapped in your script to readable text: