Skip to content

Towards Unified Sequence Representation II: Move YAIB tasks and per-step labels to SequenceProcessorV2 - #1347

Draft
Logiquo wants to merge 1 commit into
feat/seq-v2from
feat/seq-v2-2
Draft

Logiquo wants to merge 1 commit into
feat/seq-v2from
feat/seq-v2-2

Conversation

@Logiquo

@Logiquo Logiquo commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Second PR in the stack toward a unified sequence representation, on top of #1343. It moves the per-step (timeseries) labels and the YAIB MIMIC-IV tasks to SequenceProcessorV2, and updates the loss and Trainer to match. No model consumes per-step V2 labels yet; Unified_RNN follows in a later PR of this stack.

Changes

  • TimeseriesLabelProcessor, TimeseriesBinaryLabelProcessor and TimeseriesRegressionLabelProcessor are now restricted SequenceProcessorV2 fields: one series level with scalar values and strictly increasing times. A batch is packed as (values [ΣN, 1], time [ΣN], batch offsets [B + 1]); there is no grid or mask.
  • The timeseries_* losses average over the label records, and Trainer.inference splits the packed labels into one array per sample for the timeseries metrics.
  • BaseModel._resolve_mode picks the most specific registered processor class, so the label subclasses resolve to their own modes rather than sequence_v2.
  • RNN and MultimodalRNN reject per-step labels.
  • The five YAIB tasks (mortality, kidney function, length of stay, AKI, sepsis) use a sequence_v2 series for the dynamic features: forward fill, then mean, then zero imputation, z-score normalization and missing indicators. A test checks this matches the previous TimeseriesProcessor preprocessing.

Tests

tests/core/label_record_model_utils.py adds a minimal per-step test model (one linear layer on each label's time), so the label processors, loss, Trainer and metrics are tested without depending on a particular architecture.

@Logiquo
Logiquo added this pull request to stack #1339 October 28, 2026 22:43
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Test Coverage

Total: 74.71% (21031 / 28151 lines)

Modified file Coverage Lines
pyhealth/benchmarks/__init__.py 100.00% 2 / 2
pyhealth/benchmarks/_serialization.py 95.95% 71 / 74
pyhealth/benchmarks/base.py 98.33% 59 / 60
pyhealth/models/base_model.py 92.81% 129 / 139
pyhealth/models/rnn.py 87.17% 163 / 187
pyhealth/models/vae.py 96.77% 90 / 93
pyhealth/processors/timeseries_processor.py 88.35% 91 / 103
pyhealth/tasks/__init__.py 89.74% 35 / 39
pyhealth/tasks/covid19_cxr_generation.py 100.00% 9 / 9
pyhealth/tasks/yaib_mimic4.py 93.06% 523 / 562
pyhealth/trainer.py 73.06% 198 / 271

Workflow run · ce890cd

@Logiquo Logiquo added the status: manual Pending maintainer's review label Oct 30, 2026
@Logiquo

Logiquo commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions

Copy link
Copy Markdown

AI Review

suggestion: not available
decision: human review

This PR is too large for AI review (over 300 files or 200000 diff characters), so it is labeled status: manual and needs a human review.

@Logiquo
Logiquo force-pushed the feat/seq-v2-2 branch 2 times, most recently from 6912de3 to b8522f4 Compare October 30, 2026 11:36
@Logiquo Logiquo changed the title Towards Unified Sequence Representation II: Add SequenceEmbeddingModel and Unified_RNN for hierarchical packed records Towards Unified Sequence Representation II: Move YAIB tasks and per-step labels to SequenceProcessorV2 Oct 30, 2026
- TimeseriesLabelProcessor and its binary and regression subclasses are now
  restricted SequenceProcessorV2 fields: one series level with scalar
  values and strictly increasing times. A batch is packed as (values [ΣN, 1],
  time [ΣN], batch offsets [B + 1]); there is no grid or mask.
- The timeseries losses average over the label records, and
  Trainer.inference splits the packed labels into one array per sample.
  _resolve_mode picks the most specific registered processor class, so the
  label subclasses resolve to their own modes.
- RNN and MultimodalRNN reject per-step (timeseries_*) labels.
- The five YAIB MIMIC-IV tasks use a sequence_v2 series for the dynamic
  features (forward fill, then mean, then zero imputation, z-score
  normalization and missing indicators) and per-hour label records.
- Tests use a minimal per-step model (tests/core/label_record_model_utils.py)
  for the loss, Trainer and metrics.

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.

1 participant