Repository navigation
docs: add custom ensemble example and fix Sphinx warnings - #1360
joshb-code wants to merge 4 commits into
Conversation
- Show how to subclass BaseInterpreterEnsemble and implement _ensemble on the ensemble page, since autodoc hides private methods. - Escape |B| in the Comprehensiveness/Sufficiency docstrings, which Sphinx parsed as an undefined substitution reference. - Lengthen the "Interpretability" heading underline in interpret.rst. Follow-up to sunlabuiuc#1341; addresses sunlabuiuc#324 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
/review |
Test CoverageTotal: 74.97% (21247 / 28339 lines)
|
There was a problem hiding this comment.
Previous review
AI Review
suggestion: approve
decision: approve
Thank you for this contribution, Joshua. The new "Writing a custom strategy" section makes the _ensemble signature and tensor shapes visible, which autodoc hides. The Sphinx warning fixes are also useful.
The change looks ready to merge.
- The example matches the base class contract:
_ensembletakes(B, I, M)and returns(B, M). - Escaping
|B|as\\|B\\|in the non-raw docstrings gives\|B\|in RST, which fixes the substitution-reference error. The existing\\in the same docstrings confirms they are non-raw. - The heading underline now matches the title length.
- Coverage: the two modified metric files are at 100%, and the repository total is 74.72%. Both are above the bar (80% per file, 60% overall). No new behavior is added, so no new tests are needed.
Optional suggestions:
- The snippet uses
modelandbatchwithout defining them. A one-line comment saying where they come from would help readers. - You said you ran the example with
RandomBaselineexperts, but the snippet uses IntegratedGradients, DeepLift and LimeExplainer. Consider making the two match, or noting that any experts work.
Reviewed commit 757738f
Address review feedback on sunlabuiuc#1360: state what `model` and `batch` are in the custom ensemble example. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
/review |
There was a problem hiding this comment.
AI Review
suggestion: approve
decision: approve
Thank you for this contribution. The new "Writing a custom strategy" section makes the _ensemble signature and tensor shapes visible, which autodoc hides. The docs-warning fixes are also welcome. The change looks ready to merge.
Coverage: the whole repository is at 74.97%, above the 60% bar. The changed files under pyhealth/ are at 100%. Tests aren't expected for a docs-only change like this.
Optional suggestions:
- In the two docstrings, the source now has
\\\\|B\\\\|. In a non-raw string that produces two backslashes in the docstring text. Sphinx may then show a literal backslash in the rendered formula. Using\\|B\\|in the source would give a single backslash that escapes the|and renders as|B|. Please check the rendered HTML to confirm which you get. - The example comment says
modelis "a trained PyHealth model".DeepLiftrequires a model that implementsInterpretable, so a short note about that would help readers. - You ran the example with
RandomBaselineexperts, not the IG, DeepLift and Lime experts it shows. Consider saying so, or checking it once with the real experts.
Reviewed commit 8d428a6
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor: Joshua Sebastian (joshb-code)
Contribution Type: Documentation
Description: Follow-up to #1341 (addresses the remaining review suggestion) and #324:
BaseInterpreterEnsembleand implement_ensemble(autodoc hides private methods, so the signature and tensor shapes were not visible). I ran the example with threeRandomBaselineexperts; it returns the expected shapes.|B|in theComprehensivenessMetricandSufficiencyMetricdocstrings was parsed as an undefined substitution reference; it is now escaped.docs/api/interpret.rst(Sphinx "Title underline too short" warning).I rebuilt the docs locally; these three warnings/errors no longer appear. Docstring changes are formula-line only (2 lines).
Files to Review:
docs/api/interpret/pyhealth.interpret.methods.ensemble.rst- new example sectiondocs/api/interpret.rst- heading underlinepyhealth/metrics/interpretability/comprehensiveness.py- escape|B|pyhealth/metrics/interpretability/sufficiency.py- escape|B|🤖 Generated with Claude Code