Repository navigation
Add ETHOS generative timeline model with zero-shot risk estimation - #1397
Conversation
Turns a patient's MEDS rows into ETHOS tokens: per-code quantile tokens for numeric values, fitted on the training split, and 19 time-interval tokens for gaps between events. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add ICUAdmissionMEDS, HospitalReadmissionMEDS and ProlongedLengthOfStayMEDS, BaseTask classes on MEDSDataset that follow the ETHOS-ARES cohorts and labels (arXiv:2502.06124). They only need a code sequence, so any PyHealth sequence model can use them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the ETHOS GPT-style model as a BaseModel, EthosContextProcessor for the static context, EthosTimelineMEDS for training and EthosOutcomeMEDS to connect the MEDS outcome tasks to it. EthosProcessor now learns interval estimates. Rollouts stop by token or simulated time, and an EthosRolloutRule turns them into a risk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test CoverageTotal: 83.05% (36278 / 43683 lines)
|
|
/review |
There was a problem hiding this comment.
Previous review
AI Review
suggestion: need change
decision: need change
Thank you for this contribution. It adds ETHOS as a BaseModel with next-token training and zero-shot risk estimation by rollouts. It also adds the context processor, the timeline and outcome tasks, examples, docs and tests. The description is unusually clear about where it differs from ethos-ares, and I found no correctness problems in the rollout, scoring or tokenization logic.
This is close. One thing needs fixing before it can merge.
To get this merged:
- Name the links to other existing components in the description. These imports are not mentioned there:
- ethos_tasks.py and meds_outcome_tasks.py import ADMISSION_PREFIX, DIED_CODE, DISCHARGE_PREFIX and DEATH_CODE from in_hospital_mortality_meds.py.
- ethos_processor.py and ethos_context_processor.py import ConceptVocab from cehr_processor.py.
- For each, please either confirm the sharing is intended and say why in the description, or keep the component self-contained by copying the small constants or the vocabulary class locally. Both are fine. Copying the constants is a few lines.
Optional suggestions:
- Rollouts re-run the full sequence for every generated token, with no KV cache. This will be slow at the paper's scale (2048 context, 100 rollouts), so a short note in the docs would help users.
- The description is clear that nothing from the paper is reproduced, and that is fine for this PR.
Coverage meets the bar. The whole repository is at 78.2%, above the 60% minimum. Every new file is above 96%, so each is above the 80% guideline.
Nothing here touches the base classes, the Trainer or the shared registries. The change only adds new components and exports.
Reviewed commit c9757df
EthosVocab is a 50-line copy of the parts of cehr_processor.ConceptVocab the tokenizer uses, so the processor no longer links to the CEHR processor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
meds_outcome_tasks.py now defines ADMISSION_PREFIX, DISCHARGE_PREFIX, DIED_CODE and DEATH_CODE itself instead of importing them from in_hospital_mortality_meds.py. _rows_at_admission and _rows_at_discharge return the input rows, and _codes_at_admission and _codes_at_discharge take their codes, so a caller can read other columns of the same window. The task classes are unchanged. This moves the refactor from #1397 here, so #1397 no longer changes this file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # pyhealth/models/__init__.py # pyhealth/processors/ethos_processor.py
- BaseModel.mode is now a read-only property, so ETHOS no longer sets self.mode = None (it raised AttributeError on master). The dataset must have no label processor, so mode is None; a labelled dataset now raises a clear ValueError instead of failing later in Trainer. - ethos_tasks.py defines ADMISSION_PREFIX, DISCHARGE_PREFIX, DIED_CODE and DEATH_CODE itself instead of importing them from in_hospital_mortality_meds.py and ethos_processor.py. - EthosContextProcessor uses EthosVocab from ethos_processor.py instead of cehr_processor.ConceptVocab. - estimate_risk notes that rollouts have no key-value cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/review |
There was a problem hiding this comment.
Previous review
AI Review
suggestion: need change
decision: need change
Thank you for this contribution. It adds the ETHOS generative timeline model with zero-shot risk estimation by rollout, plus the tokenizer and context processors and the MEDS outcome and timeline tasks. The description is thorough and honest about what it does and doesn't reproduce. The code is well tested. Coverage is 80.44% for the whole repository, and every changed file is above 95%, so it meets the bar. The new files add exports and docs entries only, so I don't see a base-class or shared-API change.
To get this merged:
HospitalReadmissionMEDSlooks close to the existingReadmissionPredictionMIMIC4inpyhealth/tasks/readmission_prediction.py. Both label whether the patient is readmitted within a window after discharge. The description doesn't mention that task. Please add a short note saying how the two differ, for example MEDS input, death counted as positive, in-hospital deaths excluded, and the ETHOS-ARES cohort rules. Or explain why a separate task is needed. That would settle the question of whether this duplicates an existing component.
Optional suggestions:
- The ETHOS tasks are only tested on in-memory
Patientobjects. A smallset_tasktest forEthosTimelineMEDSandEthosOutcomeMEDSon synthetic Parquet would show that the cache key and the processors work end to end. death_as_positivedefaults toTrue, which differs from the paper's ICU-only Table S1 label. You document this clearly. Keep that note prominent in the docs as well.- This PR includes the diffs of #1393 and #1395 until they land, so the final review is easiest once they are merged.
Reviewed commit 15b15af
Also note in the module docstring that the midnight rule can drop a true midnight event, and that the discharge-code pick among exact timestamp ties is not guaranteed stable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On synthetic Parquet: the timeline task fits both ETHOS processors, and two EthosOutcomeMEDS options give their own cached labels while reusing the timeline vocabularies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/review |
There was a problem hiding this comment.
Previous review
AI Review
suggestion: approve
decision: approve
Thank you for this contribution. It adds ETHOS as a BaseModel with zero-shot risk estimation by rollouts. It also adds the EthosProcessor and EthosContextProcessor, the EthosTimelineMEDS and EthosOutcomeMEDS tasks, and the MEDS outcome tasks they build on. It looks ready to merge.
What I checked:
- The code matches the description. That covers the rollout rules, the label options, the dropped-rollout handling, and saving and loading of the processors.
- Every link between components is named in the description with a reason. These are the links from ethos_tasks to meds_outcome_tasks and to ethos_processor, from the context processor to ethos_processor, and from ethos.py to the processors and tasks.
- No base class, Trainer, or registry behavior is changed. The shared files only get new exports and docs entries.
- Coverage meets the bar. The repository total is 80.44%, against a 60% bar. Every added file is at or above 96%: ethos.py 100%, ethos_processor.py 100%, ethos_context_processor.py 96.4%, ethos_tasks.py 100%, meds_outcome_tasks.py 100%. The modified init files are at or above 95%.
- HospitalReadmissionMEDS is not a duplicate of ReadmissionPredictionMIMIC4. The docstring explains the differences in data, input, death handling, cohort and window.
Optional suggestions:
- Set
learns_statistics = Trueon EthosContextProcessor, if the framework uses it for its leakage warning. Right now no warning is raised when it is fitted on all samples. - Rollouts recompute full-sequence logits at every step. You already note this in the docstring. A key-value cache would help at the paper's scale.
- The tokenizer example re-implements EthosTimelineMEDS inline. You could use the task instead.
- Consider a short test that trains ETHOS on the output of
set_task.
Reviewed commit 79af6ea
* Add MEDS ICU admission, readmission and prolonged stay tasks Add ICUAdmissionMEDS, HospitalReadmissionMEDS and ProlongedLengthOfStayMEDS, BaseTask classes on MEDSDataset that follow the ETHOS-ARES cohorts and labels (arXiv:2502.06124). They only need a code sequence, so any PyHealth sequence model can use them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep the MEDS codes local and return input rows from the window helpers meds_outcome_tasks.py now defines ADMISSION_PREFIX, DISCHARGE_PREFIX, DIED_CODE and DEATH_CODE itself instead of importing them from in_hospital_mortality_meds.py. _rows_at_admission and _rows_at_discharge return the input rows, and _codes_at_admission and _codes_at_discharge take their codes, so a caller can read other columns of the same window. The task classes are unchanged. This moves the refactor from #1397 here, so #1397 no longer changes this file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Say how HospitalReadmissionMEDS differs from ReadmissionPredictionMIMIC4 Also note in the module docstring that the midnight rule can drop a true midnight event, and that the discharge-code pick among exact timestamp ties is not guaranteed stable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * MEDS readmission: keep a later stay's events out of the discharge input A same-day readmission's date-resolution codes (e.g. HCPCS stamped at midnight) sort before this stay's discharge and revealed the label. Events of any stay admitted at or after the discharge are now dropped. Test: discharge 14:00, readmission 18:00, HCPCS of the next stay at 00:00. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BdtuVKBLhWpYbhTQbaZaTt --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: solarsys <jimeng.sun@gmail.com>
# Conflicts: # docs/api/processors.rst # docs/api/tasks.rst # pyhealth/processors/__init__.py # pyhealth/processors/ethos_processor.py # pyhealth/tasks/__init__.py # pyhealth/tasks/meds_outcome_tasks.py # tests/core/test_ethos_processor.py # tests/core/test_meds_outcome_tasks.py
|
/review |
There was a problem hiding this comment.
Previous review
AI Review
suggestion: need change
decision: need change
Thank you for this contribution. It adds ETHOS as a BaseModel with zero-shot risk estimation by rollout. It also adds the context processor, the timeline and outcome tasks, and the rollout rules. The description is thorough, the links to other components are explained, and test coverage is well above the bar. The new files are at 96–100%, and the repository total is 83%. You are close, and there is one blocking problem.
To get this merged:
- Guard against mismatched processors in
ETHOS.estimate_risk. If an outcome dataset is built withoutinput_processors=model.dataset.input_processors, it fits its own vocabulary and quantile breaks. The token ids then mean something different from what the model was trained on.estimate_riskstill returns plausible-looking risks, but they are wrong. TheEthosOutcomeMEDSdocstring asks users to pass the processors, but nothing enforces it. Please add a check that fails loudly. For example, when the dataloader exposes its dataset, compare the batch processors' vocabularies and quantiles with the model's. If the check can't be complete, at least raise an error when a token id falls outside the model's vocabulary. Add a test for the mismatch case. A prominent note in theestimate_riskdocstring would also help, but a check is better.
Optional suggestions:
- The default
death_as_positive=Truediffers from the ICU-only label behind Table S1. You already raise this in your questions. Consider saying in theEthosOutcomeMEDSdocs which setting matches the paper. - The no-KV-cache slowness is documented. A short pointer in the model's
.rstpage would help people planning paper-scale runs.
Reviewed commit 95b20c3
An outcome dataset built without the training model's processors fits its own vocabulary and quantiles, so token ids mean something else and the risks are silently wrong. estimate_risk now compares the dataloader's dataset processors (vocabularies, quantiles, interval estimates) with the model's and raises; for loaders without a dataset it raises on any id outside the model's vocabulary. Docstring and test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BdtuVKBLhWpYbhTQbaZaTt
|
/review Addressed the review: |
| # No timeline has a next token. A zero that keeps the graph, instead | ||
| # of the NaN mean of nothing. | ||
| loss = logits.sum() * 0.0 | ||
| return {"loss": loss, "logit": logits, "y_true": labels} |
There was a problem hiding this comment.
[medium] Trainer.inference raises KeyError for ETHOS because forward has no y_prob
forward returns only loss, logit and y_true. ETHOS has no label processor, so Trainer.inference (pyhealth/trainer.py:427-428) reads output["y_prob"] unconditionally and raises KeyError: 'y_prob'. Trainer.evaluate avoids that path, which is why the tests pass, but inference is public and the description says ETHOS works with Trainer. Fix: either state in the ETHOS class docstring and the PR description that Trainer.inference is not supported (use estimate_risk), or make ETHOS raise a clear error from inference. Add a test that pins whichever behavior is chosen.
| Smoke test on synthetic data: this writes a small MEDS directory to a temporary | ||
| folder, so it needs no credentials and no download. The numbers mean nothing | ||
| clinically, and nothing here reproduces a result from the paper. Sixty made-up | ||
| patients and a tiny model cannot, whatever the AUROCs below happen to be. |
There was a problem hiding this comment.
[low] Docstring refers to AUROCs that the file never shows
"whatever the AUROCs below happen to be" points at nothing in the file; the AUROCs are only printed when the script runs. Rephrase, for example "whatever AUROC the script prints".
There was a problem hiding this comment.
AI Review
suggestion: approve
decision: approve
Thank you for this contribution. It adds ETHOS as a BaseModel: a next-token timeline model with zero-shot risk estimation by rollouts. It also adds an EthosContextProcessor, interval_estimates on EthosProcessor, and the EthosTimelineMEDS and EthosOutcomeMEDS tasks with their rollout rules. It looks ready to merge.
What I checked:
- The code matches the description. That covers the rollout stop, drop and positive rules, the windowing and age-at-window-start logic, the processor checks in estimate_risk, and the label-free ValueError.
- Every new link between components is named in the description with a reason. These are the links to meds_outcome_tasks.py and ethos_processor.py in ethos_tasks.py, to ethos_processor.py in ethos_context_processor.py, and to the processors and tasks in ethos.py. The copied constants are explained too.
- Existing components change only by export lines, docs entries, and interval_estimates on the ETHOS-only EthosProcessor. No existing component is changed in a way that affects others.
- PyHealth has no existing component that samples future timelines, so this adds nothing it already has.
- No new dataset is added.
- Coverage meets the bar. The whole repository is at 83.05%, above 60%. Each changed file is above 80%: ethos.py 99.59%, ethos_context_processor.py 96.43%, ethos_tasks.py 100%, ethos_processor.py 100%.
Optional suggestions:
- forward returns no y_prob, so Trainer.inference would raise a KeyError for this model. This follows from having no labels, and you already state that only loss-based evaluate applies. A sentence in the ETHOS docstring saying to use estimate_risk instead of Trainer.inference would help users.
- The module docstring of examples/ethos_zero_shot.py refers to AUROCs "below" that it doesn't show. You could reword it.
- The description says this branch depends on #1393 and #1395, so it should merge after them. The diff will shrink once they land.
- On your open questions about the death_as_positive default, HOSPITAL_DISCHARGE//DIED handling and multi-part codes, the maintainers are best placed to decide.
Reviewed commit 7d24d29
… ones Six bounties are already fully merged but were still listed as open: 22 VAE (sunlabuiuc#1358), 27 YAIB (sunlabuiuc#1338, sunlabuiuc#1417, sunlabuiuc#1423), 40 DiPro (sunlabuiuc#1398), 43 ARMR (sunlabuiuc#1371), 56 TRACE (sunlabuiuc#1382) and 58 ETHOS-ARES (sunlabuiuc#1397). Eight more are partly merged. Their descriptions now say what is merged and what remains, so contributors can pick up the rest: 37 MIRA, 41 HeartLang, 42 APN, 52 APRICOT-M, 53 KnowRare, 54 LLMs as EHR Encoders, 55 MEME and 60 TrajSurv. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UxbiyTdwHAng6T548wdSda
Depends on two unmerged draft PRs: #1393 (
feat/ethos-tokenizer, the tokenizer) and #1395 (feat/meds-outcome-tasks, the outcome tasks). This branch starts from #1393 and merges #1395, so until they land the diff againstmasterincludes both. To read only this PR, diff against the merge of the two parents, or look at the commits "Add ETHOS generative timeline model with zero-shot risk estimation" and "Port ETHOS to the LabelProcessor API and keep its MEDS codes local".What this adds
ETHOS (Renc et al., arXiv:2502.06124) as a
BaseModel: a GPT-style model of tokenized timelines that trains without labels and predicts outcomes by sampling future timelines. Adapted from ethos-ares at 2d54383 (MIT).pyhealth.models.ETHOS:forwardis the next-token loss and works withTrainer.rolloutsamples futures for one sample.estimate_riskturns them into a risk per sample.EthosContextProcessor("ethos_context"): static demographics and age, which Add EthosProcessor, the ETHOS timeline tokenizer for MEDS #1393 leaves out.EthosProcessor.interval_estimates: the mean hours per interval token (ETHOS'sIntervalEstimator), which rollouts need to stop on time.EthosTimelineMEDS: whole timelines for training.EthosOutcomeMEDS(ICUAdmissionMEDS, ...): runs an outcome task from Add MEDS ICU admission, readmission and prolonged stay tasks #1395 and keeps its cohort, labels and leakage exclusions, but returns the rows in the form ETHOS tokenizes. Its.ruleis the matchingEthosRolloutRule.How a rollout becomes a risk
Risk is positive rollouts over kept rollouts, 100 rollouts by default (the paper's N). Rollouts stopped by an invalid token or
max_new_tokensare always dropped. If all of a sample's rollouts are dropped, its risk isnan.TIMELINE_ENDdeath_as_positiveTIMELINE_END, time limitTIMELINE_ENDthreshold_daysTIMELINE_END, time limitTIMELINE_ENDTIMELINE_ENDare negative)window_daysLabel options used. The rollout follows the options of the task it is given:
death_as_positiveis honored. Its default ofTruecomes fromnotebooks/icu_admission.ipynb, but the paper's 0.932 comes fromfigures.ipynb, which is ICU-only. To compare with Table S1, usedeath_as_positive=False, as the example does.threshold_daysis inclusive (>= 10 days), matching Add MEDS ICU admission, readmission and prolonged stay tasks #1395 and the code. The paper's text says>10 days.require_full_followupchanges only the cohort. It has no effect on the rollout.Results
Smoke test on synthetic data only. No result from the paper is reproduced, and MIMIC-IV in MEDS form is not on this machine, so no real or demo data was run.
examples/ethos_zero_shot.pytrains a 2-layer, 32-dimension model for 60 epochs on 42 synthetic patients, then runs 20 rollouts for each of 29 stays from 18 held-out patients. Re-run after the master merge:Before the merge the same script gave risks of 0.659, 0.626 and 0.422 and AUROCs of 0.708, 0.740 and 0.641; I did not isolate which master change moved the training run. These show only that the pipeline runs end to end. The sample is too small for the AUROCs to mean anything, and the synthetic data has a planted age effect.
For reference, the paper's Table S1 reports these AUROCs for ETHOS on MIMIC-IV: hospital mortality 0.940, ICU admission 0.932, prolonged stay 0.853, composite 0.906. It does not report 30-day readmission.
Decisions and differences
Model and training
scripts/run_training.sh. Thetraining.yamldefaults are smaller and were not used.Trainerhas no warmup or cosine schedule, and its decay groups differ fromconfigure_optimizers. DDP, autocast,torch.compile, the encoder-decoder variant and attention capture are not ported.forwardreturns noy_prob. The training dataset has no label processor, somodeisNoneandTrainer.evaluatereports loss only. A dataset with a label raises aValueErrorat construction; labels are scored withestimate_risk.estimate_risk's docstring says so.ethos-ares, but the authors' checkpoints were not tested and would not fit, because the vocabularies differ.Static context
<unk>. ETHOS would raise an error.<unk>age tokens.Rollouts
max_new_tokens(default 8192) is new. ETHOS has no such limit, but a poorly trained model may never advance the clock. These rollouts are dropped.<pad>,<unk>, static tokens and unused ids count as invalid (key_error). ETHOS has only the unused ids.Task inputs
HOSPITAL_ADMISSION//EW EMER.//ERas one token, while ETHOS splits it. So rollout rules match on prefixes, a prompt ends at the admission code (ETHOS starts two tokens later), and a rollout generates the whole code at once.HOSPITAL_DISCHARGE//DIEDcounts as a death, because Add MEDS ICU admission, readmission and prolonged stay tasks #1395 labels it so. ETHOS relies on the separate death token.TIMELINE_ENDrollouts, asfigures.ipynbdoes.icu_admission.ipynbcounts them as negative.ETHOS, not in the task.HospitalReadmissionMEDS(from #1395) andReadmissionPredictionMIMIC4. Both label readmission within a window after discharge, but they are different tasks. The same list is in #1395 and in theHospitalReadmissionMEDSdocstring:MEDSDataset(onemedstable), not the MIMIC-IVpatients,admissions,diagnoses_icd,procedures_icdandprescriptionstables ofMIMIC4EHRDataset.ReadmissionPredictionMIMIC4doesn't look at deaths.require_full_followup).ReadmissionPredictionMIMIC4only makes samples for admissions followed by another admission, skips visits missing any of the three code types, and drops patients under 18.EthosOutcomeMEDSneeds a MEDS task whose stays and exclusions it can cut ETHOS timelines from, so it builds onHospitalReadmissionMEDS, not on the MIMIC-IV task.Not included
EthosRolloutRule) but has no matching label task yet.metrics.py.Changes to the parents' code (on this branch only)
EthosProcessorgainsinterval_estimatesinfit,saveandload.meds_outcome_tasks.pyis no longer changed here. Its_rows_at_admission/_rows_at_dischargerefactor moved to Add MEDS ICU admission, readmission and prolonged stay tasks #1395, and the file is now identical to Add MEDS ICU admission, readmission and prolonged stay tasks #1395's.Links to other components
ethos_tasks.pyusesmeds_outcome_tasks.py(Add MEDS ICU admission, readmission and prolonged stay tasks #1395):EthosOutcomeMEDSwrapsICUAdmissionMEDS,HospitalReadmissionMEDSandProlongedLengthOfStayMEDS, and calls_load_events,_completed_stays,_rows_at_admissionand_rows_at_discharge, plus theICU_ADMISSION_PREFIXconstant. Kept: these helpers are the cohort, label and leakage logic (stays fromhadm_id, the midnight rule, the ICU and same-time exclusions, in-stay death). The zero-shot labels must stay identical to the supervised tasks' for the comparison to mean anything, so copying would duplicate real logic that has to stay in step.ethos_tasks.pyusesethos_processor.py(Add EthosProcessor, the ETHOS timeline tokenizer for MEDS #1393):STATIC_CODE_PREFIXESandTIMELINE_END_TOKEN. Kept: the task must leave out exactly the codes the processor excludes and stop on the token the processor emits, so both have to come from one place.ethos_context_processor.pyusesethos_processor.py(Add EthosProcessor, the ETHOS timeline tokenizer for MEDS #1393):STATIC_CODE_PREFIXESand theEthosVocabclass. Kept: the context processor encodes exactly the codes the timeline processor drops, and the two ETHOS processors share one vocabulary class so they save the same JSON form. Both are ETHOS components from this stack.ethos.pyusesethos_processor.py,ethos_context_processor.pyandethos_tasks.py: the processors' vocabularies andinterval_estimates,TIMELINE_END_TOKEN, andEthosRolloutRulewith its stop reasons. Kept: these are the model's own inputs and rollout rules.ethos_tasks.pynow definesADMISSION_PREFIX,DISCHARGE_PREFIX,DIED_CODEandDEATH_CODEitself. It used to import the first three fromin_hospital_mortality_meds.pyandDEATH_CODEfromethos_processor.py.ConceptVocabfromcehr_processor.pyis no longer used by either ETHOS processor: Add EthosProcessor, the ETHOS timeline tokenizer for MEDS #1393 now has its ownEthosVocab, andEthosContextProcessoruses that.Remaining shared-code changes
None outside the new files. The only edits to existing files add exports and docs entries:
pyhealth/models/__init__.py,pyhealth/processors/__init__.py,pyhealth/tasks/__init__.pyanddocs/api/{models,processors,tasks}.rst.Updated to master
Merged the updated #1393 (
15aa1df) and #1395 (3de46e1, then5f3a65f, which only adds docstring notes), which both includeorigin/masterat be1ecbf (#1383); a finalgit merge origin/masterwas then already up to date.pyhealth/models/__init__.py(master added KnowRare, APRICOT-M and SelectiveSSM at the same place asETHOS; kept master's lines and addedETHOSafter them) andpyhealth/processors/ethos_processor.py(Add EthosProcessor, the ETHOS timeline tokenizer for MEDS #1393'sEthosVocabagainst this branch'sinterval_estimates; kept both).BaseModel.modeis now a read-only property worked out from the label processors, soETHOS.__init__'sself.mode = NoneraisedAttributeError. That line is gone. With an emptyoutput_schemathe model has no label processor andmodeisNone, soTrainerstill reports loss only. A labelled dataset now raises a clearValueErrorup front (new test). The outcome tasks keep their"binary"labels, whichestimate_riskreturns asy_true. Nothing else in the model used the removedBaseModelmethods.Testing
After the master merge. At
79af6ea:check_pr_rulesagainst all three bases,ruff, and 147 passed, 1 skipped acrosstest_ethos.py,test_ethos_tasks.py,test_ethos_context_processor.py,test_ethos_processor.py,test_meds_outcome_tasks.pyandtest_in_hospital_mortality_meds.py. The rest below ran at15b15af; the commits since then change only docstrings and tests:tools/check_pr_rules.py: passed with--base origin/master,--base feat/ethos-tokenizerand--base feat/meds-outcome-tasks.ruff checkon the new Python files, tests and examples: passed.TestSetTaskintest_ethos_tasks.py:EthosTimelineMEDSandEthosOutcomeMEDSthroughMEDSDataset.set_taskon synthetic Parquet in a temp dir. It checks that both ETHOS processors are fitted, that the outcome task reuses the timeline vocabularies, and thatdeath_as_positive=TrueandFalsegive their own cached labels. The class setup takes about 1.1 s (dataset build), and the tests themselves take about 0.1 s.15b15af: 196 tests passed acrosstest_ethos.py,test_ethos_tasks.py,test_ethos_context_processor.py,test_ethos_processor.py,test_meds_outcome_tasks.pyandtest_label_processor.py.test_processor_schemas,test_processor_transfer,test_vocab_processors,test_in_hospital_mortality_meds,test_meds,test_ehrmamba_cehrandtest_event_tie_order.ethos.py,ethos_tasks.py(2 skipped),ethos_context_processor.pyandethos_processor.py.examples/ethos_zero_shot.py,ethos_timeline_tokenizer.pyandmeds_outcome_tasks.pyall ran.Not run: the full test suite, the Sphinx docs build, and anything on real data or a GPU. The model was never compared numerically with
ethos-ares, since the reference repo is read-only here.Four
TestSetTasktests from #1395 take about a second each, slightly over the fast-test limit. The new tests are all under a second.Questions for the authors
icu_admission.ipynbcounts deaths as positive. Which should be the default here?HOSPITAL_DISCHARGE//DIEDcount as a death, given that codes are kept whole?🤖 Generated with Claude Code