Saltar al contenido principal

RegressionKernelShap

LocalExplainer
DashAI.back.explainability.explainers.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

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)

Defined on RegressionKernelShap

Compute 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)

Defined on RegressionKernelShap

Fit 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_data is 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]

Defined on RegressionKernelShap

Render 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

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It 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.

Compatible with