https://github.com/allanotieno254/loan-approval-prediction
This project predicts whether a loan application will be approved or rejected based on various applicant details.
https://github.com/allanotieno254/loan-approval-prediction
binary-classification data-preprocessing deep-learning evaluation-metrics feature-engineering normalization tensorflow
Last synced: 2 months ago
JSON representation
This project predicts whether a loan application will be approved or rejected based on various applicant details.
- Host: GitHub
- URL: https://github.com/allanotieno254/loan-approval-prediction
- Owner: AllanOtieno254
- Created: 2025-03-08T05:25:59.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-08T05:45:14.000Z (7 months ago)
- Last Synced: 2025-03-18T16:40:41.257Z (7 months ago)
- Topics: binary-classification, data-preprocessing, deep-learning, evaluation-metrics, feature-engineering, normalization, tensorflow
- Language: Jupyter Notebook
- Homepage: https://colab.research.google.com/drive/1H-3vejDOQpVRp-zj8uKLmvqdt3wPDkQQ?usp=sharing
- Size: 875 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Loan Approval Prediction
## ๐ Project Overview
This project predicts whether a loan application will be approved or rejected based on various applicant details. The dataset includes features such as income, loan amount, credit score, and employment status. A deep learning model is trained using TensorFlow/Keras to classify applications into **Approved** or **Rejected**.## ๐ ๏ธ Technologies Used
- **Python** (pandas, NumPy, TensorFlow, scikit-learn)
- **Machine Learning** (Logistic Regression, Neural Networks)
- **Deep Learning** (Keras Sequential Model)
- **Data Preprocessing** (Feature Encoding, Normalization, Scaling)
- **Jupyter Notebook** for experimentation## ๐ Repository Structure
```
Loan-Approval-Prediction/
โโโ data/
โ โโโ loan_approval.csv # Original dataset
โ โโโ processed_data.csv # Cleaned dataset
โโโ notebooks/
โ โโโ data_preprocessing.ipynb # Data cleaning & preprocessing
โ โโโ model_training.ipynb # Model training & evaluation
โ โโโ model_testing.ipynb # Model testing & validation
โโโ models/
โ โโโ loan_approval_model.h5 # Saved trained model
โ โโโ scaler.pkl # StandardScaler for preprocessing
โโโ scripts/
โ โโโ train_model.py # Script for model training
โ โโโ predict.py # Script for making predictions
โโโ README.md # Project documentation
โโโ requirements.txt # Required Python libraries
โโโ LICENSE # Open-source license
โโโ .gitignore # Ignore unnecessary files
```## ๐ Dataset Description
The dataset consists of financial and personal details of applicants.
| Column | Description |
|---------|----------------------|
| `no_of_dependents` | Number of dependents |
| `income_annum` | Annual income of applicant |
| `loan_amount` | Loan amount requested |
| `loan_term` | Loan repayment term (months) |
| `cibil_score` | Credit score of applicant |
| `residential_assets_value` | Value of residential assets |
| `commercial_assets_value` | Value of commercial assets |
| `luxury_assets_value` | Value of luxury assets |
| `bank_asset_value` | Total assets in bank |
| `education_ Not Graduate` | Education status (binary) |
| `self_employed_ Yes` | Employment type (binary) |
| `loan_status_ Rejected` | Loan rejection status (target) |## ๐๏ธ Data Preprocessing
- **Remove leading/trailing spaces in column names**
- **Convert categorical variables using One-Hot Encoding**
- **Scale numeric features using `StandardScaler`**## ๐ง Model Architecture
```python
model = Sequential([
Dense(32, activation='relu', input_shape=(xtrain.shape[1],)),
Dropout(0.1),
Dense(32, activation='relu'),
Dropout(0.5),
Dense(1, activation='sigmoid')
])
```
- **Loss Function:** Binary Cross-Entropy
- **Optimizer:** Adam
- **Metrics:** Accuracy## ๐ Model Training
```python
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(xtrain, ytrain, epochs=20, batch_size=16, validation_data=(xtest, ytest))
```## ๐งช Model Testing
```python
loss, accuracy = model.evaluate(xtest, ytest)
print(f'Test Loss: {loss:.4f}')
print(f'Test Accuracy: {accuracy:.4f}')
```## ๐ฎ Making Predictions
```python
# New Applicant Data
new_data = np.array([[2, 4100000, 12200000, 8, 417, 2700000, 2200000, 8800000, 3300000, 1, 1]])
new_data_df = pd.DataFrame(new_data, columns=feature_columns)
new_data_scaled = scaler.transform(new_data_df)# Predict Approval/Rejection
prediction = model.predict(new_data_scaled)
predicted_class = (prediction > 0.5).astype(int)[0][0]if predicted_class == 1:
print("Loan Approved โ ")
else:
print("Loan Rejected โ")
```## ๐ Results
The model predicts whether a loan application will be approved or rejected based on the provided applicant details.## ๐ License
This project is licensed under the **MIT License** โ see the [LICENSE](LICENSE) file for details.## ๐ฌ Contact
- **GitHub**: [AllanOtieno254](https://github.com/AllanOtieno254)
- **LinkedIn**: [Allan Otieno Akumu](https://www.linkedin.com/in/allanotienoakumu)---
๐น **Contributions are welcome!** Feel free to fork this repository and improve the model. ๐