Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions alibi/saving.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,25 @@ def _save_AnchorText(explainer: 'AnchorText', path: Union[str, os.PathLike]) ->
explainer.perturbation = perturbation


def _save_KernelShap(explainer: 'KernelShap', path: Union[str, os.PathLike]) -> None:
# TODO: save internal shap objects using native pickle?
def _save_Shap(explainer: Union['KernelShap', 'TreeShap'], path: Union[str, os.PathLike]) -> None:
# set the internal explainer object to avoid saving it. The internal explainer
# object is recreated when in the `reset_predictor` function call.
_explainer = explainer._explainer
explainer._explainer = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that this will need to be considered too when fixing #830


# simple save which does not save the predictor
_simple_save(explainer, path)

# reset the internal explainer object
explainer._explainer = _explainer

def _save_TreelShap(explainer: 'TreeShap', path: Union[str, os.PathLike]) -> None:
# TODO: save internal shap objects using native pickle?
_simple_save(explainer, path)

def _save_KernelShap(explainer: 'KernelShap', path: Union[str, os.PathLike]) -> None:
_save_Shap(explainer, path)


def _save_TreeShap(explainer: 'TreeShap', path: Union[str, os.PathLike]) -> None:
_save_Shap(explainer, path)


def _save_CounterfactualRL(explainer: 'CounterfactualRL', path: Union[str, os.PathLike]) -> None:
Expand Down