ICEExplainer#
- class sdm.explain.ICEExplainer(grid_resolution: int = 20)#
Bases:
objectCompute individual conditional expectation (ICE) curves of feature columns from the “Peeking Inside the Black Box: Visualizing Statistical Learning with Plots of Individual Conditional Expectation” paper.
Each column is in turn set to every value of a grid in all query rows of a fitted model, which gives one curve of predictions per query row. Numerical and datetime grids are evenly spaced between the 5% and 95% quantiles of the column, and categorical grids hold its vocabulary.
- Parameters:
grid_resolution (int) – The number of grid values
Gof numerical columns.
- explain(model: ICLModel, x: TableTensor, output: str, inputs: str | Iterable[str] | None = None) dict[str, tuple[Tensor, Tensor]]#
Explain how feature values affect predictions.
- Parameters:
model (ICLModel) – The fitted model.
x (TableTensor) – The feature tensor of query examples with shape
[..., R, D]withRrows andDcolumns.output (str) – The name of the predicted column to explain.
inputs (str | Iterable[str] | None) – The name or names of the input feature columns to explain. If
None, all supported columns will be used.
- Returns:
A dictionary from each column name to its grid table with shape
[..., G]and its curves with shape[..., R, G].- Return type: