Shades a grid of predictions to show a two-dimensional classifier's decision regions; overlay geom_point() for the training data.

geom_decision_boundary(mapping = NULL, data = NULL, alpha = NULL)

Arguments

mapping, data

Standard layer overrides. Map the grid coordinates to x/y and the predicted class to color.

alpha

Region opacity.

Value

A Layer to add with +.

Examples

g <- expand.grid(x = seq(0, 1, 0.05), y = seq(0, 1, 0.05))
g$cls <- ifelse(g$x + g$y > 1, "a", "b")
ggnext(g, aes(x, y, color = cls)) + geom_decision_boundary()
#> <ggnext plot>
#>   data:  441 x 3
#>   aes:   x = x, y = y, color = cls
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static