This project provides a FastAPI-based ML API that serves two predictive models:
-
🧬 Cancer Prediction Models
- Cancer Type Classification
- Severity Score Prediction
-
💰 Loan Status Prediction
All models are trained using Scikit-learn, tracked with MLflow, and deployed through a FastAPI REST API.
You can test and interact with the models easily via Swagger UI at /docs.
Caner_and_loan/
│
├── app.py # Main FastAPI app
├── train.py # Script to train models
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
│
├── models/ # Saved ML models
│ ├── best_cancer_model.pkl
│ ├── best_loan_model.pkl
│ ├── best_severity_model.pkl
│ └── cancer_label_encoder.pkl
│
├── schemas/ # Pydantic schemas (API validation)
│ ├── cancer_schema.py
│ └── loan_schema.py
│
├── utils/ # Helper functions
│ └── model_utils.py
│
├── data/
│ ├── cancer_data.csv
│ └── loan_data.csv
│
└── README.md # This file
conda create -n mlflow_env python=3.10 -y
conda activate mlflow_envor using venv:
python -m venv venv
venv\Scripts\activatepip install -r requirements.txtpython train.py --cancer_csv data/cancer_data.csv --loan_csv data/loan_data.csvThis will save all trained models inside the models/ folder.
uvicorn app:app --reloadThen open your browser at: 👉 http://127.0.0.1:8000/docs
docker build -t mlproject .docker run -d -p 8000:8000 mlprojectVisit: 👉 http://localhost:8000/docs
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Check API status |
/predict_cancer_type |
POST | Predict type of cancer |
/predict_severity |
POST | Predict cancer severity score |
/predict_loan |
POST | Predict loan approval status |
POST /predict_cancer_type
{
"Age": 45,
"Gender": "Female",
"Cancer_Stage": "Stage II",
"Treatment_Cost_USD": 45000,
"Survival_Years": 6
}Response
{
"cancer_type": "Breast Cancer"
}- FastAPI — for serving ML models as REST APIs
- scikit-learn — for model training
- pandas / numpy — for data preprocessing
- joblib — for model persistence
- MLflow — for experiment tracking
- Docker — for containerized deployment
All models achieved >90% accuracy after hyperparameter tuning and feature optimization.
Alaa Taha El Maria 🤖 AI Developer | Machine Learning Enthusiast | Problem Solver 📎 LinkedIn 🐦 Twitter