plot_partials | R Documentation |
Plot partial dependence plots
plot_partials(
object,
fns = list(location = mean, spread = stats::sd),
rug = TRUE
)
object |
an object output by |
fns |
a list of summary functions; one should be called |
rug |
boolean; whether to add a rug plot to show at which values of the
explanatory variables the partial dependence is computed. This is most
useful when partial dependence is computed at quantiles of the original
data ( |
A ggplot2 object.
Other partial dependence plots functions:
partials()
,
summarise_partials()
# fit a model on 5 bootstraps
m <- resample_boot(mtcars, 5) %>%
xgb_fit(resp="mpg", expl=c("cyl", "hp", "qsec"),
eta=0.1, max_depth=4, nrounds=20)
# assess variable importance
importance(m) %>% summarise_importance()
# compute the partial dependence to the two most relevant variables
m <- partials(m, expl=c("hp", "cyl"))
# and plot them for each resample
plot_partials(m, fns=NULL)
# do the same with a finer grid
m <- partials(m, expl=c("hp", "cyl"), grid.resolution=50)
plot_partials(m, fns=NULL)
# or along quantiles
m <- partials(m, expl=c("hp", "cyl"), quantiles=TRUE, probs=0:20/20)
plot_partials(m, fns=NULL)
# compute mean+/-sd among resamples
summarise_partials(m)
plot_partials(m)
# do the same with median+/-mad
summarise_partials(m, fns=list(location=median, spread=mad))
plot_partials(m, fns=list(location=median, spread=mad))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.