Skip to content

make MLP compatible with the new pyhealth 2.0 loaders#543

Merged
jhnwu3 merged 1 commit intomasterfrom
fix/mlp
Sep 12, 2025
Merged

make MLP compatible with the new pyhealth 2.0 loaders#543
jhnwu3 merged 1 commit intomasterfrom
fix/mlp

Conversation

@jhnwu3
Copy link
Collaborator

@jhnwu3 jhnwu3 commented Sep 11, 2025

This pull request refactors the MLP model in pyhealth/models/mlp.py to support the new SampleDataset format and simplifies the model's interface and feature handling. It also adds support for a new processor type in the embedding model and improves code clarity and maintainability throughout. The most important changes are grouped below:

Dataset and Model Interface Modernization:

  • Refactored the MLP model to use SampleDataset instead of SampleEHRDataset, updating constructor arguments and usage examples for a simpler and more unified interface. Feature and label keys are now inferred from the dataset, removing the need to manually specify them. [1] [2] [3] [4] [5]

Feature Handling and Forward Logic Simplification:

  • Rewrote the forward method in MLP to dynamically handle different feature types and tensor shapes, including automatic creation of embedding or linear layers as needed, and streamlined pooling logic for both categorical and numerical inputs.

Processor and Embedding Model Extension:

  • Added support for TensorProcessor in the embedding model, enabling flexible handling of tensor-based features by automatically determining input size from sample data. [1] [2]

Documentation and Code Clarity:

  • Improved and clarified docstrings and comments in the MLP model, including more detailed explanations of supported input formats and pooling methods. [1] [2]

Miscellaneous Improvements:

  • Minor formatting and registry logic improvements in the processor module for future extensibility.

@jhnwu3 jhnwu3 requested a review from plandes September 11, 2025 23:04
@jhnwu3 jhnwu3 merged commit dbd2878 into master Sep 12, 2025
1 check passed
@jhnwu3 jhnwu3 deleted the fix/mlp branch September 12, 2025 14:52
dalloliogm pushed a commit to dalloliogm/PyHealth that referenced this pull request Nov 26, 2025
Co-authored-by: John Wu <johnwu3@sunlab-serv-03.cs.illinois.edu>
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.

2 participants