Spaces:
Running
Running
metadata
title: Lung Cancer Prediction API
emoji: 🫁
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
Lung Cancer Prediction API
A FastAPI-based REST API for predicting lung cancer risk based on patient symptoms and characteristics.
Features
- ✅ RESTful API endpoints
- ✅ Automatic Swagger/OpenAPI documentation
- ✅ Pydantic models for request validation
- ✅ CORS support for web applications
- ✅ Production-ready with error handling
Hugging Face Spaces Deployment
This project is configured for deployment on Hugging Face Spaces using the Docker SDK.
Deploy to Hugging Face
- Create a new Space on Hugging Face
- Select Docker as the SDK
- Push this repository to your Space
- The API will be available at your Space URL
API Endpoints
Once deployed, access your API at:
- Swagger UI:
https://your-space.hf.space/docs - ReDoc:
https://your-space.hf.space/redoc
API Endpoints
GET /- API informationGET /status- Check API statusPOST /predict- Predict lung cancer risk
Request Format
{
"gender": "M",
"age": 65,
"smoking": "YES",
"yellow_fingers": "NO",
"anxiety": "NO",
"peer_pressure": "NO",
"chronic_disease": "YES",
"fatigue": "YES",
"allergy": "NO",
"wheezing": "YES",
"alcohol": "NO",
"coughing": "YES",
"shortness_of_breath": "YES",
"swallowing_difficulty": "NO",
"chest_pain": "YES"
}
Response Format
{
"success": true,
"prediction": "YES",
"probability": 87.5,
"message": "Prediction: YES (Confidence: 87.50%)"
}
Local Development
Install dependencies:
pip install -r requirements.txtRun the API:
uvicorn main:app --reload --port 7860Access API documentation:
- Swagger UI: http://localhost:7860/docs
- ReDoc: http://localhost:7860/redoc
Notes
- This application is for educational/research purposes only
- Medical predictions should always be verified by healthcare professionals
- The model accuracy depends on the quality of the training data