Add 10 new explainers and model specific explainability mixins#768
Draft
Irozuku wants to merge 9 commits into
Draft
Add 10 new explainers and model specific explainability mixins#768Irozuku wants to merge 9 commits into
Irozuku wants to merge 9 commits into
Conversation
dice-ml pulls xgboost, which depends on nvidia-nccl-cu12 on linux. Plain uv sync installs the default PyPI torch (CUDA 13 build), whose libtorch_cuda.so needs nvidia-nccl-cu13; with both nccl packages installed the loader resolves the cu12 libnccl.so.2 and torch import fails with undefined symbol ncclCommResume. Sync with --extra cpu as publish.yml already does, and pass --no-sync to uv run so it does not re-sync back to the default (CUDA) torch build.
The 0.3.32 macos arm64 wheel on the llama-cpp cpu index is a corrupt zip (trailing bytes after end-of-central-directory) and uv refuses to extract it. Tests do not need llama_cpp (all imports are guarded), so exclude it from the CI install instead of pinning around the broken artifact.
Python 3.10/3.11 resolved shap 0.46.0 (0.52.0 needs python >= 3.12), which passes abstract dtypes like np.floating to numpy; numpy 2.3 made that a TypeError, breaking the kernel shap and contrastive explainer tests on 3.10/3.11 across all platforms. The floor moves those interpreters to shap 0.49.1. Verified the explainer suite passes on 3.11 with shap 0.49.1 and numpy 2.4.6.
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.
Summary
Grows the explainer catalog from 3 to 13, giving image classification, text classification, and regression their first explainers. Adds counterfactual and contrastive explainers for tabular classification. Model specific explainers are declared through new model mixins that also enforce the preprocessing contract image explainers need, keeping explainability responsibilities out of the core model API.
Type of Change
Changes (by file)
DashAI/back/explainability/explainers/: 10 new explainers, all emitting typed artifacts:contrastive_shap.py(why P rather than Q, SHAP deltas),nearest_counterfactual.py(nearest real training rows, highlighted table),dice_counterfactual.py(synthetic counterfactuals via dice-ml).grad_cam.py(CAM heatmap overlays, gradcam/gradcam++/eigencam),occlusion_saliency.py(probability drop maps, works on any torch image model).lime_text.py(word attributions),token_ablation.py(per token probability drop).regression_partial_dependence.py,regression_kernel_shap.py,regression_permutation_feature_importance.py.image_explainer_utils.py: shared white box helpers (torch module access, inference transform, plotly heatmap overlay).DashAI/back/models/image_explainable_model.py: newOcclusionSaliencyCompatibleModelandGradCamCompatibleModelmixins; they carry the explainerCOMPATIBLE_COMPONENTSentries and forceget_inference_transform()as an abstract method.DashAI/back/models/{base_torchvision_image_classifier,cnn_image_classifier,lenet5_image_classifier}.py: inheritGradCamCompatibleModeland implement the transform;mlp_image_classifier.pyinherits occlusion only (no conv layers).DashAI/back/models/scikit_learn/sklearn_like_classifier.py: declaresDiceCounterfactual(requirespredict_proba); all sklearn classifiers inherit it via the MRO merge.DashAI/back/initial_components.py: registers the 10 new explainers.DashAI/back/dependencies/registry/component_registry.py:get_related_componentsskips unregistered relation names (a model declaring an uninstalled plugin explainer no longer breaks component lookups).pyproject.toml/uv.lock: new dependenciesgrad-cam,dice-ml,lime.tests/back/explainers/test_{new_explainers,lib_explainers,image_explainers,task_explainers}.py: coverage for all 10 explainers with tiny or fake models (fast).Testing
uv run pytest tests/back/explainers tests/back/registries(46 tests).Notes