Repository navigation
Conversation
Test CoverageTotal: 70.04% (18755 / 26778 lines)
|
This was referenced Oct 20, 2026
solarsys
force-pushed
the
feat/autoimprove-clinical
branch
2 times, most recently
from
October 23, 2026 09:18
f42fe88 to
dd5f866
Compare
…ion, report) A run now ends with a report that explains the selected model and how the search got there, built from the decision log alone. - Decision log: every trial records the proposer's rationale and expectation (written before it runs), the trial it was changed from and what changed. LLM proposers are asked for both. - Selection: among the trials that beat the baseline consistently across folds, the most interpretable one within one paired SE of the best (the one-SE rule, select_simplest). Models sit on an interpretability ladder (SearchSpace.rung): logistic regression, depth-1 XGBoost (additive, now in the space), shallow trees and MLPs, then deeper trees and sequence models. one_se=False keeps the highest-lower-bound rule. - Plain words: every model has a description and every setting a meaning (Param.meaning, SearchSpace.explain). - AutoImprover.attribute(): reverts each changed setting of the selected trial one at a time and scores it on the same folds. - evaluate_on_test() also scores the highest-scoring candidate when a simpler one was selected, and saves test.json. - AutoImprover.report() / load_run(): HTML, Markdown and JSON with the summary, task, model and why (candidates, ladder, price of interpretability, attribution), test comparison and reasoning trace (timeline, every trial with hypothesis, change, result and verdict, single-setting comparisons, lessons). Statements are labelled measured, tested or hypothesis; numbers in lessons that match nothing in the log are flagged (unverified_numbers). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ntMLEmFsQEQJKTmPGGw4T
A run's report now explains how the selected model decides and how it would perform in clinical use, and lists what a clinician must decide. - pyhealth.tasks.TaskCard and the optional BaseTask.task_card() hook: the task's design choices with their rationale, and a feature dictionary (meaning, clinical group, expected direction of effect). - pyhealth.metrics.clinical: alert_rate_metrics (sensitivity, PPV and number needed to evaluate when the top 5/10/20% of risk is flagged), net_benefit (decision curve), calibration_bins, subgroup_metrics and clinical_summary; counts below 11 patients are suppressed. - AutoImprover(task_card=...); explain(): exact TreeSHAP for trees, integrated gradients for torch models (exact for logistic regression); importance by clinical group, top features with effect shapes in bins of at least 11 patients, learned vs expected direction, and the top-feature overlap of the fold models. - evaluate_on_test(subgroups=...) adds the clinical summary per config. - flags() and approve(): a missing card, undescribed top features, effects opposite to the expected direction, poor calibration and subgroup gaps; decisions are kept in review.json. - The report gains How it decides, Performance in clinical terms, Clinician review and a TRIPOD+AI reporting checklist; load_run reads the new files. The eICU example has a task card and age/sex subgroups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ntMLEmFsQEQJKTmPGGw4T
solarsys
force-pushed
the
feat/autoimprove-clinical
branch
from
October 25, 2026 15:20
dd5f866 to
d1e5f76
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1317, which is stacked on #1316. Until those merge, the diff includes them; review the last commit,
autoimprove: clinical explanation, clinical performance and review.Why
#1317 explains why a model was selected. A clinician also needs to know three more things:
This PR adds those, plus the items a clinician must sign off before use.
What changes
pyhealth.tasks.TaskCardand an optionalBaseTask.task_card()hook (defaultNone). The card records:+,-, U-shaped, or none).pyhealth.metrics.clinical, usable on its own, for example by the clinical benchmark's metrics step (I-03):alert_rate_metrics: sensitivity, PPV and number needed to evaluate when the top 5, 10 or 20% of risk is flagged;net_benefit: the decision curve;calibration_binsandsubgroup_metrics;clinical_summary, which runs all of the above.Any count below 11 patients is suppressed (the HIPAA/CMS small-cell convention), counted in distinct patients.
AutoImprover(task_card=...)andexplain(). Attributions come from exact TreeSHAP for trees and from integrated gradients for torch models, which is exact for logistic regression; numeric tensor and time-series fields are covered.explain()reports:evaluate_on_test(subgroups=...)adds the clinical summary for each config.flags()/approve(). Flags cover:Decisions are recorded in
review.json.The report gains How it decides, Performance in clinical terms, Clinician review, and a checklist of where it covers the main TRIPOD+AI items.
Tried on the eICU 48 h mortality task (open demo data)
The example now has a task card for all 88 tabular columns, plus age-band and sex subgroups.
Tests
tools/check_pr_rules.py.🤖 Generated with Claude Code
https://claude.ai/code/session_015ntMLEmFsQEQJKTmPGGw4T