Fildza/aurelia-depression-backend
0
Aurelia Depression Detection Backend
Backend API untuk dashboard deteksi dini risiko depresi Aurelia.
API Endpoints
Model
- Algoritma: XGBoost + TF-IDF Vectorizer
- Training Data: Mental Health Dataset (binary classification)
- Output: Probability score → 3 risk levels (rendah/sedang/tinggi)
- Explainability: SHAP TreeExplainer
Environment Variables
*Required untuk chatbot LLM. Fallback ke simulasi jika tidak diset.
Local Development
# Install dependencies
pip install -r requirements.txt
# Run development server
python app.py
# Atau dengan gunicorn
gunicorn --bind 0.0.0.0:5000 --workers 2 app:appDeployment
Hugging Face Spaces (Docker)
- Create new Space with Docker SDK
- Push this repository
- Set
GROQ_API_KEYin Space Settings → Secrets - Space will be available at
https://huggingface.co/spaces/<user>/<space-name>
Docker
docker build -f Dockerfile.hf -t aurelia-backend .
docker run -p 7860:7860 -e GROQ_API_KEY=your_key aurelia-backendProject Structure
backend/
├── app.py # Main Flask application
├── requirements.txt # Python dependencies
├── Dockerfile.hf # HF Spaces Dockerfile
├── models/
│ ├── model_xgboost.pkl # Trained XGBoost model
│ ├── tfidf_vectorizer.pkl # TF-IDF vectorizer
│ └── performa_model.json # Model metrics
└── data/ # SQLite database (runtime)
└── chatbot.dbExample Request
curl -X POST https://your-space.hf.space/predict \
-H "Content-Type: application/json" \
-d '{"teks": "I feel so hopeless and tired every day"}'Response:
{
"teks": "I feel so hopeless and tired every day",
"skor": 0.87,
"risiko": "tinggi",
"model": "XGBoost",
"xai": {
"shap": [...],
"limeHighlight": [...],
"catatanKlinis": "..."
}
}License
MIT
