.ale | R Documentation |
This is a barebone implementation of Apley's ALE.
Per bin, the local effect D_j
is calculated, and then accumulated over bins.
D_j
equals the difference between the partial dependence at the
lower and upper bin breaks using only observations within bin.
To plot the values, we can make a line plot of the resulting vector against
upper bin breaks. Alternatively, the vector can be extended
from the left by the value 0, and then plotted against all breaks.
.ale(
object,
v,
data,
breaks,
right = TRUE,
pred_fun = stats::predict,
trafo = NULL,
which_pred = NULL,
bin_size = 200L,
w = NULL,
g = NULL,
...
)
object |
Fitted model. |
v |
Variable name in |
data |
Matrix or data.frame. |
breaks |
Bin breaks. |
right |
Should bins be right-closed?
The default is |
pred_fun |
Prediction function, by default |
trafo |
How should predictions be transformed?
A function or |
which_pred |
If the predictions are multivariate: which column to pick
(integer or column name). By default |
bin_size |
Maximal number of observations used per bin. If there are more
observations in a bin, |
w |
Optional vector with case weights. |
g |
For internal use. The result of |
... |
Further arguments passed to |
Vector representing one ALE per bin.
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.
partial_dependence()
fit <- lm(Sepal.Length ~ ., data = iris)
v <- "Sepal.Width"
.ale(fit, v, data = iris, breaks = seq(2, 4, length.out = 5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.