This repository provides the codebase for the multi-modal predictive model for glaucoma surgical outcomes. We utilize Bio-Clinical BERT to extract information from operative notes and combine it with static features. The code is written in Python and uses PyTorch for the deep learning components.
- Data Structure
- Functionalities
- Getting Started
- Code structure
- Model Architecture
- Training
- Evaluation
- License
The dataset should include:
- A target column named
output, which contains three classes for prediction. - A feature column named
clean-up operative notesthat includes the operative notes. - 75 columns of structured EHR data.
This codebase is designed to:
- Import an Excel file into a Pandas DataFrame.
- Split the feature and target variables into training, validation, and test sets (70%/10%/20%).
- Initialize a ClinicalBERT tokenizer for text processing.
- Tokenize the clean-up operative notes and create data loaders for training, validation, and testing.
- Utilize an input dimension of
[512, 512, 75, 1], where:- The first two dimensions are the encoded input IDs and attention masks from Bio-Clinical BERT.
- The third dimension contains structured EHR (Electronic Health Records) data.
- The fourth dimension holds the outcome labels.
- Set up a PyTorch model class that combines a pre-trained Bio_ClinicalBERT model with static data.
- Initialize and configure the Multi_BERT model and move it to the specified device (CPU or GPU).
- Set three functions: get_accuracy, train, and evaluate.
- Start to train the PyTorch model using a specified set of parameters, optimizer, and loss function.
- Evaluate the model on a test set to generate predictions with ROCs, P-R curves, and classification reports.
Ensure that you have:
- Python
- PyTorch
- Transformers library from Hugging Face
- Other requirements
To install the necessary packages, run the following command:
pip install pandasMulti_BERT: The main classification model class with transformer encoder.train(): Function to train the model.evaluate(): Function to evaluate the model.get_accuracy(): Function to compute accuracy during training and validation.
Our model leverages a pre-trained ClinicalBERT and adds custom layers for dimensionality reduction and combining with static data for classification tasks. The architecture is defined in the Multi_BERT class.
The model is trained using a defined set of hyperparameters, a specified loss function, and an optimizer.
- Batch Size: 16
- Epochs: 200
- Learning Rate: 4e-5
- Weight Decay for L2 Regularization: 1e-5
- Class Weights: [0.2584, 0.8678, 0.8737]
The model is evaluated using a separate test dataset. Evaluation metrics include AUC (Area Under the Curve), Precision-Recall Curve, and Classification reports.
This project is licensed under the MIT License.