alibi
alibi copied to clipboard
Warning / Error when explainers have `reset_predictor` called early
@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:
- Refuse calls to
reset_predictor
iffit
has not been called (related - should we also only allow to savefit
ted explainers?) by raising a custom exception - Use the state of the explainer (e.g.
is_fit: bool
, which would need to be used for 1. also) to modify the logic ofreset_predictor
to allow it to be called regardless of whetherfit
was called or not.