Skip to content

Abdelrhman941/Deploy-One-Project

Repository files navigation

⇒ Loan Approval Prediction System

Python Version FastAPI MLflow Docker

A production-ready machine learning system that predicts loan approval status using ensemble methods (Random Forest, XGBoost, LightGBM) with MLflow experiment tracking, FastAPI backend, and an interactive web interface.

⇒ Quick Start

- Automated Setup (Recommended)

Run the automated setup script that handles environment creation, dependencies, MLflow, and API:

bash run.sh

This interactive script will:

  1. ✅ Create/activate conda environment
  2. ✅ Install dependencies from requirements.txt
  3. ✅ Start MLflow UI (http://localhost:5000)
  4. ✅ Optionally run model training
  5. ✅ Start FastAPI server (http://localhost:8000)

⇒ Installation

- Method 1️⃣: Local Setup

Step 1: Create Conda Environment

conda create -n deploy python=3.9.23
conda activate deploy

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Start MLflow UI

Open a terminal and run:

mlflow ui

🔗 Access MLflow at: http://127.0.0.1:5000

Step 5: Train Model (Optional)

python src/test_1.py

With custom parameters:

python src/test_1.py -n 300 -xlr 0.05 -llr 0.07

Step 6: Start FastAPI Server

In a new terminal:

conda activate deploy
python src/api_1.py

🔗 API : http://127.0.0.1:8000 🔗 API Doc: http://127.0.0.1:8000/docs

Step 7: Open Frontend

Simply open frontend/index.html in your browser.


- Method 2️⃣: Docker

Step 1: Build Docker Image

docker build -t loan_app .

Step 2: Run Container

docker run -p 8000:8000 -p 5000:5000 loan_app

Exposed Ports:

  • 8000: FastAPI server
  • 5000: MLflow UI (optional)

Step 3: Access Services

Stop & Remove Container

# List running containers
docker ps

# Stop container
docker stop <container_id>

# Remove container
docker rm <container_id>

🗂️ Project Structure

Loan_Approval_Prediction/
├── data/                              # Dataset directory
│   └── loan_approval_dataset.csv
├── frontend/                          # Web interface
│   ├── index.html                     # Main HTML page
│   └── main.js                        # Frontend JavaScript logic
├── notebook/                          # Exploratory analysis
│   └── test1.ipynb                    # EDA & model experimentation
├── output/                            # Generated artifacts
│   ├── best_loan_model.pkl            # Trained model
│   └── model_results.csv              # Model comparison results
├── src/                               # Source code
│   ├── api_1.py                       # FastAPI application
│   └── test_1.py                      # Model training script
├── Dockerfile                         # Docker configuration
├── helperFunction.py                  # Utility functions
├── README.md                          # Project documentation
├── requirements.txt                   # Python dependencies
└── run.sh                             # Automated setup script

⇒ Model Training

Custom Training Parameters

python src/test_1.py -n <n_estimators> -xlr <xgb_learning_rate> -llr <lgbm_learning_rate>

Example:

python src/test_1.py -n 300 -xlr 0.05 -llr 0.07

Tracked Metrics

  • Accuracy (Train & Test)
  • Balanced Accuracy
  • F1 Score (Macro & Micro)
  • ROC-AUC Score
  • Accuracy Gap (overfitting indicator)
  • Training Time
.. This is for DEPI Deployment task ..
THANK YOU FOR VISITING!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages