RegressionKernelShap
Model agnostic local explainer for regression via Kernel SHAP.
For each instance, estimates how much each feature value pushed the
model's numeric prediction above or below the expected (baseline) output,
using the Kernel SHAP weighted linear model over sampled feature
coalitions. The model is treated as a black box: only predict is
queried.
References
- [1] Lundberg, S.M. & Lee, S.I. (2017). "A Unified Approach to Interpreting Model Predictions." NeurIPS 30. https://arxiv.org/abs/1705.07874
- [2] https://shap.readthedocs.io/en/latest/generated/shap.KernelExplainer.html
Parameters
- fit_parameter_sample_background_data : boolean, default=
True - 'true' if background data must be sampled; otherwise the entire training set is used. Smaller datasets speed up the algorithm runtime.
- fit_parameter_background_fraction : number, default=
0.2 - If 'Sample background data' is selected, fraction of background samples to draw from the training set.
Methods
explain_instance(self, instances)
RegressionKernelShapCompute SHAP values for each instance.
Parameters
- instances : DatasetDict
- Instances to be explained.
Returns
- dict
- Dictionary with, for each instance, the model prediction, the baseline value and the per-feature SHAP values.
fit(self, background_dataset, sample_background_data=False, background_fraction=None, **kwargs)
RegressionKernelShapFit the Kernel SHAP explainer on background data.
Parameters
- background_dataset : Tuple[DatasetDict, DatasetDict]
- Tuple
(x, y)with the dataset splits; the train split is used as SHAP background data. - sample_background_data : bool
- True if the background data must be sampled.
- background_fraction : float
- Fraction of the training samples used as background data when
sample_background_datais True. - **kwargs : Any
- Ignored; present for interface compatibility.
Returns
- RegressionKernelShap
- The fitted explainer instance (
self).
plot(self, explanation: dict) -> List[DashAI.back.core.artifacts.GroupedArtifacts]
RegressionKernelShapRender each instance as a SHAP bar plot plus a text summary.
Parameters
- explanation : dict
- Dictionary with the explanation generated by the explainer.
Returns
- List[GroupedArtifacts]
- A single grouped artifact with one group per explained instance, each holding that instance's plotly plot and text summary.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.