PartialDependenceExplainer#

class sdm.explain.PartialDependenceExplainer(grid_resolution: int = 20)#

Bases: ICEExplainer

Compute the partial dependence of feature columns from the “Greedy Function Approximation: A Gradient Boosting Machine” paper.

The partial dependence of a column is the mean of its curves of ICEExplainer over all query rows.

Parameters:

grid_resolution (int) – The number of grid values G of 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] with R rows and D columns.

  • 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 partial dependence with shape [..., G].

Return type:

dict[str, tuple[Tensor, Tensor]]