Learn R Programming

MLwrap (version 0.3.0)

plot_ale: Plot Accumulated Local Effects (ALE)

Description

The plot_ale() function computes and visualizes Accumulated Local Effects (ALE) for a selected feature, following the approach described in Interpretable Machine Learning by Christoph Molnar. ALE plots quantify how changes in a feature locally influence model predictions, offering a robust alternative to Partial Dependence Plots (PDP) by avoiding extrapolation and handling correlated predictors more reliably.

Usage

plot_ale(
  analysis_object,
  feature,
  group = NULL,
  grid.size = 20,
  use_test = FALSE,
  plot = TRUE
)

Value

If plot = TRUE, returns the updated wrap_object and prints the ALE plot. If plot = FALSE, returns a ggplot object containing the ALE visualization.

Arguments

analysis_object

A fitted wrap_object with model results or previously computed ALE values.

feature

Character. Name of the continuous feature for which ALE should be computed.

group

Optional character. A grouping variable to compute grouped ALE curves.

grid.size

Integer. Number of intervals to partition the feature domain (default = 20).

use_test

Logical. If TRUE, ALE is computed using the test set (default = FALSE).

plot

Logical. If TRUE, displays the ALE plot and returns wrap_object; if FALSE, returns the ggplot object without modifying the object.

References

Molnar, C. (2022). Interpretable Machine Learning.
https://christophm.github.io/interpretable-ml-book/

See Also

sensitivity_analysis

Examples

Run this code
# After fitting a model with fine_tuning(wrap_object):
# plot_ale(wrap_object, feature = "age")

Run the code above in your browser using DataLab