Add 10 new explainers and model specific explainability mixins#768
Draft
Irozuku wants to merge 6 commits into
Draft
Add 10 new explainers and model specific explainability mixins#768Irozuku wants to merge 6 commits into
Irozuku wants to merge 6 commits into
Conversation
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