marcotcr / anchor

Code for "High-Precision Model-Agnostic Explanations" paper
BSD 2-Clause "Simplified" License
795 stars 114 forks source link

AnchorTabularExplainer explain_instance #43

Closed ri3017 closed 4 years ago

ri3017 commented 4 years ago

Hi! I am trying to use AnchorTabularExplainer to explain the predictions of a random forest classifier, but when calling explain_instance function I get this error: "ValueError: X has different shape than during fitting. Expected 4, got 11." I have checked that the train dataset and test dataset have the same shape.

Any suggestions of what can I do?

marcotcr commented 4 years ago

are you using an encoder? Can you paste some code snippets?

ri3017 commented 4 years ago

Yes, I have used le = LabelEncoder() on the dataset to encode my categorical features. Afterwards, I have used the encoded datset to fit the explainer and the classifier.

marcotcr commented 4 years ago

Try the new version (since d86d99def867a3321bbe7789cf5f8955397c976a), in particular take a look at the tabular jupyter notebook for how to use encoders.