Created
February 11, 2019 22:30
-
-
Save erykml/b5aac9bd3e3491fe9eb1fbbf5d961382 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import lime | |
| import lime.lime_tabular | |
| explainer = lime.lime_tabular.LimeTabularExplainer(X_train.values, | |
| mode = 'regression', | |
| feature_names = X_train.columns, | |
| categorical_features = [3], | |
| categorical_names = ['CHAS'], | |
| discretize_continuous = True) | |
| np.random.seed(42) | |
| exp = explainer.explain_instance(X_train.values[31], rf.predict, num_features = 5) | |
| exp.show_in_notebook(show_all=False) #only the features used in the explanation are displayed | |
| exp = explainer.explain_instance(X_train.values[85], rf.predict, num_features = 5) | |
| exp.show_in_notebook(show_all=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment