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.
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.
- 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
plotlyto 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.
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
- Frontend / Application Framework: Streamlit
- Data Manipulation:
pandas,numpy - Machine Learning:
scikit-learn,LightGBM - Model Serialization:
joblib - Visualization:
plotly
The model requires the following standard medical parameters:
- Age (years)
- Sex (Male / Female)
- Albumin (g/dL)
- Alkaline Phosphatase (U/L)
- ALT (U/L)
- AST (U/L)
- Total Bilirubin (mg/dL)
- Cholinesterase (U/L)
- Cholesterol (mg/dL)
- Creatinine (mg/dL)
- GGT (U/L)
- Total Protein (g/dL)
To run this project on your local machine, follow these steps:
git clone https://github.com/your-username/liver-disease-prediction-system.git
cd liver-disease-prediction-system-mainpython -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`pip install -r requirements.txtstreamlit run app.pyThe application will launch in your default web browser at http://localhost:8501.
📁 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
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