Skip to content

About

A full‑stack system for classifying Vietnamese symptom descriptions into disease groups using a hybrid Machine Learning pipeline and LLM‑based analysis.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Disease Classification Website

Python FastAPI .NET Transformers Model Hub GitHub Repo

UI Screenshot

This system supports disease-group classification from Vietnamese symptom descriptions, including:

  • DiseaseClassificationAPI: FastAPI backend + ML model (TF-IDF + SVD + BERT embeddings) + short Gemini-based analysis.
  • DiseaseClassificationWeb: ASP.NET Core MVC interface for entering symptoms and viewing results.

Model on Hugging Face

1. Overview Architecture

Processing flow:

  1. Users enter symptoms on the web app (DiseaseClassificationWeb).
  2. The web app calls FastAPI endpoint POST /predict-with-analysis.
  3. FastAPI:
  • Vietnamese preprocessing (pyvi).
  • Hybrid feature extraction (BERT + TF-IDF/SVD).
  • Disease-group prediction using a trained SVM model.
  • Gemini call to generate a short reference explanation.
  1. The web app displays disease_class and analysis to users.

2. Technology Stack

  • Backend API: FastAPI, Pydantic, Uvicorn
  • Machine Learning: scikit-learn, torch, transformers, pyvi
  • Model storage: Hugging Face Hub (Marcoh05P/disease-classification-model)
  • Analysis LLM: Google Gemini (google-genai)
  • Frontend Web: ASP.NET Core MVC (net10.0)

3. Project Structure

DiseaseClassificationWebsite/
|-- DiseaseClassificationAPI/
|   |-- main.py
|   |-- settings.py
|   `-- requirements.txt
|-- DiseaseClassificationWeb/
|   |-- Program.cs
|   |-- appsettings.json
|   |-- Controllers/
|   |-- Services/
|   |-- Models/
|   `-- Views/
`-- README.md

4. Environment Requirements

  • Python 3.10+ (3.11 recommended)
  • .NET SDK 10.0 (based on TargetFramework: net10.0)
  • Internet connection for first-time model download from Hugging Face
  • Gemini API key (required for analysis endpoint)

5. Run FastAPI Backend

From the project root:

cd DiseaseClassificationAPI
python -m venv .venv

Activate virtual environment:

  • Windows CMD:
.venv\Scripts\activate
  • PowerShell:
.\.venv\Scripts\Activate.ps1

Install dependencies:

pip install -r requirements.txt

Create DiseaseClassificationAPI/.env (optional but recommended):

GEMINI_API_KEY=your_api_key_here

Run API:

uvicorn main:app --host 0.0.0.0 --port 8000 --reload

Default API URL: http://localhost:8000

Swagger UI: http://localhost:8000/docs

6. Run ASP.NET Core MVC Web App

Open a new terminal, from the project root:

cd DiseaseClassificationWeb
dotnet restore
dotnet run

Default web URLs:

  • http://localhost:5079
  • or https://localhost:7067

The web app calls FastAPI based on:

  • File: DiseaseClassificationWeb/appsettings.json
  • Key: FastApiSettings:BaseUrl
  • Default value: http://localhost:8000

7. API Endpoints

POST /predict

Accepts symptom text and returns predicted disease group.

Request:

{
  "text": "I have a fever, cough, and sore throat"
}

Response:

{
  "disease_class": "..."
}

POST /predict-with-analysis

Returns predicted disease group and a reference analysis from Gemini.

Request:

{
  "text": "I have a fever, cough, and sore throat"
}

Response:

{
  "disease_class": "...",
  "analysis": "..."
}

8. Quick cURL Tests

curl -X POST http://localhost:8000/predict \
  -H "Content-Type: application/json" \
  -d "{\"text\":\"I have a headache and mild fever\"}"
curl -X POST http://localhost:8000/predict-with-analysis \
  -H "Content-Type: application/json" \
  -d "{\"text\":\"I have a headache and mild fever\"}"

9. Common Issues

  • 503 Service Unavailable:
    • Model is still loading or failed to download from Hugging Face.
    • GEMINI_API_KEY is missing when calling /predict-with-analysis.
  • Web shows API connection error:
    • Verify FastAPI is running on the expected port.
    • Verify FastApiSettings:BaseUrl in appsettings.json.
  • Slow startup on first API run:
    • Initial model/tokenizer download.

10. Medical Disclaimer

System outputs are for reference only and do not replace diagnosis or advice from qualified medical professionals.

11. Contributions

The Disease Classification Website project was developed for research and experimentation in applying machine learning and natural language processing to classify disease groups from Vietnamese symptom descriptions. The system combines multiple technology components, including an ML model, backend API, and web interface, to provide an end-to-end pipeline from user input to prediction and reference analysis.

Key contributions include:

  1. Building a disease classification model using hybrid feature extraction from TF-IDF, SVD, and BERT embeddings, combined with Support Vector Machine (SVM) to improve semantic representation for Vietnamese text.
  2. Developing a FastAPI prediction service to deploy the machine learning model as a web API.
  3. Building an ASP.NET Core MVC user interface for symptom input and prediction output.
  4. Integrating Gemini to generate short explanatory text that helps users interpret prediction results.

This project is published publicly for learning, research, and reference in Machine Learning, Natural Language Processing, and AI-integrated web system development. Improvements, bug reports, and enhancement proposals are welcome via pull requests or issues on the project GitHub repository.

12. Copyright

License: CC BY-NC 4.0 – Non-commercial use only.


© 2026 Marcoh05P – Disease Classification Website – Ho Chi Minh City Open University

About

A full‑stack system for classifying Vietnamese symptom descriptions into disease groups using a hybrid Machine Learning pipeline and LLM‑based analysis.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages