Repository navigation
C4: SHAP plots and per-locus top contributions - #14
Merged
Merged
Conversation
…he code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ibutions in infer explain.py computes exact TreeSHAP values with XGBoost's pred_contribs. visualize writes per-class summary plots, mean absolute SHAP per class and dependence plots as vector files (8 pt Helvetica kept as text), plus the values as CSV; gain/weight/cover only with --legacy_importance. infer adds each locus's three largest contributions to xgboost_judgement.csv. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TejusK123
added a commit
that referenced
this pull request
Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
C4: SHAP values, the default output of
AutoDeep visualizeThese replace the single decision trees of Figs 2-4. A single tree is one of the model's 2,949, so it says little about how the model as a whole uses a feature.
AutoDeep visualize(newexplain.py, using XGBoost's exact TreeSHAP viapred_contribs; no new dependency)plots<timestamp>/(previouslytree_plots<timestamp>/):shap_summary_<class>.pdf, one per class (the new Figs 2-4)shap_importance.pdf(mean absolute SHAP value per feature and class)shap_dependence_<feature>.pdffor 5' homogeneity, both overhangs and folding energyshap_values.csvandshap_importance.csv, the numbers behind the plots--data CSV...explains a run, e.g.AutoDeepRun/fully_formatted_data.csv(the default is the bundled training data).--format pdf|svg.--legacy_importancegives the old gain, weight and cover plots unchanged (Tejus's request).--treesis unchanged.<text>in SVG). Features carry their Table 1 names. All plots share one feature order.AutoDeepRun/folder in the current directory; nothing in visualize used it.AutoDeep infer:xgboost_judgement.csvgainsshap_top1_feature,shap_top1_value, ... up toshap_top3: each locus's three largest SHAP contributions to its predicted label, signed. Tejus asked whether one header would do, so I checked first. On the training data, the 2,907 loci have 458 different ordered top-three lists, and the most common covers 8%; on Pomonella, 65 lists across 212 loci. So the columns are per locus. The infer help now names the output file correctly (xgboost_judgement.csv, notAutoDeep_results.csv).Tests (written first; all 13 failed before the code)
tests/test_explain.py: SHAP values add up to the raw scores; blanks get values; the top three are the largest by size for the predicted class; every feature has a Table 1 name.tests/test_visualize.py: the default files and tables;--legacy_importance; PDF text as embedded TrueType; SVG text as text;--datawith blank overhangs.tests/test_inference_columns.py: the top-three columns match the SHAP values.tests/test_example.py: the tutorial's expected output, regenerated, has the new columns; their values are compared with a 1e-5 tolerance because XGBoost's arithmetic differs slightly between Linux and Mac. The old columns are unchanged.I rendered every figure for the shipped model on the training data and checked each one by eye. That led to two fixes: "|SHAP|" read as "lSHAPl" in Helvetica, and the colour bar was too heavy.
Paper: METHODS_CHANGES.md (C4) has the old text, the new Methods text and a note on the Results paragraph that reads the trees. Make the paper's figures after D1 retrains the model.
Results. Locally, with the testing folder: 150 passed. CI: see the checks below.
🤖 Generated with Claude Code