Repository navigation
Add SEER dataset and 12-month survival prediction - #1561
Conversation
Test CoverageTotal: 88.35% (58458 / 66164 lines)
|
|
/review |
There was a problem hiding this comment.
Previous review
AI Review
suggestion: approve
decision: human review
Thank you for this contribution. It adds a SEER dataset loader, a fixed-horizon survival task, a fitted feature encoder, and a reproducible example that compares majority, logistic regression and MLP models. It also includes a grouped ablation. It looks ready to merge.
Coverage meets the bar. The whole repository is at 86.06%, against the 60% bar. seer.py is at 92.19%, seer_processor.py at 95.35% and seer_survival.py at 96.97%. Both __init__.py files are well above 80%.
The dataset, task and processor are self-contained. The only links are the example's reuse of PyHealth's LogisticRegression, MLP and Trainer, which your description states. The __init__.py changes only add exports. The paper is cited in the module docstrings and the README, and the docs page links to SEER data access.
Optional suggestions:
- Task docs wording: the task page says to pass
split="at task creation". The code passes it todataset.set_task(task, split=split), so please reword that sentence to match. - Numeric encoding: in
numericmode, tumor-size special codes such as 991 and 999 are standardized as if they were millimetres. This is arguably faithful to the paper's raw-code baseline. A sentence in the docs saying so, or a test that pins the behaviour, would make it clearer. - Reduced feature set test: a small test of
SEERFeatureProcessorwithinclude_extent=Falsewould cover that path directly. - Binary session file:
Lung_2004_2009_current.ssis committed as a binary. Please confirm it contains no local paths or user information. A short note in the README about what it contains would also help.
Reviewed commit 8ea3065
- Document that numeric encoding standardizes special codes such as tumor size 999 as numbers, and pin it with a test. - Test that include_extent=False removes extent fields from the fitted processor. - Say that split= goes to dataset.set_task in the task docs. - Add Args/Returns/Raises to SEERSurvivalPrediction.__call__ and SEERFeatureProcessor.fit/process. - Wrap the 90-character stage pattern line in seer.py. - Note in the example README that the SEER*Stat session holds no patient records or local paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/review Generated by Claude Code |
There was a problem hiding this comment.
Previous review
AI Review
suggestion: need change
decision: human review
Thank you for this contribution. It adds a SEER*Stat Case Listing dataset, a 12-month survival task, a training-only feature processor, docs, tests and a reproducible benchmark with an ablation. It is close. The tests are thorough, and coverage meets the bar: the whole repository is at 86.26%, and the new files are at 92.19% (seer.py), 95.35% (seer_processor.py) and 96.97% (seer_survival.py).
To get this merged:
SEERFeatureProcessorinpyhealth/processors/seer_processor.pysubclasses the existingTensorProcessor, and the description doesn't mention this. Please do one of two things. Either confirm the sharing is intended and say why in the description, for example to reuse its dtype andprocesscontract. Or keep the processor self-contained by deriving from the base processor class instead, or by copying what you need.- If you keep the subclass, please check the inherited methods.
fitis overridden and doesn't set the attributes the parent'sdim()andspatial()rely on, so those inherited calls may raise. Either set those attributes infitor override the methods.
Optional suggestions:
SEERDataset._scan_tablereads the whole export into memory before caching. A note in the docs would help users with large exports.- The task docs could say plainly that all unseen categories in a field share one indicator column, which is separate from the blank and special-size columns.
Reviewed commit 82444bd
- SEERFeatureProcessor subclasses TensorProcessor to reuse its float dtype, size()/process() contract and learns_statistics handling. Its fit now sets _n_dim, so the inherited dim() and spatial() report one flat vector instead of raising; a test covers this. - Say in the task docs that all unseen categories of a field share one indicator column. 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: human review
Thank you for this contribution. It adds a SEER*Stat Case Listing dataset, a fixed-horizon survival task, a split-aware feature processor, tests, docs and a reproduction example. It is self-contained and well tested. Coverage looks good: the added files are at 92.19% (seer.py), 95.4% (seer_processor.py) and 96.97% (seer_survival.py), and the whole repository is at 87.17%.
To get this merged:
- Fix the numeric-encoding documentation so it matches the code.
docs/api/tasks/pyhealth.tasks.SEERSurvivalPrediction.rstsays the numeric encoding uses "verified exported codes" for primary site. The README also says the numeric baseline "uses verified native codes". Inseer_processor.py,_numeric_valueonly uses the value as a number when it is purely decimal. Formatted primary-site values such asC341, as in your fixture, go down the ordinal-category path instead. Either update the docs and README to say which fields use native numeric codes (histology, extension, nodes, metastases and size) and that primary site is ordinal-coded for formatted exports, or change the code to match. Please also check that the README's description of the real-data numeric results is accurate.
Optional suggestions:
- A blank line in the export currently aborts the loader with a "Wrong number of fields" error. Skipping blank rows would be friendlier.
tests/core/conftest.pywrites the internalglobal_event_df.parquetcache file directly. Going through a public path would be less brittle.- Add tests for the one-hot
include_extent=Falsepath and for the BOM and cp1252 encoding detection. - Consider adding the paper link to the
SEERDatasetclass docstring or to its docs page. It is currently only in the module docstring. The SEER access link is already in the docs.
Reviewed commit 04898bf
|
Why this PR has
To make it eligible for automatic review:
#1667 (opened today) adds another SEER dataset and survival task. Yours came first and is closer to ready, so we've suggested that #1667 build on this one. Once that's pushed, we'll switch the label to |
|
Picked as PyHealth's SEER dataset and survival task. We compared this with #1667. Yours:
It was also opened first. What's left are the fixes from my earlier comment:
After that, we'll move it to |
- Remove tests/core/conftest.py. Each SEER test module defines its own seer_dataset fixture, and the fixture builds the event cache through the public global_event_df property instead of writing the parquet file by hand. - Move the synthetic export to test-resources/core/seer/ and update the test and docs paths. - Say in the task docs and README which fields numeric encoding uses as numbers: primary site is numeric only when exported as digits (as in the real export, e.g. 341); a formatted value such as C341 gets an ordinal code. No code or results change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves the import conflict in pyhealth/datasets/__init__.py by keeping both SEERDataset and the new HIRIDDataset imports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Good news: the reasons this PR had |
|
/review |
| Use ``encoding="numeric"`` for the standardized numeric baseline. The | ||
| processor uses the numeric diagnosis year and size, and uses primary site, | ||
| histology, extension, lymph nodes, and metastases as numbers when their | ||
| exported values are all digits (for example primary site ``341``). Any other |
There was a problem hiding this comment.
[low] Numeric-encoding wording implies a field-level rule that the code does not apply
The text says the numeric baseline uses primary site, histology, extension, lymph nodes and metastases as numbers "when their exported values are all digits". In pyhealth/processors/seer_processor.py:133 (_numeric_value) the check is made per value, not per field. A field that mixes "341" with "C341" therefore puts digit values on the raw code scale and the other values on ordinal indices in one standardized column. Reword the sentence to say the choice is made per value, or make the choice per field in fit() so the doc is accurate.
| The inputs are an explicit list of diagnosis-time fields. It includes | ||
| diagnosis year, primary site, sex, age group, histology, grade, laterality, | ||
| marital status, AJCC stage group, tumor size, extension, lymph nodes, and | ||
| metastases. The site cohort filter, survival outcomes, follow-up fields, |
There was a problem hiding this comment.
[low] Site cohort filter is described but not applied or checked
The text refers to a "site cohort filter" as being outside the feature list. Neither SEERDataset nor SEERSurvivalPrediction filters or validates the Site recode field, so a non-lung export is accepted silently and labelled as the same task. The lung-only cohort exists only in the external SEER*Stat session described in the example README. Say explicitly that the caller must export the lung cohort, or check the site value in the dataset loader.
| return float(number) | ||
|
|
||
|
|
||
| class SEERFeatureProcessor(TensorProcessor): |
There was a problem hiding this comment.
[low] Subclassing TensorProcessor makes transform_processor bridge it with TensorProcessor's converter
SEERFeatureProcessor inherits from TensorProcessor, so the MRO lookup in pyhealth/processors/unified_bridge.py:1037 gives it TensorToUnifiedBridge. The subclass overrides fit and process entirely and never sets the fields that bridge reads (_shape stays None). A flat vector probably still converts correctly, but I did not verify the bridged output. Either give the processor an explicit bridge, or subclass a base that is not a concrete processor. This does not block the merge.
There was a problem hiding this comment.
AI Review
suggestion: approve
decision: approve
Thank you for this contribution. It adds a SEER*Stat Case Listing dataset, a fixed-horizon 12-month survival task, and a train-fitted one-hot and numeric feature processor. It also adds a benchmark and ablation example with aggregate results, API docs, and tests. It looks ready to merge.
- Code and docs: The dataset, task and processor are self-contained. They only register new exports in the package init files and reuse the generic TensorProcessor base. The dataset cites the Hegselmann et al. paper in its module docstring and in the docs. The docs match the code.
- Tests: Coverage meets the bar. The new files are at 92.2% (seer.py), 95.4% (seer_processor.py) and 97.0% (seer_survival.py). The repository total is 88.35%, above the 60% guideline.
- Redundancy: PyHealth has no existing SEER dataset or task, so nothing is duplicated.
Optional suggestions:
- Description paths: The description mentions tests/core/conftest.py and tests/fixtures/seer/. The diff has neither. The fixture is at test-resources/core/seer/, so please update the description.
- Site cohort filter: The task docs refer to a "site cohort filter". Neither the dataset nor the task applies one, so a non-lung export would load without complaint. Either state that the cohort is chosen in SEER*Stat, or add a filter.
- Numeric encoding wording: The docs describe the numeric-encoding rule as if it applied per field. The code decides per value: a digits-only value is used as a number, and anything else gets an ordinal code. Rewording the docs would make this clearer.
- Session file: I couldn't inspect the binary Lung_2004_2009_current.ss file. Please check that it holds no local paths or user details.
Reviewed commit 23d7c0f
Contributors
Contribution type
Dataset + task for CS 598. The experiment reuses PyHealth's logistic regression
and MLP.
Original paper
Hegselmann et al. (2018), Reproducible Survival Prediction with SEER Cancer
Data. Paper
Description
This contribution adds support for locally exported SEER*Stat Case Listings
and fixed-horizon cancer survival prediction. The example reproduces the
12-month lung and bronchus comparison using the November 2025 SEER release.
It fits numeric and one-hot encoders on training patients and compares a
majority baseline, logistic regression, and an MLP.
On 20,446 held-out patients, the one-hot MLP achieved 0.8349 ROC-AUC, 0.7143 F1,
and 0.7627 accuracy. Removing AJCC stage, tumor size, extension, lymph nodes,
and metastases lowered ROC-AUC by 0.1146 on average over three matched model
seeds. The available Case Listing determined the feature group for this
ablation. The accompanying results explain the differences between the
current-release experiment and the paper's November 2016 experiment.
Files to review
pyhealth/datasets/seer.pyandpyhealth/datasets/configs/seer.yamlload,validate, and group tumor events by patient.
pyhealth/tasks/seer_survival.pycreates labels and diagnosis-time samples.pyhealth/processors/seer_processor.pyfits the two feature encodings.pyhealth/datasets/__init__.pyandpyhealth/tasks/__init__.pyexpose thedataset and task.
examples/seer_survival_mlp.pyruns the benchmarks and grouped ablation.examples/seer_survival/includes the setup, findings, aggregate scores,and saved cohort settings.
tests/core/test_seer_dataset.pyandtests/core/test_seer_survival.pycoverdata loading, patient grouping, eligibility, features, and split-aware
preprocessing.
tests/core/conftest.pyandtests/fixtures/seer/supply thefour-patient fixture.
docs/api/datasets/pyhealth.datasets.SEERDataset.rstanddocs/api/tasks/pyhealth.tasks.SEERSurvivalPrediction.rstdescribe usage,with links from the respective API indexes.
Verification
The tests and synthetic example use generated data. The Case Listing and
patient-level caches stay in approved local storage.