Skip to content

Commit

Permalink
Added instructions for progressr to vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
tripartio committed Feb 6, 2024
1 parent f69f383 commit 7029071
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
11 changes: 11 additions & 0 deletions vignettes/ale-intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)`.
Expand Down
13 changes: 12 additions & 1 deletion vignettes/ale-small-datasets.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 11 additions & 0 deletions vignettes/ale-statistics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions vignettes/ale-x-datatypes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
9 changes: 9 additions & 0 deletions vignettes/articles/ale-ALEPlot.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 7029071

Please sign in to comment.