-
-
Notifications
You must be signed in to change notification settings - Fork 169
Closed
Labels
Python 🐍Related to PythonRelated to Pythonquestion ❔Further information is requestedFurther information is requested
Description
I found a bug or missing feature with scikit pipelines in dalex.
When you try to create an explainer with predict_parts
and type="shap_wrapper
like this:
sh_mary = exp.predict_parts(mary, type='shap_wrapper', B = 10, label=mary.index[0])
It causes an error. This bug is reproducible with your titanic example.
I would be thankful for any workaround.
The error message is:
EDIT:
Furthermore if you take a look at the explainer output it seems that numpy.ndarrays do not work properly
but the error message literally states that it expects an array:
-> predict function : Accepts only pandas.DataFrame, numpy.ndarray causes problems.
TypeError Traceback (most recent call last)
Input In [9], in <cell line: 2>()
1 import shap
----> 2 sh_mary = exp.predict_parts(mary, type='shap_wrapper', B = 10, label=mary.index[0])
File ~\miniconda3\envs\Master_ML\lib\site-packages\dalex\_explainer\object.py:320, in Explainer.predict_parts(self, new_observation, type, order, interaction_preference, path, N, B, keep_distributions, label, processes, random_state, **kwargs)
317 else:
318 raise TypeError("Wrong type parameter.")
--> 320 _predict_parts.fit(self, new_observation, **kwargs)
322 if label:
323 _predict_parts.result['label'] = label
File ~\miniconda3\envs\Master_ML\lib\site-packages\dalex\wrappers\_shap\object.py:71, in ShapWrapper.fit(self, explainer, new_observation, shap_explainer_type, **kwargs)
49 """Calculate the result of explanation
50
51 Fit method makes calculations in place and changes the attributes.
(...)
67 None
68 """
69 from shap import TreeExplainer, DeepExplainer, GradientExplainer, LinearExplainer, KernelExplainer
---> 71 checks.check_compatibility(explainer)
72 shap_explainer_type = checks.check_shap_explainer_type(shap_explainer_type, explainer.model)
74 if self.type == 'predict_parts':
File ~\miniconda3\envs\Master_ML\lib\site-packages\dalex\wrappers\_shap\checks.py:48, in check_compatibility(explainer)
46 if 'arrays_accepted' in explainer.model_info:
47 if not explainer.model_info['arrays_accepted']:
---> 48 raise TypeError("'predict_function' not compatible with the 'shap' package")
49 else:
50 # data was None but now is available
51 try:
TypeError: 'predict_function' not compatible with the 'shap' package
Metadata
Metadata
Assignees
Labels
Python 🐍Related to PythonRelated to Pythonquestion ❔Further information is requestedFurther information is requested