This project encompasses a comprehensive analysis of credit risk, including data understanding, exploratory data analysis, feature engineering, and model building. The following tasks were completed:
- Task 1 - Understanding Credit Risk
- Task 2 - Exploratory Data Analysis (EDA)
- Task 3 - Feature Engineering
- Task 3.1 - Default Estimator and WoE Binning
- Task 4 - Modelling
- Task 5 - Model Serving API Call
Objective: Understand the concept of Credit Risk
Key References:
Objective: Analyze and understand the structure and key characteristics of the dataset.
Steps and Findings:
-
Overview of the Data:
- Inspected the number of rows, columns, and data types.
- Dataset contains
nrows andmcolumns.
-
Summary Statistics:
- Calculated mean, median, standard deviation, min, and max for numerical features.
-
Distribution of Numerical Features:
- Visualized using histograms.
- Identified skewness and potential outliers.
-
Distribution of Categorical Features:
- Visualized using bar plots.
- Observed the frequency and variability of categories.
-
Correlation Analysis:
- Generated a correlation matrix.
- Identified strong and weak relationships between numerical features.
-
Identifying Missing Values:
- Checked for missing values.
- Used appropriate imputation strategies to handle missing data.
-
Outlier Detection:
- Used box plots to identify and analyze outliers.
Objective: Create new features and prepare the dataset for modeling.
Steps and Findings:
-
Create Aggregate Features:
- Total Transaction Amount, Average Transaction Amount, Transaction Count, Standard Deviation of Transaction Amounts were calculated for each customer.
-
Extract Features:
- Transaction Hour, Day, Month, and Year were extracted from the transaction timestamp.
-
Encode Categorical Variables:
- Used One-Hot Encoding and Label Encoding to convert categorical values into numerical format.
-
Handle Missing Values:
- Imputed missing values using mean and median imputation.
-
Normalize/Standardize Numerical Features:
- Applied Min-Max Scaling for normalization and StandardScaler for standardization.
-
Weight of Evidence (WoE) Binning:
- Performed WoE binning to transform categorical variables into numerical values with predictive power.
Objective: Construct a default estimator to classify users as high risk or low risk based on RFMS formalism and perform WoE binning.
Steps and Findings:
-
Construct Default Estimator (Proxy):
- Calculated RFMS scores (Recency, Frequency, Monetary) for each customer.
- Established a boundary to classify users into good (high RFMS score) and bad (low RFMS score) categories.
-
Assign Good and Bad Labels:
- Labeled users as good or bad based on the RFMS score boundary.
-
Perform WoE Binning:
- Conducted WoE binning for categorical variables, transforming them into numerical values that hold significant predictive power.
- Results:
- Generated WoE and IV values for each category in
ProductCategory.
- Generated WoE and IV values for each category in
This analysis provided a comprehensive approach to understanding credit risk, preparing data for modeling, and building and evaluating predictive models. The results highlight the effectiveness of the models in classifying users as high or low risk based on their transaction behaviors and other features.
Getting Started Follow the instructions below to set up and run the project on your local machine.
Prerequisites Ensure you have the following installed on your system:
Python 3.x pip virtualenv
Clone the repository
Clone the project repository to your local machine using the following command:
git clone https://github.com/fro-su/Bati_Bank
Install dependencies
Navigate to the project directory and create a virtual environment using virtualenv:
cd Bati-Bank-Credit-Scoring-Model
virtualenv venv
Activate the virtual environment
on Windows .\venv\Scripts\activate
on Mac/Linus source venv/bin/activate
Install dependencies
With the virtual environment activated, install all the required packages from the requirements.txt file:
pip install -r requirements.txt
Run the application
After installing the dependencies, you are all set! Run the application or script as needed.