Skip to content

docs(notebook): Improve notebook for v3#960

Merged
adrian-prior merged 3 commits into
mainfrom
adrian/fix-example-notebook
May 12, 2026
Merged

docs(notebook): Improve notebook for v3#960
adrian-prior merged 3 commits into
mainfrom
adrian/fix-example-notebook

Conversation

@adrian-prior
Copy link
Copy Markdown
Contributor

@adrian-prior adrian-prior commented May 12, 2026

Summary

Updates to examples/notebooks/TabPFN_Demo_Local.ipynb:

  • Shapley Values section (cells 34–36): switches from the legacy interpretability.shap adapter (classic shap library + PermutationExplainer) to shapiq via get_tabpfn_imputation_explainer. Same imputation paradigm, but using shapiq's native bar_plot, beeswarm_plot, and plot_force. Surrounding markdown rewritten to explain shapiq and link to shap_example.py in tabpfn-extensions for the classic-shap path.
  • KV cache enabled on the SHAP demo classifier (fit_mode="fit_with_cache") since shapiq issues many predict_proba calls against the same training set. Markdown notes that this is local-only — for the client backend, drop the flag (slower).
  • Switched the explainer to imputer="baseline" for a better speed/quality trade-off, kept n_estimators=8 with a comment about throughput on stronger GPUs, and right-sized the demo split to n_samples_test=5, n_samples_train=200.
  • Feature selection cell (cell 40): added cv=3 to feature_selection(...) to make the example reproducible without depending on the library's default CV setting.
  • Time-series install cell (cell 53): removed the raise ValueError(...) that interrupted the run after install; replaced with a clearer markdown note telling the reader to restart the runtime before continuing.
  • Causal-inference install cell (cell 73): switched !pip install!uv pip install for consistency with the rest of the notebook.
  • Added a small Feedback cell at the end pointing readers to Discord and GitHub.

Test plan

  • Run the updated Shapley Values cell end-to-end (Colab GPU or local CUDA) and confirm the bar, beeswarm, and force plots render.
  • Run the feature selection cell and confirm it executes with cv=3.
  • Re-run the time-series section: install cell completes, then after a runtime restart the rest of the section runs cleanly.
  • Re-run the causal inference install via uv pip and confirm both tabpfn and econml are picked up.
  • Quick top-to-bottom smoke run of the notebook to confirm no broken imports were introduced.

🤖 Generated with Claude Code

Switch the Shapley Values cell from the legacy `interpretability.shap`
adapter (classic shap library + PermutationExplainer) to the `shapiq`
adapter via `get_tabpfn_imputation_explainer`. This produces equivalent
bar/beeswarm/force plots through shapiq's native plotting and aligns the
notebook with the currently recommended path in tabpfn-extensions.

Also enable TabPFN's KV cache (`fit_mode="fit_with_cache"`), since the
explainer triggers many `predict_proba` calls against the same training
set — a clear speedup for SHAP-style workloads.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@adrian-prior adrian-prior changed the title docs(notebook): modernize SHAP section in TabPFN_Demo_Local docs(notebook): Improve notebook for v3 May 12, 2026
@adrian-prior adrian-prior requested a review from LeoGrin May 12, 2026 13:33
adrian-prior and others added 2 commits May 12, 2026 15:34
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Colab wrote `metadata.widgets["application/vnd.jupyter.widget-state+json"]`
without the required `state` wrapper, which trips GitHub's nbviewer:

  > the 'state' key is missing from 'metadata.widgets'

The entries were leftover runtime widget state (e.g. tqdm bars) from
cached outputs and carry no user-facing content — dropping the whole
key restores rendering on GitHub.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@LeoGrin LeoGrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!!

@adrian-prior adrian-prior marked this pull request as ready for review May 12, 2026 13:38
@adrian-prior adrian-prior requested a review from a team as a code owner May 12, 2026 13:38
@adrian-prior adrian-prior requested review from oscarkey and removed request for a team May 12, 2026 13:38
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@adrian-prior adrian-prior enabled auto-merge May 12, 2026 13:38
@oscarkey oscarkey removed their request for review May 12, 2026 13:38
@adrian-prior adrian-prior added this pull request to the merge queue May 12, 2026
Merged via the queue into main with commit bdc2c31 May 12, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants