Skip to content

Labrador model ml171#949

Open
leemhmark wants to merge 11 commits intosunlabuiuc:masterfrom
leemhmark:labrador-model-ml171
Open

Labrador model ml171#949
leemhmark wants to merge 11 commits intosunlabuiuc:masterfrom
leemhmark:labrador-model-ml171

Conversation

@leemhmark
Copy link
Copy Markdown

Contributor: Mark Lee (ml171@illinois.edu)
Contribution type: Model

Description:
Implementation of a Transformer model for structured laboratory data in PyHealth from the Labrador Paper (https://arxiv.org/abs/2312.11502). The model processes aligned lab code (categorical) and lab value (continuous) inputs, applies a Transformer encoder without positional encoding, and performs downstream classification.

Files to review

pyhealth/models/labrador.py

  • LabradorModel – main model class with:
  • code embedding + value projection
  • Transformer encoder (permutation-invariant)
  • masked mean pooling
  • classifier head

pyhealth/models/init.py

  • Added import for LabradorModel

tests/test_labrador.py

  • Synthetic tests covering:
  • initialization
  • forward pass
  • output shapes
  • backward pass

docs/api/models/pyhealth.models.labrador.rst

  • API documentation for the model

docs/api/models.rst

  • Added LabradorModel to index

examples/labrador_ablations_quickstart.ipynb

  • Example usage and ablation study with hyperparameter variations

leemhmark added 11 commits April 3, 2026 14:58
- Added a new section demonstrating masking of lab positions using the LabradorModel encoder.
- Implemented functions for masking, encoding, and computing metrics for masked predictions.
- Updated evaluation metrics to include precision, recall, and F1 score for masked code predictions.
- Adjusted execution counts and markdown headers for clarity and consistency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant