Skip to content

[CS598 DL4H] TPC model for MIMIC-IV in-hospital mortalityTpc mortality prediction - #1724

Open
avnimohan9 wants to merge 10 commits into
sunlabuiuc:masterfrom
avnimohan9:tpc_mortality_prediction
Open

avnimohan9 wants to merge 10 commits into
sunlabuiuc:masterfrom
avnimohan9:tpc_mortality_prediction

Conversation

@avnimohan9

@avnimohan9 avnimohan9 commented Nov 29, 2026 •

Copy link
Copy Markdown

Title: [CS598 DL4H] TPC model for MIMIC-IV in-hospital mortality

Contributors

  • Pawel Kostadinow (NetID: pawel2)
  • Avni Mohan (NetID: avnim2)
  • Surabhi Pathak (NetID: pathak5)

Contribution type

Model contribution: Temporal Pointwise Convolutional Network (TPC).

Paper

Rocheteau, Liò & Hyland, "Temporal Pointwise Convolutional Networks for Length of Stay Prediction in the Intensive Care Unit", CHIL 2021. https://arxiv.org/abs/2007.09483

What it does

TPC reads hourly lab time series (timeseries input, [batch, hours, labs]) and predicts a binary label, here in-hospital mortality with InHospitalMortalityMIMIC4. Each TPC layer runs two branches side by side and concatenates them with skip connections:

  • Temporal convolution: grouped, causal and dilated, with its own weights for each lab.
  • Pointwise convolution: a 1x1 convolution across all labs at each hour.

Padded hours are masked: a padding-aware batch norm (MaskedNorm1d) skips them, and the prediction comes from each patient's last real hour. Options cover the paper's ablations: use_temporal, use_pointwise, use_skips, share_weights, and linear or exponential dilation.

Files

  • pyhealth/models/tpc.py: MaskedNorm1d, TPCLayer, TPC
  • pyhealth/models/__init__.py: export
  • docs/api/models/pyhealth.models.TPC.rst + docs/api/models.rst index entry
  • examples/mimic4_mortality_tpc.py: baseline comparison and hyperparameter sweep
  • examples/mimic4_mortality_tpc_results.md: results write-up
  • tests/core/test_tpc.py: 14 unit tests

Tests

14 fast tests on synthetic data (slowest about 0.1 s). They cover:

  • initialization, forward outputs and shapes, gradients
  • every ablation option, invalid arguments, receptive field
  • padding invariance and causality (later hours never change earlier outputs)
  • embed output, and save/load through a temporary directory that is cleaned up

tools/check_pr_rules.py passes.

Results (full MIMIC-IV v2.2, 224,791 admissions, 15 epochs, mean of 3 seeds)

Model Test AUROC Test AUPRC
TPC 0.811 0.168
LSTM 0.787 0.160
Transformer 0.774 0.115
TCN 0.762 0.147

TPC beat every baseline in all 3 seeds with 60,863 parameters, against 135k–268k for the baselines. In the one-at-a-time sweep:

  • Learning rate 1e-2 (−0.028 AUROC) and dropout 0.5 (−0.013) hurt in every seed.
  • temp_channels and point_size changed AUROC by 0.003 or less.

The full write-up is in examples/mimic4_mortality_tpc_results.md.

Note

#1412 recently added a TPC model for length-of-stay prediction as pyhealth/models/tpc.py, so this branch currently conflicts with master on the same file and class names. We are happy to rename this implementation (for example TPCMortality in tpc_mortality.py) or fold it into the existing module, whichever the maintainers prefer.

avnimohan9 and others added 10 commits November 28, 2026 03:19
Placeholders for the model, docs page, example script and tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copied as-is from fork/master (62a84e3). Example renamed to .py and
docs page put in the existing pyhealth.models.TPC.rst to match the
upstream naming.

Co-Authored-By: PawelUIUC <PawelUIUC@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the redundant alias in __init__, add >>> examples to MaskedNorm1d
and TPCLayer, and wrap lines over 88 characters. No logic changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PyHealth moved output size, loss and activation onto the label
processor, so TPC now calls label_processor.output_size(), .loss()
and .activation(). Also restores the trailing blank line in models.rst.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Save/load uses a temp folder and checks it is cleaned up. Also tests the
embed output, TPCLayer output size and causality, and MaskedNorm1d in
eval mode and on an all-padding batch. 14 tests, all pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Headers with names, NetIDs, paper and description in the model, example
and test files; drop leftover PURPOSE/STATUS notes; type the example's
functions and add -> None to __init__ methods.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a placeholder for results summary.
This document details hyperparameter ablation and baseline comparison for the Temporal Pointwise Convolutional model on MIMIC-IV in-hospital mortality data, including experimental setup, results, findings, and caveats.
Updated section title from 'Caveats' to 'Considerations' for clarity.
Point the example's RESULTS section at the results file with a summary
table, set the default to the 15 epochs used, note that test scores use
the best-validation checkpoint, mark the 5-epoch remark as not tabulated,
and replace links to CSVs that are not in the repo with run commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@solarsys solarsys added the status: manual Pending maintainer's review label Nov 30, 2026
@solarsys

Copy link
Copy Markdown
Collaborator

Why this PR has status: manual: PyHealth's TPC model was merged yesterday (#1412, pyhealth/models/tpc.py), and this PR adds another models/tpc.py. The branch also conflicts with master.

What you can contribute instead: rebase on master and use the merged TPC. A MIMIC-IV in-hospital mortality task that works with it would be a new, welcome piece; please send it as a task-only PR. #1699 is also adding a mortality head to the merged TPC, so coordinate there if your model changes overlap.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: manual Pending maintainer's review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants