Credit Score Prediction

📊 Credit Score Prediction
Project Type: Machine Learning Model | Industry Focus: Finance | Tools Used: Python, Scikit-learn, Pandas, Matplotlib, Seaborn
🔍 Project Overview
Built a supervised learning model to predict individual credit scores—categorized as Poor, Standard, or Good—based on key financial and behavioral indicators. The project aims to support financial institutions in automating credit risk evaluation and improving lending decisions.
🎯 Objectives
- Classify credit scores using supervised machine learning algorithms
- Analyze the relationship between financial behavior and creditworthiness
- Provide a data-driven foundation for credit risk assessment
🧩 Dataset
- Source: Public datasets (Kaggle / UCI repository)
- Features: Age, Income, Loan Amount, Credit Inquiries, Payment History, Credit Utilization, etc.
- Target: Credit Score Category (Poor, Standard, Good)
🛠️ Techniques & Methodology
- Performed exploratory data analysis (EDA) and data cleaning
- Created engineered features like debt-to-income ratio and account age
- Applied models: Logistic Regression, Random Forest, XGBoost
- Evaluated performance using Accuracy, F1-Score, Confusion Matrix, ROC-AUC
🚀 Key Results
- Best model (XGBoost) achieved ~89% accuracy on test data
- Feature importance showed payment history and utilization ratio as top predictors
- Deployed an interactive scoring tool using Streamlit (optional integration)
💼 Business Impact
This model demonstrates how financial service providers can leverage AI to optimize loan approvals, minimize default risk, and offer personalized financial products based on customer credit profiles.
Key Results
Achieved ~89% accuracy with the XGBoost model. Identified that repayment history and credit utilization were the most influential features. Deployed the final model using Streamlit for an interactive credit risk scoring demo.
Code Snippet
import pandas as pd
import numpy as np
import plotly.express as px
from IPython.display import display
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import PowerTransformer,OrdinalEncoder
from imblearn.over_sampling import SMOTE
import re
from sklearn.neighbors import LocalOutlierFactor
from sklearn.impute import SimpleImputer
from sklearn.ensemble import (
BaggingClassifier,ExtraTreesClassifier,
RandomForestClassifier, StackingClassifier,
HistGradientBoostingClassifier)
from xgboost import XGBClassifier
from sklearn.metrics import classification_report,accuracy_score,confusion_matrix, precision_score,recall_score,f1_score,roc_auc_score
import joblib
import warnings
warnings.filterwarnings('ignore')
# Load the dataset
data=pd.read_csv('/content/drive/MyDrive/Colab_Notebooks/Credit Score/train.csv')
data.sample(10)
# Preprocessing
data.select_dtypes(include='object').head()
data['Payment_of_Min_Amount']=data['Payment_of_Min_Amount'].map({'NM':'No',
'No':'No',
'Yes':'Yes'})
data['Payment_of_Min_Amount'].unique()
for i in data.select_dtypes(include='object').columns[:2]:
display(data.groupby('Credit_Score')[i].value_counts().sort_index().unstack().style.background_gradient(cmap='RdBu_r',axis=0))
# Initialize and train the model
bagging = BaggingClassifier(n_jobs=-1)
extraTrees = ExtraTreesClassifier(max_depth=10, n_jobs=-1)
randomForest = RandomForestClassifier(n_jobs=-1)
histGradientBoosting = HistGradientBoostingClassifier()
XGB = XGBClassifier(n_jobs=-1)
model = StackingClassifier([
('bagging', bagging),
('extraTress', extraTrees),
('randomforest', randomForest),
('histGradientBoosting', histGradientBoosting),
('XGB', XGB)
], n_jobs=-1)
model=model.fit(x_train, y_train)
y_pred=model.predict(x_test)
# Evaluate the model
print(f'Accuracy Score: {accuracy_score(y_pred,y_test)}')
precisionscore=precision_score(y_pred,y_test,average='weighted')
f1score=f1_score(y_pred,y_test,average='weighted')
print(f'Precision Score: {precisionscore}')
print(f'f1 Score: {f1score}')



















