shapiq.explainer.TabPFNExplainer¶
- class shapiq.explainer.TabPFNExplainer(model, data, labels, *, index='SV', max_order=1, x_test=None, empty_prediction=None, class_index=None, approximator='auto', verbose=False)[source]¶
Bases:
TabularExplainerThe TabPFN explainer as the main interface for the shapiq package.
The
TabPFNExplainerclass is the dedicated interface for theshapiqpackage and TabPFN Hollmann et al.[1] models such as theTabPFNClassifierandTabPFNRegressor. The explainer does not rely on classical imputation methods and is optimized for TabPFN’s in-context learning approach. The explanation paradigm for TabPFN is described in Rundel et al.[2]. In essence the explainer is a wrapper around the :class:~`shapiq.explainer.tabular.TabularExplainer` class and uses the same API.References
Initialize the TabPFNExplainer.
- Parameters:
model (
Any) – Either a TabPFNClassifier or TabPFNRegressor model to be explained.data (
ndarray) – The background data to use for the explainer as a 2-dimensional array with shape(n_samples, n_features). This data is used to contextualize the model on.labels (
ndarray) – The labels for the background data as a 1-dimensional array with shape(n_samples,). This data is used to contextualize the model on.approximator (
Union[Approximator,Literal['auto','spex','montecarlo','svarm','permutation','regression']]) – AnApproximatorobject to use for the explainer or a literal string from["auto", "spex", "montecarlo", "svarm", "permutation"]. Defaults to"auto"which automatically selects:KernelSHAPfor"SV",KernelSHAPIQfor"SII"/"k-SII",RegressionFSIIfor"FSII",RegressionFBIIfor"FBII", andSVARMIQfor"STII".index (
Literal['SV','SII','k-SII','STII','FSII','BV','BII','FBII']) – The index to explain the model with. Defaults to"SV"which computes the Shapley value. Options:"SV"(Shapley value),"k-SII"(k-Shapley Interaction Index),"FSII"(Faithful Shapley Interaction Index),"FBII"(Faithful Banzhaf Interaction Index, becomesBVfor order 1),"STII"(Shapley Taylor Interaction Index),"SII"(Shapley Interaction Index).max_order (
int) – The maximum order of interactions to be computed. Set to1for no interactions (i.e, for Shapley values"SV"or Banzhaf values"BV").x_test (
ndarray|None) – An optional test data set to compute the model’s empty prediction (average prediction) on. If no test data andempty_predictionis set toNonethe last 20% of the background data is used as test data and the remaining 80% as training data for contextualization. Defaults toNone.empty_prediction (
float|None) – Optional value for the model’s average prediction on an empty data point (all features missing). If provided, overrides parameters inx_test. and skips the computation of the empty prediction. Defaults toNone.class_index (
int|None) – The class index of the model to explain. Defaults toNone, which will set the class index to1per default for classification models and is ignored for regression models.verbose (
bool) – Whether to show a progress bar during the computation. Defaults toFalse. Note that verbosity can slow down the computation for large datasets.