Skip to content

VenkateshHJoshi/liver-disease-prediction-system

Repository files navigation

🩺 Liver Disease Prediction System

Streamlit App Python Machine Learning License

An advanced, medical-grade AI dashboard built with Streamlit and LightGBM that evaluates patient clinical markers to predict various liver conditions including Hepatitis, Fibrosis, and Cirrhosis.

Try the Live Demo Here!


📖 Project Description

The Liver Disease Prediction System is an intelligent diagnostic aid designed to analyze standard biochemical blood test results. By taking in 12 accessible input markers (such as ALT, AST, Bilirubin, and Albumin), the system performs real-time data transformations, unit conversions, and complex feature engineering to output a diagnostic probability.

The underlying machine learning pipeline uses a powerful LightGBM model to classify the patient's liver health status into one of five categories:

  • ✅ Healthy Liver
  • ⚠️ Suspected Liver Disorder
  • 🦠 Hepatitis
  • 🕸️ Fibrosis
  • 🪨 Cirrhosis

The user interface is designed to provide immediate insight through interactive Plotly visualizations, representing diagnostic confidence and differential probabilities.


🌟 Key Features

  • Medical-Grade UI: Intuitive and easy-to-use inputs with predefined medical ranges.
  • Automated Feature Engineering: On-the-fly calculation of crucial metrics like AST/ALT ratio, Albumin/Bilirubin ratio, and synthetic liver function scores.
  • Robust Machine Learning Model: Pre-trained inference pipeline yielding multi-class output and probability distribution.
  • Interactive Visualizations: Employs plotly to render gauge charts for diagnostic confidence and bar charts for top differential possibilities.
  • Clinical Chat Interpretations: Provides simple AI-based text summaries of the laboratory results indicating the primary driving factors for the prediction.

⚙️ System Architecture

Below is a visual representation of how data flows from the user inputs to the final clinical inference.

graph TD
    classDef ui fill:#4c6291,stroke:#fff,stroke-width:2px,color:#fff;
    classDef process fill:#e59e35,stroke:#fff,stroke-width:2px,color:#fff;
    classDef model fill:#459d7a,stroke:#fff,stroke-width:2px,color:#fff;
    classDef prediction fill:#ba4a4f,stroke:#fff,stroke-width:2px,color:#fff;
    classDef vis fill:#7d4da7,stroke:#fff,stroke-width:2px,color:#fff;

    A[Patient Clinical Inputs<br/>UI via Streamlit]:::ui --> B(Data Standardization & <br/>Unit Conversion):::process
    B --> C(Feature Engineering<br/>AST/ALT Ratio, Inflammation Score, etc.):::process
    C --> D{LightGBM Machine Learning Pipeline}:::model
    
    D --> E[Multi-Class Classification]:::model
    
    E --> F1[Healthy Liver]:::prediction
    E --> F2[Suspected Disorder]:::prediction
    E --> F3[Hepatitis]:::prediction
    E --> F4[Fibrosis]:::prediction
    E --> F5[Cirrhosis]:::prediction
    
    D --> G[Probability Distribution & Confidence]:::vis
    G --> H[Plotly Gauge Chart & Bar Charts]:::vis
    G --> I[Clinical Interpretation Text]:::vis
Loading

🛠️ Technology Stack

  • Frontend / Application Framework: Streamlit
  • Data Manipulation: pandas, numpy
  • Machine Learning: scikit-learn, LightGBM
  • Model Serialization: joblib
  • Visualization: plotly

🔬 Core Clinical Inputs Required

The model requires the following standard medical parameters:

  1. Age (years)
  2. Sex (Male / Female)
  3. Albumin (g/dL)
  4. Alkaline Phosphatase (U/L)
  5. ALT (U/L)
  6. AST (U/L)
  7. Total Bilirubin (mg/dL)
  8. Cholinesterase (U/L)
  9. Cholesterol (mg/dL)
  10. Creatinine (mg/dL)
  11. GGT (U/L)
  12. Total Protein (g/dL)

💻 Local Installation & Usage

To run this project on your local machine, follow these steps:

1. Clone the repository

git clone https://github.com/your-username/liver-disease-prediction-system.git
cd liver-disease-prediction-system-main

2. Create a virtual environment (optional but recommended)

python -m venv venv
source venv/bin/activate  # On Windows use `venv\Scripts\activate`

3. Install the required dependencies

pip install -r requirements.txt

4. Run the Streamlit Application

streamlit run app.py

The application will launch in your default web browser at http://localhost:8501.


📂 Project Structure

📁 liver-disease-prediction-system-main
│
├── 📄 app.py                     # Main Streamlit application
├── 📄 liver_pipeline.joblib      # Pre-trained LightGBM classification pipeline
├── 📄 requirements.txt           # Python dependencies
├── 📄 Dataset-620.csv            # Raw dataset
├── 📄 liver_eda_cleaned.csv      # Cleaned Dataset after EDA
└── 📓 Full_Eda.ipynb             # Jupyter Notebook containing Exploratory Data Analysis & Model Training

⚠️ Medical Disclaimer

This tool is for educational and demonstration purposes only. It relies on machine learning patterns to correlate clinical variables with liver conditions. It is NOT a clinical diagnostic tool and should not be used in place of professional medical advice, diagnosis, or treatment. Always consult a qualified healthcare provider with any questions you may have regarding a medical condition.


Developed with ❤️ for Healthcare Innovation

About

The Liver Disease Prediction System is an intelligent diagnostic aid that analyzes biochemical blood test results. By taking 12 input markers, it performs data transformations and uses a LightGBM model to classify the patient's liver health status into 5 categories: Healthy Liver, Suspected Liver Disorder, Hepatitis, Fibrosis, and Cirrhosis.

Topics

Resources

Stars

Watchers

Forks

Contributors