Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Credit Risk Default Score Prediction Project

Built with the tools and technologies:

JSON scikitlearn tqdm FastAPI NumPy MLflow
Docker Python Plotly pandas YAML



Table of Contents


Overview

Credit Default Prediction β€” A machine learning project that predicts the likelihood of customer loan default to help financial institutions minimize credit risk. Built with Python, Scikit-learn, and Pandas, the model enhances data-driven lending and supports proactive risk mitigation.

Key Features:

Built predictive models using supervised learning algorithms ( - Linear Regression - KNN - Decision Tree - Random Forest - Stacking Regressor (using the above models as base estimators)).

Performed data cleaning, feature engineering, and model evaluation to ensure accuracy and reliability

Generated actionable insights to support data-driven lending decisions and default mitigation strategies

Tools & Technologies: Python, Scikit-learn, Pandas, NumPy, Matplotlib, Jupyter Notebook, Mlflow

Outcome: Improved prediction accuracy of default risk, enabling proactive financial decision-making and efficient credit portfolio management.


Roadmap

  • Task 1: Perform Data ingestion (Ingesting data either from local-csv/database/API).
  • Task 2: Perform Data transformation (train/test split, filling missing values, encoding).
  • Task 3: Train the model (Models training).
  • Task 4: Perform Model evaluation (Evaluate model; metrics = { "r2_score": r2, "rmse": rmse, "mae": mae } Also setup Mlflow for model & parameter tracking ).

Features

❯ πŸ—’οΈπŸ“Œ Key Features Used

Feature Name Description
income Annual income of the applicant
loan_amount Total amount of the requested loan
loan_term Duration of the loan in months
interest_rate Interest rate applied to the loan
debt_to_income_ratio Ratio of total debt to annual income
employment_years Years employed at current job
savings_balance Current savings balance
age Age of the applicant

Project Structure

└── /
    β”œβ”€β”€ .github
    β”‚   └── workflows
    β”œβ”€β”€ api
    β”‚   └── main.py
    β”œβ”€β”€ app.py
    β”œβ”€β”€ artifacts
    β”‚   β”œβ”€β”€ data_ingestion
    β”‚   β”œβ”€β”€ data_transformation
    β”‚   β”œβ”€β”€ model_evaluation
    β”‚   └── model_trainer
    β”œβ”€β”€ config
    β”‚   └── config.yaml
    β”œβ”€β”€ Dockerfile
    β”œβ”€β”€ LICENSE
    β”œβ”€β”€ logs
    β”‚   └── running_logs.log
    β”œβ”€β”€ main.py
    β”œβ”€β”€ notebook
    β”‚   β”œβ”€β”€ data
    β”‚   β”œβ”€β”€ EDA_DEFAULTPRED.ipynb
    β”‚   β”œβ”€β”€ MODEL_TRAINER.ipynb
    β”‚   └── trials.ipynb
    β”œβ”€β”€ params.yaml
    β”œβ”€β”€ README.md
    β”œβ”€β”€ requirements-streamlit.txt
    β”œβ”€β”€ requirements.txt
    β”œβ”€β”€ setup.py
    β”œβ”€β”€ src
    β”‚   β”œβ”€β”€ defaultMlProj
    β”‚   └── defaultMlProj.egg-info
    β”œβ”€β”€ template.py
    └── templates
        └── index.html

Project Index

/
__root__
β¦Ώ __root__
File Name Summary
app.py Code>❯ Setup our frontend with streamlit
Dockerfile Code>❯ Build image for model deployment
LICENSE Code>❯ MIT License
main.py Code>❯ Executes the data stages
params.yaml Code>❯ Holds the model parameters
requirements-streamlit.txt Code>❯ Necessary libraries for running steamlit frontend
requirements.txt Code>❯ Libraries for running the project
setup.py Code>❯ Project setup
template.py Code>❯ Project template file
api
β¦Ώ api
File Name Summary
main.py Code>❯ FASTAPI
config
β¦Ώ config
File Name Summary
config.yaml Code>❯ Configuration file
notebook
β¦Ώ notebook
File Name Summary
EDA_DEFAULTPRED.ipynb Code>❯ Notebook
MODEL_TRAINER.ipynb Code>❯ Model trainer notebook
trials.ipynb Code>❯ Trials notebook
templates
β¦Ώ templates
File Name Summary
index.html Code>❯ HTML file
artifacts
β¦Ώ artifacts
model_evaluation
β¦Ώ artifacts.model_evaluation
File Name Summary
metrics.json Code>❯ Store the model metrics
model_trainer
β¦Ώ artifacts.model_trainer
File Name Summary
model.joblib Code>❯ Store model artifacts
src
β¦Ώ src
defaultMlProj.egg-info
β¦Ώ src.defaultMlProj.egg-info
File Name Summary
dependency_links.txt Code>❯ Project pypi package links
PKG-INFO Code>❯ Project pypi package
SOURCES.txt Code>❯ REPLACE-ME
top_level.txt Code>❯ REPLACE-ME
defaultMlProj
β¦Ώ src.defaultMlProj
components
β¦Ώ src.defaultMlProj.components
File Name Summary
data_ingestion.py Code>❯ Data ingestion file
data_transformation.py Code>❯ Data transformation file
model_evaluation.py Code>❯ Model evaluation file
model_trainer.py Code>❯ Model trainer file
config
β¦Ώ src.defaultMlProj.config
File Name Summary
configuration.py Code>❯ Config file
constants
β¦Ώ src.defaultMlProj.constants
File Name Summary
constant.py Code>❯ Project constants file
entity
β¦Ώ src.defaultMlProj.entity
File Name Summary
config_entity.py Code>❯ Project Config file
pipeline
β¦Ώ src.defaultMlProj.pipeline
File Name Summary
prediction.py Code>❯ Model Prediction file
stage_data_ingestion.py Code>❯ Data ingestion stage file
stage_data_transformation.py Code>❯ Data transformation stage file
stage_model_evaluation.py Code>❯ Model evaluation stage file
stage_model_trainer.py Code>❯ Model tariner stage file
utils
β¦Ώ src.defaultMlProj.utils
File Name Summary
common.py Code>❯ Common functions project file

Getting Started

Prerequisites

This project requires the following dependencies:

  • Programming Language: Python
  • Package Manager: Pip
  • Container Runtime: Docker

Installation

Build from the source and intsall dependencies:

  1. Clone the repository:

    ❯ git clone ../
  2. Navigate to the project directory:

    ❯ cd 
  3. Install the dependencies:

    Using docker:

    ❯ docker build -t / .

    Using pip:

    ❯ pip install -r requirements.txt

Usage

Run the project with:

Using docker:

docker run -it {image_name}

Using pip:

python {entrypoint}

Testing

uses the {test_framework} test framework. Run the test suite with:

Using pip:

pytest

Evaluation Metrics

Each model was evaluated using:

  • Mean Squared Error (MSE)
  • Root Mean Squared Error (RMSE)
  • R-squared (RΒ²) Score

The best performing model selected based on these metrics.

  • βœ… Stacking Regressor

Contributing

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your LOCAL account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone .
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to LOCAL: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph


License

is protected under the LICENSE License. For more details, refer to the LICENSE file.


Acknowledgments

  • Credit contributors, inspiration, references, etc.


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages