Skip to content

SivaguruArumugam/cancer-prediction-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Cancer Prediction API

A production-ready Machine Learning API that predicts cancer risk using patient data. Built with FastAPI and a trained Random Forest model.


🚀 Features

  • 🧠 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

🛠 Tech Stack

  • Python
  • FastAPI
  • Scikit-learn
  • NumPy

📁 Project Structure

cancer-prediction-api/ │ ├── app.py ├── train.py ├── model.pkl ├── requirements.txt ├── README.md │ ├── cancer-api-output.png │ ├── logs/ │ └── predictions.log │ └── data/


⚙️ Installation

pip install -r requirements.txt


▶️ How to Run

python train.py
uvicorn app:app --reload


🌐 API Access

http://127.0.0.1:8000/docs


🧪 Example Request

{ "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] }


📸 Swagger Output

Swagger


📊 Example Response

{ "prediction": "Low Cancer Risk", "confidence": "53.00%", "probabilities": { "low_risk": 0.53, "high_risk": 0.47 } }


⚠️ Notes

  • Model requires exactly 30 input features
  • Logs stored in logs/predictions.log

🚀 Future Improvements

  • Model deployment (Docker)
  • Frontend integration
  • Authentication system

👨‍💻 Author

Sivaguru Arumugam


⭐ Support

If you like this project, give it a ⭐ on GitHub!

About

A production-ready Machine Learning API built with FastAPI that predicts cancer risk using a trained Random Forest model with input validation, probability scoring, and prediction logging.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages