marcotcr / anchor

Code for "High-Precision Model-Agnostic Explanations" paper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

all the input arrays must have same number of dimensions, but the array at index 0 has 2 dimension(s) and the array at index 1 has 1 dimension(s)

yosepppph opened this issue · comments

Hey, I'm working on a breast cancer dataset. When I call the explain_instace function, I get the above error message.

This is what the code looks like:
from anchor import anchor_tabular
explainer = anchor_tabular.AnchorTabularExplainer(np.asarray(["0","1"]),list(data.drop(columns=['id','diagnosis']).columns),x)
exp = explainer.explain_instance(X_test[0:1], classifier.predict, threshold=0.95)

I saw the same issue on Shap GitHub, and advice to use NumPy slices but still, that didn't work.

Screen Shot 2020-04-29 at 5 06 55 PM

This is what the error log looks like

The first parameter should be a 1d numpy array, you are giving it a 2d numpy array of dimension (1, d).
Reopen if this doesn't fix it : )