shapiq.explainer.tree.conversion.sklearn#

This module contains functions for converting scikit-learn decision trees to the format used by shapiq.

Functions

convert_sklearn_forest(tree_model[, class_label])

Transforms a scikit-learn random forest to the format used by shapiq.

convert_sklearn_tree(tree_model[, ...])

Convert a scikit-learn decision tree to the format used by shapiq.

shapiq.explainer.tree.conversion.sklearn.convert_sklearn_forest(tree_model, class_label=None)[source]#

Transforms a scikit-learn random forest to the format used by shapiq.

Parameters:
  • tree_model (TypeVar(Model)) – The scikit-learn random forest model to convert.

  • class_label (Optional[int]) – The class label of the model to explain. Only used for classification models. Defaults to 0.

Return type:

list[TreeModel]

Returns:

The converted random forest model.

shapiq.explainer.tree.conversion.sklearn.convert_sklearn_tree(tree_model, class_label=None, scaling=1.0)[source]#

Convert a scikit-learn decision tree to the format used by shapiq.

Parameters:
  • tree_model (TypeVar(Model)) – The scikit-learn decision tree model to convert.

  • class_label (Optional[int]) – The class label of the model to explain. Only used for classification models. Defaults to 0.

  • scaling (float) – The scaling factor for the tree values.

Return type:

TreeModel

Returns:

The converted decision tree model.