A production-ready Machine Learning API that predicts cancer risk using patient data. Built with FastAPI and a trained Random Forest model.
- 🧠 Machine Learning model (Random Forest)
- ⚡ FastAPI backend
- ✅ Input validation (strict feature check)
- 📊 Confidence score & probability output
- 📝 Prediction logging system
- 🏥 Cancer risk classification (High / Low)
- 🔍 Swagger UI for testing
- Python
- FastAPI
- Scikit-learn
- NumPy
cancer-prediction-api/ │ ├── app.py ├── train.py ├── model.pkl ├── requirements.txt ├── README.md │ ├── cancer-api-output.png │ ├── logs/ │ └── predictions.log │ └── data/
pip install -r requirements.txt
python train.py
uvicorn app:app --reload
{ "features": [14.0, 20.0, 90.0, 600.0, 0.1, 0.2, 0.15, 0.1, 0.2, 0.07, 0.5, 1.2, 3.5, 40.0, 0.005, 0.02, 0.03, 0.01, 0.02, 0.003, 15.0, 25.0, 100.0, 700.0, 0.15, 0.25, 0.3, 0.15, 0.3, 0.08] }
{ "prediction": "Low Cancer Risk", "confidence": "53.00%", "probabilities": { "low_risk": 0.53, "high_risk": 0.47 } }
- Model requires exactly 30 input features
- Logs stored in logs/predictions.log
- Model deployment (Docker)
- Frontend integration
- Authentication system
Sivaguru Arumugam
If you like this project, give it a ⭐ on GitHub!
