Break Down: model explanations with interactions and DALEX in the BayArea
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The breakDown package explains predictions from black-box models, such as random forest, xgboost, svm or neural networks (it works for lm and glm as well). As a result you gets decomposition of model prediction that can be attributed to particular variables.
The version 0.3 has a new function break_down
. It identifies pairwise interactions of variables. So if the model is not additive, then instead of seeing effects of single variables you will see effects for interactions.
It’s easy to use this function. See an example below.
HR is an artificial dataset. The break_down
function correctly identifies interaction between gender and age. Find more examples in the documentation.
# # Create a model for classification library("DALEX") library("randomForest") model <- randomForest(status ~ . , data = HR) # # Create a DALEX explainer explainer_rf_fired <- explain(model, data = HR, y = HR$status == "fired", predict_function = function(m,x) predict(m,x, type = "prob")[,1]) # # Calculate variable attributions new_observation <- HRTest[1,] library("breakDown") bd_rf <- break_down(explainer_rf_fired, new_observation, keep_distributions = TRUE) bd_rf #> contribution #> (Intercept) 0.386 #> * hours = 42 0.231 #> * salary = 2 -0.216 #> * age:gender = 58:male 0.397 #> * evaluation = 2 -0.019 #> final_prognosis 0.778 #> baseline: 0 plot(bd_rf)
Figure below shows that a single prediction was decomposed into 4 parts. One of them is related to the interaction between age and gender.
BreakDown is a part of DALEXverse – collection of tools for visualisation, exploration and explanation of complex machine learning models.
Till the end of September I am visiting UC Davis and UC Berkeley. Happy to talk about DALEX explainers, XAI and related stuff.
So, if you want to talk about interpretability of complex ML models, just let me know.
Yes, it’s part of the DALEX invasion
Thanks to the H2020 project RENOIR.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.