File size: 2,129 Bytes
fbec77d
 
 
 
 
 
 
 
 
6f2b9f4
fa01bf1
6f2b9f4
 
 
 
 
 
 
 
 
fa01bf1
ee093d4
fa01bf1
ee093d4
fa01bf1
ee093d4
fa01bf1
ee093d4
 
 
 
fa01bf1
ee093d4
fa01bf1
ee093d4
 
 
fa01bf1
 
 
6f2b9f4
fa01bf1
6f2b9f4
fa01bf1
6f2b9f4
fa01bf1
6f2b9f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee093d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6f2b9f4
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
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](https://huggingface.co/spaces)
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

```json
{
  "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

```json
{
  "success": true,
  "prediction": "YES",
  "probability": 87.5,
  "message": "Prediction: YES (Confidence: 87.50%)"
}
```

## Local Development

1. **Install dependencies:**
   ```bash
   pip install -r requirements.txt
   ```

2. **Run the API:**
   ```bash
   uvicorn main:app --reload --port 7860
   ```

3. **Access 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