File size: 8,756 Bytes
8f44912 06a82f6 7dc530d 06a82f6 7dc530d 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 dc709da 06a82f6 fec3b4a 06a82f6 dc709da |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
---
title: "FibroPred Predictive System"
emoji: "🩺"
colorFrom: "blue"
colorTo: "green"
sdk: "gradio"
app_file: "app.py"
datasets:
- "clinical_data"
license: "apache-2.0"
tags:
- "machine-learning"
- "healthcare"
- "predictive-model"
- "fibrosis"
- "random-forest"
inference: false
---
### README: **FibroPred Predictive System**
---
#### **Description**
FibroPred is a predictive system designed to analyze clinical data and provide predictions for specific medical outcomes related to fibrosis. The tool employs machine learning models, primarily Random Forest classifiers, to forecast the likelihood of various events or conditions, such as mortality, necessity for transplantation, and progressive disease.
The system provides an easy-to-use interface built with Gradio, allowing users to input feature values and obtain predictions. Models and their configurations are stored and loaded dynamically, ensuring modularity and adaptability.
---
#### **Features**
1. **Prediction Targets**:
- **Death**: Likelihood of patient mortality based on clinical and diagnostic features.
- **Binary Diagnosis**: Classification of patients into specific diagnostic categories.
- **Necessity of Transplantation**: Assessment of whether a patient is likely to need a transplant.
- **Progressive Disease**: Prediction of disease progression based on longitudinal data.
2. **Dynamic Model Loading**: Models and feature sets are loaded dynamically from a pre-configured directory (`models`).
3. **Gradio Interface**: A tabbed interface for each prediction target, where users can input values interactively and receive predictions in real-time.
---
#### **Predictive Features**
Below are the features used for prediction across all targets:
1. **Pedigree**: Represents the familial history related to fibrotic conditions.
2. **Age at diagnosis**: Age of the patient at the time of diagnosis.
3. **FVC (L) at diagnosis**: Forced vital capacity in liters at the time of diagnosis, reflecting lung function.
4. **FVC (%) at diagnosis**: Forced vital capacity as a percentage of the expected value for the patient’s age and sex.
5. **DLCO (%) at diagnosis**: Diffusion capacity for carbon monoxide as a percentage, measuring gas exchange efficiency in the lungs.
6. **RadioWorsening2y**: Radiological assessment of lung deterioration over two years.
7. **Severity of telomere shortening - Transform 4**: Indicates the degree of telomere shortening.
8. **Progressive disease**: Binary variable indicating whether the disease is progressive or stable.
9. **Biopsy**: Binary variable indicating whether a biopsy was performed.
10. **Genetic mutation studied in patient**: Binary variable indicating the presence of specific genetic mutations.
11. **Comorbidities**: Binary variable representing the presence of relevant comorbidities.
12. **Tobacco use**: Binary variable reflecting whether the patient has a history of tobacco use.
---
#### **Setup Instructions**
1. Clone or download the repository.
2. Ensure Python 3.8+ is installed.
3. Install dependencies using the command:
```bash
pip install -r requirements.txt
```
4. Place trained models in the `models` directory. Models should be `.pkl` files containing:
- `model`: Trained Random Forest model.
- `features`: Feature list used during model training.
---
#### **Usage**
1. Run the application:
```bash
python app.py
```
2. Access the Gradio interface through the displayed local or public URL.
3. Select a prediction tab, input feature values, and click "Submit" to get predictions.
---
#### **Key Scripts**
1. **app.py**:
- Implements the Gradio interface.
- Maps user-friendly model names to actual models and their features.
2. **fibropred_model.py**:
- Contains the preprocessing pipeline, including imputation and feature selection.
- Includes functions for training, evaluation, and visualization.
3. **model_utils.py**:
- Functions to load models and their features dynamically.
- Handles predictions using preloaded models.
4. **requirements.txt**:
- Lists the Python dependencies required for the system.
---
#### **Technical Highlights**
- **Machine Learning Framework**: Models are built using `scikit-learn`, leveraging Random Forest classifiers for robust predictions.
- **Visualization**: The script includes utilities for plotting feature importance, ROC-AUC curves, and overfitting diagnostics.
- **Dynamic Handling**: Feature lists and models are dynamically linked, ensuring flexibility when adding new prediction targets.
---
#### **Results**
The performance and feature importance for the prediction targets are detailed below:
##### **Prediction Target: Death**

- **Cross-validation Accuracy**:
The cross-validation results for "Death" show some variability across folds, but overall, the model achieves consistently high accuracy.
- **Train vs Test Accuracy**:


- **Feature Importance**:
Features such as "Progressive disease", "DLCO (%) at diagnosis", and "FVC (%) at diagnosis" are the most influential.

- **ROC-AUC Curve**:
The ROC-AUC curve illustrates strong model performance, with an AUC of 0.92.
##### **Prediction Target: Binary Diagnosis**

- **Cross-validation Accuracy**:
Variability in cross-validation accuracy is observed, but the model maintains high performance across most folds.


- **Feature Importance**:
Key predictors include "Age at diagnosis", "Pedigree", and "Tobacco use".

- **ROC-AUC Curve**:
The high AUC value of 0.95 indicates excellent discrimination ability.
##### **Prediction Target: Progressive Disease**

- **Cross-validation Accuracy**:
Accuracy scores across folds highlight variability, but peaks show strong model performance.
- **Train vs Test Accuracy**:


- **Feature Importance**:
"DLCO (%) at diagnosis", "Age at diagnosis", and "Pedigree" emerge as the dominant predictors.

- **ROC-AUC Curve**:
With an AUC of 0.98, the model demonstrates exceptional predictive power.
##### **Prediction Target: Necessity of Transplantation**

- **Cross-validation Accuracy**:
Cross-validation reveals excellent model accuracy.


- **Feature Importance**:
"RadioWorsening2y", "FVC (%) 1 year after diagnosis", and "Comorbidities" are critical.

- **ROC-AUC Curve**:
The model achieves an AUC of 1.00.
---
#### **Future Improvements**
- **Optimizing Variable Names**:
Review and refine variable naming conventions for clarity.
- **Improving Model Precision**:
Retrain the model with a larger dataset.
- **Identifying Optimal Medical Variables**:
Simplify the model by removing less relevant variables.
- **Testing Model Performance with Reduced Variables**:
Assess predictive performance with a reduced set of variables.
- **Expanding Dataset Diversity**:
Incorporate data from diverse demographics.
- **Adding Longitudinal Data Analysis**:
Integrate temporal patterns in disease progression.
- **Real-time Model Retraining**:
Develop mechanisms for real-time updates.
### Associated Space
Check out the interactive demo of this model on Hugging Face Spaces:
[](https://huggingface.co/spaces/amonfortc/FibroPred)
---
This README provides a comprehensive guide to understanding and using the **FibroPred** predictive system effectively.
|