This project implements a machine learning system to predict loan approval based on applicant details. It analyzes a dataset of loan applications, performs data cleaning and exploratory data analysis (EDA), and builds classification models to determine whether a loan should be approved or not.
The project uses the loan_approval_data.csv dataset, which contains the following information for 1000 applicants:
- Applicant Details:
Applicant_ID,Age,Gender,Marital_Status,Dependents,Education_Level - Financial Information:
Applicant_Income,Coapplicant_Income,Savings,DTI_Ratio(Debt-to-Income Ratio),Credit_Score - Loan Details:
Loan_Amount,Loan_Term,Loan_Purpose,Existing_Loans,Collateral_Value - Employment:
Employment_Status,Employer_Category - Property:
Property_Area - Target Variable:
Loan_Approved(Yes/No)
To run this project, you need Python installed along with the following libraries:
- pandas
- numpy
- seaborn
- matplotlib
- scikit-learn
You can install these dependencies using pip:
pip install pandas numpy seaborn matplotlib scikit-learnThe main analysis and modeling code is contained in the Jupyter Notebook loan_approver_system.ipynb.
- Clone the repository or download the files.
- Ensure
loan_approval_data.csvis in the same directory as the notebook. - Open the notebook using Jupyter Lab or Jupyter Notebook:
jupyter notebook loan_approver_system.ipynb
- Run the cells sequentially to reproduce the analysis and model training.
The workflow followed in the notebook is as follows:
- Data Loading: The dataset is loaded using Pandas.
- Data Cleaning:
- Missing numerical values are imputed with the mean.
- Missing categorical values are imputed with the most frequent value (mode).
- Exploratory Data Analysis (EDA):
- Analysis of target variable balance.
- Visualizations of categorical features (e.g., Gender, Education Level).
- Distribution plots for numerical features (e.g., Income).
- Correlation heatmap to identify relationships between features.
- Preprocessing:
- Train-test split (80% training, 20% testing).
- Feature scaling using
StandardScaler.
- Model Training & Evaluation:
Three classification models were trained and evaluated:
- Logistic Regression
- K-Nearest Neighbors (KNN)
- Gaussian Naive Bayes
- Feature Engineering:
- New features
DTI_Ratio_sqandCredit_Score_sqwere added to potentially improve model performance. - Models were re-evaluated after feature engineering.
- New features
Based on the evaluation metrics (Precision, Recall, Accuracy, F1-score), Logistic Regression consistently performed the best among the tested models for this dataset.
- Logistic Regression: Achieved high accuracy and a balanced F1-score.
- Gaussian Naive Bayes: Performed reasonably well but slightly lower than Logistic Regression.
- KNN: Generally had lower performance metrics compared to the other two.
The project demonstrates that linear models like Logistic Regression can be quite effective for this type of tabular data, especially after proper preprocessing.