CoolFace
Apppublic

Fildza/aurelia-depression-backend

sourceHugging Facemitupdated 2mo agoView on Hugging Face
0likes
App README

Aurelia Depression Detection Backend

Backend API untuk dashboard deteksi dini risiko depresi Aurelia.

API Endpoints

EndpointMethodDescription
/healthGETHealth check
/predictPOSTPrediksi risiko depresi dari teks
/ringkasanGETStatistik ringkasan dashboard
/tren-harianGETTren harian risiko
/performa-modelGETPerforma model ML
/cuitanGETDaftar cuitan contoh
/cuitan/<id>GETDetail cuitan
/cuitan/<id>/xaiGETExplainable AI (SHAP)
/chatbotPOSTChatbot asisten data
/chatbot/riwayatGETRiwayat chatbot
/chatbot/riwayatDELETEHapus riwayat

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

VariableRequiredDefaultDescription
GROQ_API_KEYYes*-Groq API key untuk chatbot LLM
GROQ_MODELNollama-3.1-8b-instantModel Groq yang digunakan

*Required untuk chatbot LLM. Fallback ke simulasi jika tidak diset.

Local Development

bash
# 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:app

Deployment

Hugging Face Spaces (Docker)

  1. 1.Create new Space with Docker SDK
  2. 2.Push this repository
  3. 3.Set GROQ_API_KEY in Space Settings → Secrets
  4. 4.Space will be available at https://huggingface.co/spaces/<user>/<space-name>

Docker

bash
docker build -f Dockerfile.hf -t aurelia-backend .
docker run -p 7860:7860 -e GROQ_API_KEY=your_key aurelia-backend

Project 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.db

Example Request

bash
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:

json
{
  "teks": "I feel so hopeless and tired every day",
  "skor": 0.87,
  "risiko": "tinggi",
  "model": "XGBoost",
  "xai": {
    "shap": [...],
    "limeHighlight": [...],
    "catatanKlinis": "..."
  }
}

License

MIT