shapiq.imputer.GenerativeConditionalImputer¶
- class shapiq.imputer.GenerativeConditionalImputer(model, data, x=None, *, sample_size=10, conditional_budget=128, conditional_threshold=0.05, normalize=True, categorical_features=None, method='generative', random_state=None)[source]¶
Bases:
ImputerA GenerativeConditionalImputer for the shapiq package.
The GenerativeConditionalImputer is used to impute the missing values of a data point by using the conditional distribution estimated with the background data.
- Variables:
empty_prediction – The model’s prediction on an empty data point (all features missing).
- Parameters:
Initializes the GenerativeConditionalImputer.
- Parameters:
model (
Any) – The model to explain as a callable function expecting a data points as input and returning the model’s predictions.data (
ndarray) – The background data to use for the explainer as a two-dimensional array with shape(n_samples, n_features).x (
ndarray|None) – The explanation point to use the imputer on.sample_size (
int) – The number of samples to draw from the conditional background data for imputation. Defaults to10.conditional_budget (
int) – The number of coallitions to sample per each point indatafor training the generative model. Defaults to16.conditional_threshold (
float) – A quantile threshold defining a neighbourhood of samples to drawsample_sizefrom. A value between0.0and1.0. Defaults to0.05.normalize (
bool) – A flag to normalize the game values. IfTrue(default), then the game values are normalized and centered to be zero for the empty set of features. Defaults toTrue.categorical_features (
list[int] |None) – A list of indices of the categorical features in the background data. Currently unused.method (
Literal['generative']) – The method to use for the GenerativeConditionalImputer. Currently only"generative"is implemented. Defaults to"generative".random_state (
int|None) – The random state to use for sampling. Defaults toNone.
- calc_empty_prediction()[source]¶
Runs the model on empty data points (all features missing) to get the empty prediction.
- Return type:
- Returns:
The empty prediction.
- init_background(data)[source]¶
Initializes the GenerativeConditionalImputer.
- Parameters:
data (
ndarray) – The background data to use for the imputer. The shape of the array must be (n_samples, n_features).- Return type:
- Returns:
The initialized imputer.
- value_function(coalitions)[source]¶
Computes the value function for all coalitions.
- Parameters:
coalitions (
ndarray) – A boolean array indicating which features are present (True) and which are missing (False). The shape of the array must be (n_subsets, n_features).- Return type:
- Returns:
- The model’s predictions on the imputed data points. The shape of the array is
(n_subsets, n_outputs).