Vertex AI Loan Risk Prediction Workflow
This guide explains how to create and deploy a machine learning model in Google Cloud’s Vertex AI to predict the risk of loan defaults.
Task 1: Prepare the Training Data
Create a Dataset
- Go to Vertex AI > Datasets in the Google Cloud Console.
- Click Create dataset, name it
LoanRisk
. - Select Tabular and choose Regression/Classification.
Upload Data
- Choose CSV from Cloud Storage.
- Enter the file path:
spls/cbl455/loan_risk.csv
.
Generate Statistics (Optional)
Click Generate statistics to view summary metrics and visualizations for each column.
Task 2: Train the Model
Model Setup
- Click Train new model > Other.
- Select Classification as the objective.
- Name the model
LoanRisk
and set Default as the target column.
Feature Selection
Exclude non-relevant fields such as ClientID
from the model training.
Training Configuration
- Set training budget to 1 node hour.
- Keep Early stopping enabled.
Task 3: Evaluate Model Performance
Precision/Recall Curve
Adjust the confidence threshold to analyze trade-offs between precision and recall.
Confusion Matrix
Displays how accurately the model classified repay and default instances.
Feature Importance
Visualizes the impact of each feature on the model’s predictions. Helps refine the model by identifying key predictors.
Task 4: Deploy the Model
Deployment Steps
- Click Deploy to Endpoint.
- Name the endpoint
LoanRisk
and select an appropriate machine type (e.g.,e2-standard-8
). - Enable Feature attribution under Explainability options.
- Assign the training dataset and target column (
Default
). - Click Deploy to create the endpoint.
Task 5: Get Predictions
Environment Setup
Set environment variables for input file, project number, and AutoML service endpoint in Cloud Shell.
Send Prediction Request
Use curl
to send a POST request with a JSON payload containing fields like age
, income
, and loan
. The response includes prediction scores for each class (repay or default).
Sample Output
The response shows confidence scores for each class and includes the model ID and display name.
This completes the end-to-end process of preparing data, training, evaluating, deploying, and making predictions with Vertex AI.