Skip to main content

Interactive ML application for Hepatitis C classification using PyTorch with Streamlit interface

Project description

Hepatitis C Predictor

A machine learning project to predict Hepatitis C using PyTorch neural networks.

Documentation Status

๐Ÿš€ Live Demo

Try the interactive demo without installing anything:

Or run it locally:

streamlit run app.py

Features

  • ๐Ÿ“Š Interactive Data Exploration: Visualize and explore the Hepatitis C dataset
  • ๐Ÿš€ Model Training Interface: Train models with custom hyperparameters
  • ๐Ÿ“ˆ Model Evaluation: Comprehensive performance metrics and visualizations
  • ๐Ÿค– Deep Learning: PyTorch-based neural network with residual connections
  • ๐Ÿ“ฆ Auto-download: Dataset downloads automatically if not present

Project Organization

โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ raw/              <- The original, immutable data dump
โ”‚   โ””โ”€โ”€ processed/        <- The final, canonical data sets for modeling
โ”‚
โ”œโ”€โ”€ models/               <- Trained and serialized models
โ”‚
โ”œโ”€โ”€ notebooks/            <- Jupyter notebooks for analysis and modeling
โ”‚   โ”œโ”€โ”€ 01-data-exploration.ipynb
โ”‚   โ”œโ”€โ”€ 02-data-preprocessing.ipynb
โ”‚   โ”œโ”€โ”€ 03-model-training.ipynb
โ”‚   โ””โ”€โ”€ 04-model-prediction.ipynb
โ”‚
โ”œโ”€โ”€ reports/              <- Generated analysis as HTML, PDF, LaTeX, etc.
โ”‚   โ””โ”€โ”€ figures/          <- Generated graphics and figures
โ”‚
โ”œโ”€โ”€ src/                  <- Source code for use in this project
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ data.py           <- Scripts to download or generate data
โ”‚   โ”œโ”€โ”€ features.py       <- Scripts to turn raw data into features
โ”‚   โ”œโ”€โ”€ models.py         <- Scripts to train models and make predictions
โ”‚   โ””โ”€โ”€ visualization.py  <- Scripts to create exploratory visualizations
โ”‚
โ”œโ”€โ”€ requirements.txt      <- The requirements file for reproducing the environment
โ””โ”€โ”€ README.md            <- The top-level README for developers

Docs

You can check the modules docs in the docs folder or directly from the deployed version on GH pages here: https://ninjalice.github.io/HEPATITIS_C_MODEL/src.html

Getting Started

Option 1: Quick Start (Recommended)

  1. Clone the repository:

    git clone https://github.com/Ninjalice/HEPATITIS_C_MODEL.git
    cd HEPATITIS_C_MODEL
    
  2. Install dependencies:

    pip install -r requirements.txt
    

    Or using uv:

    uv sync --frozen
    
  3. Run the interactive dashboard:

    streamlit run app.py
    

    The app will automatically download the dataset if not present.

Option 2: Jupyter Notebooks

Follow the notebooks in order:

  1. 01-data-exploration.ipynb - Explore the dataset
  2. 02-data-preprocessing.ipynb - Clean and prepare data
  3. 03-model-training.ipynb - Train the neural network
  4. 04-model-prediction.ipynb - Make predictions on new data (WIP)

Dataset

The dataset contains laboratory values from blood donors and Hepatitis C patients:

  • Source: UCI Machine Learning Repository / Kaggle
  • Size: 615 samples
  • Features: 12 laboratory measurements + age and sex
  • Target: Binary classification (Healthy vs Hepatitis C)
  • Auto-download: The app will automatically download the dataset if not present

Manual Download (Optional)

If auto-download fails, you can manually download from:

  1. Kaggle: https://www.kaggle.com/datasets/fedesoriano/hepatitis-c-dataset
  2. Place the file in data/raw/hepatitis_data.csv

Model

  • Architecture: Deep Neural Network with Residual Connections
    • Input Layer: 12 features
    • Hidden Layers: [128, 64, 32] neurons
    • Residual Blocks: 2 per hidden layer
    • Output Layer: 2 classes (Binary classification)
  • Framework: PyTorch 2.8+
  • Regularization: Layer Normalization + Dropout (0.3)
  • Expected Accuracy: ~97.5% on validation set

๐Ÿš€ Deployment

Deploy to Hugging Face Spaces (Recommended)

  1. Create a new Space on Hugging Face:

    • Choose Streamlit as the SDK
    • Set visibility to Public or Private
  2. Push your code to the Space:

    git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/hepatitis-c-predictor
    git push hf main
    
  3. Your app will be automatically deployed and available at: https://huggingface.co/spaces/YOUR_USERNAME/hepatitis-c-predictor

Deploy with Docker

  1. Build the Docker image:

    docker build -t hepatitis-c-predictor .
    
  2. Run the container:

    docker run -p 8501:8501 hepatitis-c-predictor
    
  3. Access the app at http://localhost:8501

Requirements for Deployment

  • Python 3.10
  • All dependencies listed in requirements.txt
  • ~500MB RAM minimum
  • Dataset will be downloaded automatically on first run

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch:
    git checkout -b feature/your-feature-name
    
  3. Make your changes
  4. Run tests and ensure documentation is updated
  5. Commit your changes:
    git commit -m "Add detailed description of your changes"
    
  6. Push to your fork:
    git push origin feature/your-feature-name
    
  7. Create a Pull Request

Code Style

  • Follow PEP 8 guidelines
  • Include docstrings for all functions and classes
  • Add comments for complex logic
  • Update documentation when changing functionality

License

This project is licensed under the MIT License - see the LICENSE file for details.

Important Note

โš ๏ธ This model is for educational purposes only. Do not use for actual medical diagnosis. Always consult healthcare professionals.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hepatitis_c_predictor-0.1.0.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hepatitis_c_predictor-0.1.0-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file hepatitis_c_predictor-0.1.0.tar.gz.

File metadata

  • Download URL: hepatitis_c_predictor-0.1.0.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for hepatitis_c_predictor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9a5a41ae7131d6d1ce83d9b459cc728ba308e2b0e426e5af50a39140120e63f9
MD5 3b546617fa5d394c9b64ee3191787454
BLAKE2b-256 c32bb5b810418af88ece58b0905362694c5c1d645e0fd38d50ddd26d5b0ca963

See more details on using hashes here.

File details

Details for the file hepatitis_c_predictor-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hepatitis_c_predictor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 059839077db60f3aac8ad9fbf381ed5f5f22a1e566f17842400e83f986eff446
MD5 da90ffff7e1ef709ff1426591d801530
BLAKE2b-256 226cf046665fe8e1749fe21177197b6b203898bf4cc245c497e078fcc5b04989

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page