alibi icon indicating copy to clipboard operation
alibi copied to clipboard

Warning / Error when explainers have `reset_predictor` called early

Open jklaise opened this issue 2 years ago • 0 comments

@sakoush found that calling reset_predictor right after __init__ on AnchorTabular results in the following error:

Traceback (most recent call last):
  File "make_test_models.py", line 261, in <module>
    _main()
  File "make_test_models.py", line 257, in _main
    make_anchor_tabular_income(model_dir)
  File "make_test_models.py", line 221, in make_anchor_tabular_income
    explainer.reset_predictor(model_pipeline.predict)
  File "/home/sa/miniconda3/envs/python3.7-seldon-core/lib/python3.7/site-packages/alibi/explainers/anchor_tabular.py", line 1028, in reset_predictor
    self.samplers[0].predictor = self._predictor
IndexError: list index out of range

The reason here is because self.samplers is an empty list until after fit is called.

There are some choices as to how we want to resolve this:

  1. Refuse calls to reset_predictor if fit has not been called (related - should we also only allow to save fitted explainers?) by raising a custom exception
  2. Use the state of the explainer (e.g. is_fit: bool, which would need to be used for 1. also) to modify the logic of reset_predictor to allow it to be called regardless of whether fit was called or not.

jklaise avatar Nov 22 '21 17:11 jklaise