Repository navigation
Integrate Synthea with PyHealth - #1244
heraclitus007 wants to merge 8 commits into
Conversation
jhnwu3
left a comment
There was a problem hiding this comment.
I like the idea of a Synthea dataset here, but it feels to me we need a SyntheaGenerator(BaseModel) instead here.
- Synthea (was SyntheaGenerator) now lives in pyhealth/models/generators/synthea.py and subclasses BaseModel; it has no trainable parameters and forward() raises. - SyntheaCSVDataset takes a root path and no longer imports the model. - Pinned release settings are inlined as _SyntheaRelease, replacing synthea_release.yaml. - Java 17+ is documented as a prerequisite and its version is checked before running; an older Java fails with a clear error. - Add API docs for both classes; rename tests to test_synthea.py. - Stop tracking generated .artifacts/ output (now gitignored) and remove the SYNTHEA_COMPLIANCE.md working checklist. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@jhnwu3 Thanks for the review. I've restructured along those lines: Generator is now a model: pyhealth.models.Synthea lives in pyhealth/models/generators/ next to HALO/MedGAN and subclasses BaseModel. Since Synthea is a rule-based Java simulator, it has no trainable parameters; forward() raises with a pointer to run() / ensure_generated(), which write CSVs to disk. Dataset stays a dataset: pyhealth.datasets.SyntheaCSVDataset(root) loads any Synthea CSV export and no longer depends on the model. Java: Java 17+ is a documented prerequisite, and the version is checked up front with a clear error. Housekeeping: API docs added for both classes; generated artifacts removed from the PR. |
|
Thank you for this! The synthea dataset format is a bit different from the existing dataset formats, would it be possible to write some more quick docs / examples to emphasize the differences so that people don't get confused? I think the existing dataset format is like a dataframe with columns: patient_id, time, code. SYNTHEA looks like it generates a lot more than that. Could be potentially confusing if documentation isn't clear, |
- Synthea's constructor now only configures the generator (output_dir, java_path, jar_path, auto_download, timeout). Population settings move to generate(), so one instance can produce many populations. - generate() reuses existing output for identical settings unless overwrite=True. An omitted seed is chosen at random and logged, so seedless calls no longer collide on one output directory. - Remove run(), ensure_generated(), with_config(), regenerate, output_path() and resolved_output_path(). build_argv() remains as a dry run taking the same settings as generate(). - Reject exporter.baseDirectory in synthea_config; output location is set by output_dir. - Docs: setup (Java install, JAR download and cache, offline use) and quick start for Synthea; how Synthea data differs from other PyHealth datasets (raw tables, event shape, SNOMED-CT/RxNorm/LOINC/CVX codes) for SyntheaCSVDataset. - Rebuild and re-execute the end-to-end notebook for the new API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the feedback, everyone. I've pushed an update that addresses all three points. 1. Setup vs. generation (constructor / You're right that synthea = Synthea("./synthea-output") # setup only, nothing runs
small = synthea.generate(population=10, seed=1) # returns the CSV directory
large = synthea.generate(population=500, seed=2, state="Ohio")
dataset = SyntheaCSVDataset(small)
@john, on your question: Synthea is a stateless command-line program. Each 2. Setup docs The 3. How Synthea data differs (@andy) The
The end-to-end notebook has been rebuilt for the new API and re-run. |
Summary
Add first-class support for generating synthetic patient populations with Synthea and loading the resulting CSV data through PyHealth’s standard dataset API.
What this adds
This feature provides:
Files added or modified
Design decisions
Out of scope
Validation