This project is about machine learning being used in identification and treatment of latent tb here in uganda through a web dashboard being used for optimization of resources by the government
# Uganda TB Risk Prediction API 🏥
REST API for predicting district-level tuberculosis (TB) risk across Uganda's 146 districts using machine learning.
## 🎯 Overview
This API uses **Isolation Forest** (AUC-ROC: 0.701) to identify high-risk TB districts based on demographic, geographic, and health facility data. It helps health officials allocate resources effectively and plan targeted interventions.
## 🏆 Model Performance
- **Algorithm:** Isolation Forest (500 trees)
- **Performance:** AUC-ROC 0.701 (best of 7 models evaluated)
- **Features:** 13 district-level indicators
- **Model Size:** 4.2 MB
- **Prediction Speed:** 47 ms for 135 districts
## 🚀 Quick Start
### Local Development
```bash
# Clone repository
git clone
github.com
cd MACHINE-LEARNING-SW-ML-38
# Install dependencies
pip install -r requirements_render.txt
# Start API
uvicorn deployment.app:app --reload --host 0.0.0.0 --port 8000
```
API will be available at:
localhost
API documentation:
localhost
### Start Dashboard (Optional)
```bash
streamlit run deployment/dashboard.py
```
Dashboard will be available at:
localhost
## 📡 API Endpoints
### Health Check
```bash
GET /
```
### List Required Features
```bash
GET /features
```
### Single District Prediction
```bash
POST /predict
Content-Type: application/json
{
"t_tl": 150000,
"working_age_pct": 0.55,
"under5_pct": 0.18,
"district_sex_ratio": 0.98,
"log_area_km2": 7.5,
"log_pop_density": 5.2,
"compactness": 0.65,
"abs_lat": 1.5,
"facility_count": 25,
"facility_density": 0.0002,
"log_facility_per_100k": 2.8,
"is_urban_survey_cluster": 0,
"region_encoded": 3,
"district_name": "Kampala"
}
```
**Response:**
```json
{
"district_name": "Kampala",
"risk_score": 0.8234,
"risk_tier": "High",
"iso_score": 0.8456,
"kde_score": 0.7891
}
```
### Batch Prediction
```bash
POST /predict/batch
Content-Type: application/json
[
{ /* district 1 data */ },
{ /* dist …