Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixed continuous and categorical features in the AnchorTabular explainers (my dataset doesn't contain NaNs) #990

Open
TopCoder2K opened this issue Dec 13, 2023 · 0 comments

Comments

@TopCoder2K
Copy link

Hi there!

I've seen #364 in which it's said "We may extend the types of data handled by the alibi explainers in the future (e.g. working on pandas dataframes) but this is not an immediate priority as there are several potential complications with this". Has there been any progress on this in 2.5 years?

I've tried to run AnchorTabular with the CatBoostRegressor trained on a dataset containing both continuous and categorical features:

from alibi.utils import gen_category_map
from alibi.explainers import AnchorTabular

category_map = gen_category_map(
    X_train, categorical_columns=categorical_features
)
AnchorTabular(
    lambda x: cb_model.predict(x), X_train.columns, categorical_names=category_map
)

but got

CatBoostError: 'data' is numpy array of floating point numerical type, it means no categorical features, but 'cat_features' parameter specifies nonzero number of categorical features

The above exception was the direct cause of the following exception:

PredictorCallError                        Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/alibi/explainers/anchors/anchor_tabular.py](https://localhost:8080/#) in _transform_predictor(self, predictor)
   1010             msg = f"Predictor failed to be called on {type(x)} of shape {x.shape} and dtype {x.dtype}. " \
   1011                   f"Check that the parameter `feature_names` is correctly specified."
-> 1012             raise PredictorCallError(msg) from e
   1013 
   1014         if not isinstance(prediction, np.ndarray):

PredictorCallError: Predictor failed to be called on <class 'numpy.ndarray'> of shape (1, 11) and dtype float32. Check that the parameter `feature_names` is correctly specified.

because the explainer gives

[[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]

Is there any way to supply categorical and continuous values simultaneously?

@TopCoder2K TopCoder2K changed the title Mixed continuous and categorical features in AnchorTabular explainers (dataset doesn't contain NaNs) Mixed continuous and categorical features in AnchorTabular explainers (my dataset doesn't contain NaNs) Dec 13, 2023
@TopCoder2K TopCoder2K changed the title Mixed continuous and categorical features in AnchorTabular explainers (my dataset doesn't contain NaNs) Mixed continuous and categorical features in the AnchorTabular explainers (my dataset doesn't contain NaNs) Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant