Description
Describe the workflow you want to enable
I'd love to push the inspection module further by adding Accumulated local effects (ALE) from Apley 2020. A great description can be found in Christoph's online book https://christophm.github.io/interpretable-ml-book/ale.html
ALE fix the problem of partial dependence that they force the model to be evaluated on impossible or rare feature combinations. ALE are defined for numeric features that can be binned. From both bin edges, the slope of the partial dependence is calculated locally, i.e., only using observations in the bin. The slopes from all bins are cumsummed and vertically centered to the average response or prediction.
Reference
Apley, Daniel W., and Jingyu Zhu. 2020. Visualizing the Effects of Predictor Variables in Black Box Supervised Learning Models. Journal of the Royal Statistical Society Series B: Statistical Methodology, 82 (4): 1059–1086. doi:10.1111/rssb.12377.
Describe your proposed solution
Pseudo code to calculate ALE for one feature:
pd_slopes = np.zeros_like(bins)
for i, bin in enumerate(bins):
X_bin = pick n_per_bin = 200 rows from data in bin
if X_bin is empty:
next
pd = partial_dependence_brute(model, X_bin, grid = [lower bin edge, upper bin edge], sample_weights)
pd_slopes[i] = pd[1] - pd[0]
return np.cumsum(pd_slopes)
Describe alternatives you've considered, if relevant
No response
Additional context
No response