Skip to content

Commit

Permalink
Vignettes updates
Browse files Browse the repository at this point in the history
Vignettes updates
  • Loading branch information
mingdeyu committed Nov 14, 2024
1 parent 0c67735 commit 730849c
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
^\.gitignore$
^CRAN-SUBMISSION$
^RESEARCH-NOTICE\.md$
^vignettes/images/.*\.html$
^vignettes/images/
^vignettes/motorcycle.Rmd$
^man/figures/dgpsi_logo.png$
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ read <- function(pkl_file) {
#' If set to `"table"`, the function returns a summary in table. If set to `"plot"`, the function
#' returns an interactive visualization. Defaults to `"plot"`. If the `object` was created with
#' `lgp()` where `struc` is not a data frame, `type` will automatically default to `"table"`.
#' @param group_size an integer secifying the number of consecutive layers to be grouped together
#' @param group_size an integer specifying the number of consecutive layers to be grouped together
#' in the interactive visualization of linked emulators when `type = "plot"`.
#' This argument is only applicable if `object` is an instance of the `lgp` class.
#' Defaults to `1`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dgpsi <img src="man/figures/dgpsi-logo.png" align="right" height="139" />
# dgpsi <img src="https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/man/figures/dgpsi_logo.png" align="right" height="139" />

[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/dgpsi)](https://CRAN.R-project.org/package=dgpsi)
[![Download](https://cranlogs.r-pkg.org/badges/grand-total/dgpsi?color=brightgreen)](https://CRAN.R-project.org/package=dgpsi)
Expand Down
2 changes: 1 addition & 1 deletion man/summary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vignettes/classification.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ plot(m_dgp, X_test, Y_test)
## Plotting ... done
```

![](images/classifier_oos_1.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/classifier_oos_1.png){width=90%}

By default, `plot()` displays true labels against predicted label proportions at each input position. Alternatively, setting `style = 2` in `plot()` generates a confusion matrix:

Expand All @@ -121,7 +121,7 @@ plot(m_dgp, X_test, Y_test, style = 2)
## Plotting ... done
```

![](images/classifier_oos_2.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/classifier_oos_2.png){width=90%}

### References

6 changes: 3 additions & 3 deletions vignettes/dgpsi.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ plot(m)
## Plotting ... done
```

![](images/step_fct_loo.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/step_fct_loo.png){width=90%}

The second validation plot is the Out-Of-Sample (OOS) validation plot that requires an out-of-sample testing data set. Here we generate an OOS data set that contains 10 testing data points

Expand All @@ -113,7 +113,7 @@ plot(m,oos_x,oos_y)
## Plotting ... done
```

![](images/step_fct_oos.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/step_fct_oos.png){width=90%}

## Prediction

Expand Down Expand Up @@ -146,4 +146,4 @@ lines(test_x, mu, type = 'l', lty = 2, lwd = 1.5, col = 'black')
lines(X, Y, type = 'p', pch = 16, cex = 1, col = "#0072B2") # Training data points
```

![](images/step_fct_result.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/step_fct_result.png){width=90%}
4 changes: 2 additions & 2 deletions vignettes/large_scale_emulation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ plot(m)
## Plotting ... done
```

![](images/vecchia_loo.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/vecchia_loo.png){width=90%}

or the Out-Of-Sample (OOS) validation plot over `1000` randomly generated testing locations:

Expand All @@ -99,7 +99,7 @@ plot(m, oos_x, oos_y)
## Plotting ... done
```

![](images/vecchia_oos.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/vecchia_oos.png){width=90%}

### Performance tip

Expand Down
16 changes: 8 additions & 8 deletions vignettes/linked_DGP.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ library(dgpsi)

We consider the following synthetic system

![](images/linked_model.png){width="60%"}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/linked_model.png){width="60%"}

that involves three models defined by:

Expand Down Expand Up @@ -99,7 +99,7 @@ plot(m1)
## Plotting ... done
```

![](images/model_1_loo.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/model_1_loo.png){width=90%}

## Emulation of Model 2

Expand Down Expand Up @@ -135,7 +135,7 @@ Post-processing LOO results ... done
Plotting ... done
```

![](images/model_2_loo.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/model_2_loo.png){width=90%}

## Emulation of Model 3

Expand Down Expand Up @@ -165,7 +165,7 @@ Post-processing LOO results ... done
Plotting ... done
```

![](images/model_3_loo.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/model_3_loo.png){width=90%}

## Emulation of Linked Model

Expand Down Expand Up @@ -256,15 +256,15 @@ plot(m_gp, x_test = test_x, y_test = test_y, type = 'line', verb = F) +
plot_annotation(title = 'GP Emulator', theme = theme(plot.title = element_text(hjust = 0.5)))
```

![](images/linked_result.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/linked_result.png){width=90%}

```{r}
# Linked emulator
plot(m_link, x_test = test_x, y_test = test_y, type = 'line', verb = F) +
plot_annotation(title = 'Linked Emulator', theme = theme(plot.title = element_text(hjust = 0.5)))
```

![](images/linked_result_new.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/linked_result_new.png){width=90%}

It can be seen from the above plots that the linked emulator outperforms the GP emulator with significantly better mean predictions and predictive uncertainties.

Expand All @@ -289,7 +289,7 @@ plot(m_gp, test_x_oos, test_y_oos, style = 2)
## Plotting ... done
```

![](images/gp_oos.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/gp_oos.png){width=90%}

and the linked emulator:

Expand All @@ -303,6 +303,6 @@ plot(m_link, test_x_oos, test_y_oos, style = 2)
## Plotting ... done
```

![](images/linked_oos.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/linked_oos.png){width=90%}

which show that the linked emulator outperforms the GP emulator with significantly better predictive accuracy and lower NRMSE.
6 changes: 3 additions & 3 deletions vignettes/motorcycle.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ and plot them:
plot(X, Y, pch = 16, cex = 1, xlab = 'Time', ylab = 'Acceleration', cex.axis = 1.3, cex.lab = 1.3)
```

![](images/motorcycle_data.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/motorcycle_data.png){width=90%}

Before constructing an emulator, we first specify a seed with `set_seed()` from the package for reproducibility

Expand Down Expand Up @@ -147,7 +147,7 @@ plot(m_gp, test_x, test_y)
## Plotting ... done
```

![](images/motorcycle_gp_oos.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/motorcycle_gp_oos.png){width=90%}

and for the DGP emulator:

Expand All @@ -161,7 +161,7 @@ plot(m_dgp, test_x, test_y)
## Plotting ... done
```

![](images/motorcycle_dgp_oos.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/motorcycle_dgp_oos.png){width=90%}

Note that we still need to provide `test_x` and `test_y` to `plot()` even they have already been provided to `validate()`. Otherwise, `plot()` will draw the LOO cross validation plot. The visualizations above show that the DGP emulator gives a better performance than the GP emulator on modeling the heteroskedastic noises embedded in the underlying data set, even though they have quite similar NRMSEs.

Expand Down
8 changes: 4 additions & 4 deletions vignettes/seq_design.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ggplot(dat, aes(x1, x2, fill = f)) + geom_tile() +
scale_fill_continuous(type = "viridis")
```

![](images/seq_fct.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/seq_fct.png){width=90%}

We can see from the figure above that the synthetic simulator exhibits more fluctuations on the bottom left of its input space while in the top-right part the simulator shows little variations.

Expand Down Expand Up @@ -193,14 +193,14 @@ After the sequential design is done, we can inspect the enriched design by apply
draw(m, 'design')
```

![](images/seq_design.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/seq_design.png){width=90%}
It can be seen from the figure above that most of the added design points concentrate at the bottom-left corner of the input space where the simulator `f` exhibits more variations and thus needs more data to be well-emulated. We can also visualize the changes of qualities (in terms of RMSEs wrt the validation dataset) of emulators constructed during the three waves of sequential designs:

```{r}
draw(m, 'rmse')
```

![](images/seq_rmse.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/seq_rmse.png){width=90%}

## Comparison to DGP emulators with space-filling designs

Expand Down Expand Up @@ -271,7 +271,7 @@ draw(m, 'rmse', log = T) +
scale_shape_manual(values = c(2, 3, 4, 8, 15))
```

![](images/seq_comparison.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/seq_comparison.png){width=90%}

It can be seen from the plot above that with static space-filling designs, the quality of an emulator may not be improved as the design size increases. This is because increasing the size of a space-filling design may not capture regions where the simulator exhibits more variations, and thus cause DGP emulators with higher RMSEs than those constructed through the sequential design.

Expand Down
6 changes: 3 additions & 3 deletions vignettes/seq_design_2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ p3 <- ggplot(data = output3, aes(x = x, y = y)) + geom_line(color = 'green4') +
wrap_plots(list(p1, p2, p3)) + plot_annotation(title = 'Synthetic Simulator')
```

![](images/seq2_fct.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/seq2_fct.png){width=90%}

We now specify a seed with `set_seed()` from the package for reproducibility

Expand Down Expand Up @@ -241,7 +241,7 @@ draw(m, 1, 'design') + draw(m, 2, 'design') + draw(m, 3, 'design') +
plot_layout() & theme(legend.position = 'bottom')
```

![](images/seq2_design.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/seq2_design.png){width=90%}

The figure above shows that for the first emulator most of the design points are added below 0.5 whilst for the second emulator most of the design points concentrate around 0.5. For the third emulator, the resulting design is space-filling. It can be seen that these design point distributions are consistent with the functional complexities of the three outputs.

Expand Down Expand Up @@ -311,7 +311,7 @@ p3 <- draw(m, emulator = 3, type = 'rmse', log = T) +
p1 + p2 + p3 + plot_layout(guides = 'collect') & theme(legend.position = 'bottom')
```

![](images/seq2_rmse.png){width=90%}
![](https://raw.githubusercontent.com/mingdeyu/dgpsi-R/master/vignettes/images/seq2_rmse.png){width=90%}

It can be seen from the plot above that with the sequential design, emulators in the bundle can achieve higher or similar accuracy with smaller number of design points.

Expand Down

0 comments on commit 730849c

Please sign in to comment.