An open API service indexing awesome lists of open source software.

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.

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. ๐Ÿš€