Skip to content

About

Credit Scoring Machine Learning Model built with Python and Scikit-learn

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Credit Scoring Model

A machine learning project that predicts the likelihood of loan default using borrower and loan information.

Project Overview

This project was developed as part of the CodeAlpha Machine Learning Internship.

The goal is to build a machine learning model that analyzes credit-related information and predicts whether a borrower is likely to default on a loan.

The project uses Logistic Regression and compares a standard model with a class-balanced version.

Dataset

The project uses the Credit Risk Dataset, which contains information about borrowers and their loans.

The dataset includes features such as:

  • Person age
  • Person income
  • Home ownership
  • Employment length
  • Loan intent
  • Loan grade
  • Loan amount
  • Loan interest rate
  • Loan percentage of income
  • Previous default history
  • Credit history length

The target variable is:

  • 0 — No default
  • 1 — Default

Technologies Used

  • Python
  • Pandas
  • NumPy
  • Scikit-learn
  • Joblib
  • Matplotlib
  • Seaborn

Machine Learning Process

The project follows these steps:

  1. Load the dataset
  2. Inspect the data
  3. Handle missing values
  4. Remove duplicate records
  5. Separate features and target
  6. Encode categorical variables
  7. Split the dataset into training and testing sets
  8. Scale numerical features
  9. Train Logistic Regression models
  10. Evaluate model performance
  11. Compare baseline and balanced models
  12. Save the trained model
  13. Use the saved model to make new predictions

Models

Model 1 — Baseline Logistic Regression

The baseline model uses standard Logistic Regression without class weighting.

Model 2 — Balanced Logistic Regression

The second model uses:

class_weight="balanced"

This gives additional importance to the default class and helps the model identify more potential default cases.

Model Results

Metric Baseline Model Balanced Model
Accuracy 86.91% 81.46%
Precision 77.33% 55.48%
Recall 56.77% 77.08%
F1-Score 65.47% 64.52%
ROC-AUC 86.79% 86.96%

The two models demonstrate a trade-off between precision, recall, and overall accuracy.

The balanced model detected more of the actual default cases, while the baseline model achieved higher accuracy and precision.

Prediction System

The project includes predict.py, which allows a user to enter borrower information and receive a predicted credit-risk result.

Example:

Probability of default: 31.15%

Prediction: LOWER DEFAULT RISK

The prediction is generated by the trained machine learning model.

Project Structure

CodeAlpha_CreditScoringModel/
│
├── data/
│   └── credit_risk_dataset.csv
│
├── model/
│   └── credit_scoring_model.pkl
│
├── main.py
├── predict.py
├── requirements.txt
└── README.md

How to Run

1. Clone the repository

https://github.com/obinnakelvin-dev/CodeAlpha_CreditScoringModel.git

2. Open the project folder

cd CodeAlpha_CreditScoringModel

3. Install the required libraries

pip install -r requirements.txt

4. Train the models

python main.py

5. Make a prediction

python predict.py

Follow the prompts to enter the borrower's information.

Future Improvements

Possible improvements include:

  • Testing additional machine learning algorithms
  • Hyperparameter tuning
  • Cross-validation
  • Better handling of class imbalance
  • Feature engineering
  • More comprehensive model validation
  • Building a web interface for predictions
  • Deploying the model as a web application

Learning Outcomes

Through this project, I practiced:

  • Data preprocessing
  • Exploratory data analysis
  • Categorical encoding
  • Train/test splitting
  • Feature scaling
  • Logistic Regression
  • Model evaluation
  • Classification metrics
  • Model comparison
  • Model serialization
  • Building a simple prediction system

Author

Amala-Okechi Obinna Kelvin

Computer Engineering Student Machine Learning & Python Learner

About

Credit Scoring Machine Learning Model built with Python and Scikit-learn

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages