showWaterfall2 = function(xgb.model, explainer, DMatrix, data.matrix,
idx, type = "binary", threshold = 0.0001,
limits = c(NA, NA), explanations = NULL){
if(!is.null(explanations)){
breakdown = explanations[idx,]
} else{
breakdown = explainPredictions(xgb.model,
explainer,
slice(DMatrix,as.integer(idx)))
}
etc...
Each call to
showWaterfallrunsexplainPredictions. For datasets with hundreds or thousands of columns, this is tedious. Runtime can be hours long. To expedite the function call,showWaterfallshould also accept anexplanationsvariable that references prediction breakdowns that have already been made, maybe like this: