# x position of the black dot, y position of the black dotĭef dep_plt(col, color_by, base_actual_df, base_shap_df, overlay_x, overlay_y):Ĭmap=sns.diverging_palette(260, 10, sep=1, as_cmap=True) #seaborn palette # inputs = column of interest as string, column for coloring as string, df of our data, SHAP df, This is important, given the debate over which of the traditional methods of calculating variable importance is correct and that those methods do not always agree. SHAP provides a theoretically sound method for evaluating variable importance. Variable importance graphs are useful tools for understanding the model in a global sense. I have chosen to use the first model, the one from the XGBoost library, for these graphical examples. While LIME does not offer any graphs for global interpretability, SHAP does. The graphs in the previous section are examples of local interpretability. ![]() Global interpretability is generally more important to executive sponsors needing to understand the model at a high level, auditors looking to validate model decisions in aggregate, and scientists wanting to verify that the model matches their theoretical understanding of the system being studied. This is much bigger (and much harder) than explaining a single prediction since it involves making statements about how the model works in general, not just on one prediction. Global interpretability of models entails seeking to understand the overall structure of the model. This helps decision makers trust the model and know how to integrate its recommendations with other decision factors. Local interpretability of models consists of providing detailed explanations for why an individual prediction was made. I find it useful to think of model interpretability in two classes - local and global. The whole idea behind both SHAP and LIME is to provide model interpretability. The first three of our models can use the tree explainer.Įxp = explainer.explain_instance(X_test.values, knn.predict, num_features=5)Įxp.show_in_notebook(show_table=True) Explainability on a Macro Level with SHAP The SHAP Python library has the following explainers available: deep (a fast, but approximate, algorithm to compute SHAP values for deep learning models based on the DeepLIFT algorithm) gradient (combines ideas from Integrated Gradients, SHAP and SmoothGrad into a single expected value equation for deep learning models) kernel (a specially weighted local linear regression to estimate SHAP values for any model) linear (compute the exact SHAP values for a linear model with independent features) tree (a fast and exact algorithm to compute SHAP values for trees and ensembles of trees) and sampling (computes SHAP values under the assumption of feature independence - a good alternative to kernel when you want to use a large background set). Xgb_model = xgb.train(, xgb.DMatrix(X_train, label=y_train)) SHAP and LIME Individual Prediction Explainersįirst, we load the required Python libraries. The code below is a subset of a Jupyter notebook I created to walk through examples of SHAP and LIME. We do this with side-by-side code comparisons of SHAP and LIME for four common Python models. The goal of Part 2 is to familiarize readers with how to use the libraries in practice and how to interpret their output, helping them prepare to produce model explanations in their own work. In Part 2 we explore these libraries in more detail by applying them to a variety of Python models. Part 1 of this blog post provides a brief technical introduction to the SHAP and LIME Python libraries, including code and output to highlight a few pros and cons of each library. If interested in a visual walk-through of this post, then consider attending the webinar. This blog post provides insights on how to use the SHAP and LIME Python libraries in practice and how to interpret their output, helping readers prepare to produce model explanations in their own work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |