saifisvibin's picture
Add API password protection
fbec77d
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

  1. Create a new Space on Hugging Face
  2. Select Docker as the SDK
  3. Push this repository to your Space
  4. 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 information
  • GET /status - Check API status
  • POST /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

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Run the API:

    uvicorn main:app --reload --port 7860
    
  3. Access API documentation:

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