Loan Interest Rate and Risk Score Comparison Tool

This project provides an interactive tool to compare loan approval decisions, interest rates, and risk scores generated by two entities: Bank (external backend service) and Our System (custom model). The purpose is to evaluate the performance of our loan evaluation algorithm against the bank's criteria and make informed improvements.

Features

  • Comparison of Loan Approval: Displays whether a loan application is approved by both systems.
  • Risk Score Visualization: Compares the risk scores (0–100 scale) generated by the bank and our system.
  • Interest Rate Evaluation: Compares interest rates offered (0–1 scale, converted to percentages for clarity).
  • Dynamic Data Handling: Uses embedded scripts to retrieve real-time values from the backend and update the UI seamlessly. ## Importance of This Project Loan default rates remain a significant challenge for financial institutions. Statistics highlight that approximately 80% of individuals apply for loans without understanding how their creditworthiness and risk are assessed. Furthermore, traditional risk evaluation models can be opaque, leading to frustration among borrowers and inefficiencies for lenders.

Our project aims to address these issues by:

  1. Providing Transparency: By comparing decisions between our system and the bank's backend, we enable users to understand how their risk is calculated and how it influences approval and interest rates.
  2. Improving Accessibility: Offering a side-by-side comparison allows borrowers to see the impact of different risk assessment models.
  3. Driving Innovation: By analyzing discrepancies between our system and the bank's outputs, we aim to refine our algorithms, improve fairness, and reduce default rates.

In an industry where billions of dollars are at stake, having a more accurate and explainable risk assessment model can revolutionize lending practices and promote financial inclusion.

Code Snippets

Script for Backend Data Integration

<script data-bank-risk-score="{{ bank_risk_score }}" data-bank-interest="{{ bank_interest }}">
    const data = document.currentScript.dataset;
    const bankData = {
        loanApproved: true, // Replace with actual backend data
        riskScore: data.bankRiskScore * 100, // Convert to 0–100 scale
        interestRate: data.bankInterest // 0–1 scale
    };

    const ourData = {
        loanApproved: true,
        riskScore: 50, // Example data
        interestRate: 0.05 // Example interest rate
    };
</script>

Random Interest Rate Generator

import random

def generate_interest_rate(loan_amount, seed=42):
    """
    Generates a consistent interest rate based on the loan amount using a random function.
    The random number generation is controlled by a set seed for reproducibility.

    Parameters:
    - loan_amount (float): The amount of the loan for which the interest rate is generated.
    - seed (int): Seed for random number generation.

    Returns:
    - float: Interest rate between 0 and 4%.
    """
    random.seed(seed + loan_amount)  # Seed depends on loan amount
    return round(random.uniform(0, 4), 2)

# Example usage
print(generate_interest_rate(5000))  # Output is consistent for the same loan amount

Problem and Solution

Problem

Our Mean Squared Error (MSE)-based loan risk prediction model tends to predict a constant value (e.g., 0.49) to minimize the loss function, leading to reduced performance and generalization.

Solution

  • Revisit Loss Function: Replace the MSE loss with an alternative like MAE or Huber Loss, which penalizes outliers differently.
  • Add Regularization: Introduce L1 or L2 regularization to prevent overfitting.

- Balance the Dataset: Ensure diverse data distribution to prevent the model from learning a constant output.

Future Plans

  • Optimize model training to handle imbalanced datasets.
  • Improve the UI to provide more intuitive insights into approval and interest rate differences.
  • Explore advanced ML techniques to predict interest rates more accurately.

Built With

Share this project:

Updates