From 7029071413f2184e152b8b6586d5b886c40c3217 Mon Sep 17 00:00:00 2001 From: Chitu Okoli Date: Tue, 6 Feb 2024 18:51:38 +0100 Subject: [PATCH] Added instructions for progressr to vignettes --- vignettes/ale-intro.Rmd | 11 +++++++++++ vignettes/ale-small-datasets.Rmd | 13 ++++++++++++- vignettes/ale-statistics.Rmd | 11 +++++++++++ vignettes/ale-x-datatypes.Rmd | 9 +++++++++ vignettes/articles/ale-ALEPlot.Rmd | 9 +++++++++ 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/vignettes/ale-intro.Rmd b/vignettes/ale-intro.Rmd index d7bf204..5d4d423 100644 --- a/vignettes/ale-intro.Rmd +++ b/vignettes/ale-intro.Rmd @@ -108,6 +108,17 @@ gam_diamonds <- mgcv::gam( summary(gam_diamonds) ``` +## Enable progress bars + +Before starting, we recommend that you enable progress bars to see how long procedures will take. Simply run the following code at the beginning of your R session: + +```{r enable progressr, eval = FALSE} +progressr::handlers(global = TRUE) +progressr::handlers('cli') +``` + +If you forget to do that, the `{ale}` package will do it automatically for you with a notification message. + ## `ale()` function for generating ALE data and plots The core function in the `{ale}` package is the `ale()` function. Consistent with tidyverse conventions, its first argument is a dataset. Its second argument is a model object--any R model object that can generate numeric predictions is acceptable. By default, it generates ALE data and plots on all the input variables used for the model. To change these options (e.g., to calculate ALE for only a subset of variables; to output the data only or the plots only rather than both; or to use a custom, non-standard predict function for the model), see details in the help file for the function: `help(ale)`. diff --git a/vignettes/ale-small-datasets.Rmd b/vignettes/ale-small-datasets.Rmd index 27d83ca..e787501 100644 --- a/vignettes/ale-small-datasets.Rmd +++ b/vignettes/ale-small-datasets.Rmd @@ -77,7 +77,18 @@ lm_attitude <- lm(rating ~ ., data = attitude) summary(lm_attitude) ``` -At the very least, the `ale` is useful for visualizing the effects of model variables. Note that for now, we run `ale` with no bootstrapping (the default) because small samples require a special bootstrap approach, as explained below. For now, all we are doing is using ALE to accurately visualize what the model estimates. +At the very least, the `ale` is useful for visualizing the effects of model variables. + +Before starting, we recommend that you enable progress bars to see how long procedures will take. Simply run the following code at the beginning of your R session: + +```{r enable progressr, eval = FALSE} +progressr::handlers(global = TRUE) +progressr::handlers('cli') +``` + +If you forget to do that, the `{ale}` package will do it automatically for you with a notification message. + +Note that for now, we run `ale` with no bootstrapping (the default) because small samples require a special bootstrap approach, as explained below. For now, all we are doing is using ALE to accurately visualize what the model estimates. ```{r lm_simple, fig.width=7, fig.height=7} ale_lm_attitude_simple <- ale( diff --git a/vignettes/ale-statistics.Rmd b/vignettes/ale-statistics.Rmd index 1e4ad2b..9cd455f 100644 --- a/vignettes/ale-statistics.Rmd +++ b/vignettes/ale-statistics.Rmd @@ -107,6 +107,17 @@ The outcome variable that is the focus of our analysis is `math_avg`, the averag summary(math$math_avg) ``` +## Enable progress bars + +Before starting, we recommend that you enable progress bars to see how long procedures will take. Simply run the following code at the beginning of your R session: + +```{r enable progressr, eval = FALSE} +progressr::handlers(global = TRUE) +progressr::handlers('cli') +``` + +If you forget to do that, the `{ale}` package will do it automatically for you with a notification message. + ## Full model bootstrap Now we create a model and compute statistics on it. Because this is a [relatively small dataset](ale-small-datasets.html), we will carry out full model bootstrapping using the `model_bootstrap()` function. We create a generalized additive model (GAM) so that we can capture non-linear relationships in the data. diff --git a/vignettes/ale-x-datatypes.Rmd b/vignettes/ale-x-datatypes.Rmd index 88af250..b370ad3 100644 --- a/vignettes/ale-x-datatypes.Rmd +++ b/vignettes/ale-x-datatypes.Rmd @@ -66,6 +66,15 @@ cm <- mgcv::gam(mpg ~ cyl + disp + hp + drat + wt + s(qsec) + summary(cm) ``` +Before starting, we recommend that you enable progress bars to see how long procedures will take. Simply run the following code at the beginning of your R session: + +```{r enable progressr, eval = FALSE} +progressr::handlers(global = TRUE) +progressr::handlers('cli') +``` + +If you forget to do that, the `{ale}` package will do it automatically for you with a notification message. + Now we generate ALE data from the `var_cars` GAM model and plot it. ```{r cars_ale, fig.width=7, fig.height=14} diff --git a/vignettes/articles/ale-ALEPlot.Rmd b/vignettes/articles/ale-ALEPlot.Rmd index dc246c9..c3a420f 100644 --- a/vignettes/articles/ale-ALEPlot.Rmd +++ b/vignettes/articles/ale-ALEPlot.Rmd @@ -132,6 +132,15 @@ drawlabels=TRUE) Now we demonstrate the same functionality with the `{ale}` package. We will work with the same model on the same data, so we will not create them again. +Before starting, we recommend that you enable progress bars to see how long procedures will take. Simply run the following code at the beginning of your R session: + +```{r enable progressr, eval = FALSE} +progressr::handlers(global = TRUE) +progressr::handlers('cli') +``` + +If you forget to do that, the `{ale}` package will do it automatically for you with a notification message. + To create the model, we invoke the `{ale}` which returns a list with various ALE elements. ```{r ale nnet one-way creation}