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

Can we use Anchor to explain already built models in our own way? #27

Closed
DiliSR opened this issue Jul 12, 2019 · 2 comments
Closed

Can we use Anchor to explain already built models in our own way? #27

DiliSR opened this issue Jul 12, 2019 · 2 comments

Comments

@DiliSR
Copy link

DiliSR commented Jul 12, 2019

Hi,

First of all, I should say that this is really a great paper. Good luck with you.

My question is, let's assume we have a tabular dataset. We just do encoding categorical variables as pre-processing and make a model using the random forest. And we save that model using .pickle format.

After that can we use Anchor to explain that saved model.

For example, I don't need to use these lines of code when making the model.

explainer = anchor_tabular.AnchorTabularExplainer(dataset.class_names, dataset.feature_names, dataset.data, dataset.categorical_names)
explainer.fit(dataset.train, dataset.labels_train, dataset.validation, dataset.labels_validation)
c = sklearn.ensemble.RandomForestClassifier(n_estimators=50, n_jobs=5)
c.fit(explainer.encoder.transform(dataset.train), dataset.labels_train)

I just need to use,
c = sklearn.ensemble.RandomForestClassifier(n_estimators=50, n_jobs=5)
c.fit(dataset.train, dataset.labels_train)
these two lines when making the model.

Thank you.

@DiliSR
Copy link
Author

DiliSR commented Jul 12, 2019

In LIME, explainer was created, after built the model. But in Anchor, we need to build the explainer before making the global model.

@marcotcr
Copy link
Owner

I'm glad you found the paper interesting.

Yes, you can train the model without encoding, provided that you don't have categorical features (i.e. the explainer will tread all features as ordinal / continuous and discretize them). You don't need to initialize the explainer before training the model, I just did it in that order because I wanted to use the explainer's encoder to encode the data before training the model. Note that the init function of the explainer does not depend on the model.

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

2 participants