Credit Risk Prediction Project
1. Project Overview
Objective: Predict whether a loan applicant is a low-risk or high-risk borrower using
historical credit data.
Dataset: German Credit Data (german_credit_data.csv)
Tools & Libraries: Python, Pandas, NumPy, Matplotlib, Seaborn, Scikit-learn, XGBoost,
Streamlit
2. Data Exploration
2.1 Load and Inspect Data
Checked first few rows, column names, data types, and statistical summaries.
2.2 Understanding the Target
Target variable: Risk
Value counts: Good: X%, Bad: Y%
2.3 Checking Data Quality
Missing values: [Link]().sum()
Duplicates: [Link]().sum()
Action Taken: Dropped missing values and reset index.
3. Exploratory Data Analysis (EDA)
3.1 Numerical Features
Columns: Age, Credit amount, Duration
Checked distributions and outliers using histograms and boxplots.
3.2 Categorical Features
Columns: Sex, Job, Housing, Saving accounts, Checking account, Purpose
Countplots and grouped analysis by Risk.
3.3 Correlation Analysis
Checked correlations among numerical features using heatmaps.
3.4 Target vs Features
Boxplots and countplots of features by Risk to observe patterns.
4. Data Preprocessing
Dropped unnecessary columns.
Encoded categorical variables using LabelEncoder.
Saved encoders using joblib for Streamlit app.
5. Model Training
Train-test split: 80% train, 20% test
Models Used: Decision Tree, Random Forest, Extra Trees, XGBoost
6. Model Evaluation
Metrics: Accuracy
Extra Trees Classifier selected as final model.
7. Deployment
Streamlit app created for user input and prediction display.
Inputs: Age, Sex, Job, Housing, Savings, Checking, Credit Amount, Duration
Prediction: Low Risk / High Risk
8. Challenges & Solutions
1. Missing values: Dropped rows with missing values
2. Categorical encoding for Streamlit: Used LabelEncoder
3. Streamlit protobuf error: Correct environment (streamlit_env) used
4. Model selection: Compared multiple models and chose best
9. Key Learnings
- Importance of data cleaning and exploration
- Categorical variables impact on credit risk
- Differences in model performance
- Deployment with Streamlit
10. Next Steps / Improvements
- Use cross-validation metrics for evaluation
- Explore feature engineering for better accuracy
- Add confidence/probability scores in Streamlit
- Handle class imbalance if needed