From 1287497d142d499312079461e281f4e1cf14c587 Mon Sep 17 00:00:00 2001 From: joshb-code Date: Thu, 29 Oct 2026 16:25:39 -0400 Subject: [PATCH] docs: fix docstring examples for RandomBaseline and CrhEnsemble RandomBaseline's example imported a nonexistent `Random`; use the exported `RandomBaseline`. CrhEnsemble's example imported nonexistent `GradientShap` and `Saliency`; use the exported IntegratedGradients, DeepLift and LimeExplainer, matching the other ensemble examples. Follow-up to #1341; addresses #324 Co-Authored-By: Claude Sonnet 5.5 --- pyhealth/interpret/methods/baseline.py | 4 ++-- pyhealth/interpret/methods/ensemble_crh.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyhealth/interpret/methods/baseline.py b/pyhealth/interpret/methods/baseline.py index 67629c516..8c00570c1 100644 --- a/pyhealth/interpret/methods/baseline.py +++ b/pyhealth/interpret/methods/baseline.py @@ -44,7 +44,7 @@ class RandomBaseline(BaseInterpreter): Examples: >>> import torch >>> from pyhealth.datasets import create_sample_dataset, get_dataloader - >>> from pyhealth.interpret.methods.baseline import Random + >>> from pyhealth.interpret.methods import RandomBaseline >>> from pyhealth.models import MLP >>> >>> samples = [ @@ -64,7 +64,7 @@ class RandomBaseline(BaseInterpreter): >>> model.eval() >>> test_loader = get_dataloader(dataset, batch_size=1, shuffle=False) >>> - >>> rand_interp = Random(model, random_seed=42) + >>> rand_interp = RandomBaseline(model, random_seed=42) >>> batch = next(iter(test_loader)) >>> attributions = rand_interp.attribute(**batch) >>> print({k: v.shape for k, v in attributions.items()}) diff --git a/pyhealth/interpret/methods/ensemble_crh.py b/pyhealth/interpret/methods/ensemble_crh.py index 2a901eb9b..a8889c841 100644 --- a/pyhealth/interpret/methods/ensemble_crh.py +++ b/pyhealth/interpret/methods/ensemble_crh.py @@ -47,8 +47,8 @@ class CrhEnsemble(BaseInterpreterEnsemble): between successive iterations is below this value. Example: - >>> from pyhealth.interpret.methods import GradientShap, IntegratedGradients, Saliency - >>> experts = [GradientShap(model), IntegratedGradients(model), Saliency(model)] + >>> from pyhealth.interpret.methods import DeepLift, IntegratedGradients, LimeExplainer + >>> experts = [IntegratedGradients(model), DeepLift(model), LimeExplainer(model)] >>> ensemble = CrhEnsemble(model, experts, n_iter=30) >>> attrs = ensemble.attribute(**batch) """