Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
95e2825
Adapt the existing tests to work with the new implementation of subsa…
fweber144 Sep 26, 2024
c101bad
fix the early check for all-`NA`s in `get_stat()`
fweber144 Nov 4, 2024
06cae7d
Revert "fix the early check for all-`NA`s in `get_stat()`"
fweber144 Nov 4, 2024
b65d341
avoid the early check for all-`NA`s in `get_stat()`
fweber144 Nov 4, 2024
bd66734
replace `n_full <- sum(!is.na(mu))` with `n_full <- length(mu)` because
fweber144 Nov 17, 2024
af7bd97
tests: `NA`s in summaries should be `NA_real_`s now
fweber144 Nov 17, 2024
8564b4a
in this branch, `weighted.sd()` and `auc()` have been renamed
fweber144 Nov 17, 2024
ebfc665
divide by `(n_full - 1)` instead of `n_full` where necessary, see
fweber144 Dec 22, 2024
e841bcd
add test `".srs_diff_est_w() works as expected"` (copied from 'loo', see
fweber144 Dec 22, 2024
ff9461e
Merge remote-tracking branch 'upstream/master' into misc_from_fix-sub…
fweber144 Dec 30, 2024
4d3bc36
Merge remote-tracking branch 'upstream/master' into misc_from_fix-sub…
fweber144 Dec 30, 2024
ae82ffc
explain "fast LOO" and "full LOO" in the docs, see
fweber144 Jan 4, 2025
006ff44
make computation of `var_e_i` in `.srs_diff_est_w()` numerically more…
fweber144 Jan 5, 2025
09487e3
fix a comment, see
fweber144 Jan 5, 2025
aecaa4e
minor cleaning
fweber144 Jan 6, 2025
35280fb
fix a comment, see
fweber144 Jan 6, 2025
6dcc223
replace `mean(y)` with `mean(wobs * y)`, see
fweber144 Jan 6, 2025
1ee2bbd
avoid redundant computations by introducing object `y_mean_w`
fweber144 Jan 6, 2025
df4bad0
use `log1p()` for numerical stability (in `get_stat()`), see
fweber144 Jan 6, 2025
971d5b6
drop quotes from "exact" in a comment, see
fweber144 Jan 12, 2025
a2fed53
fix docs for RMSE and R2
fweber144 Jan 12, 2025
2131722
add `stat = "R2"` to the tests;
fweber144 Jan 12, 2025
93c3f8e
set a negative squared standard error which is numerically equal to zero
fweber144 Jan 16, 2025
cc71813
fix first-order Taylor approximation of the variance (delta method)
fweber144 Jan 12, 2025
26b36ab
change wording in a comment, see
fweber144 Jan 21, 2025
4a31499
subsampled LOO and AUC: switch from warning to error, see
fweber144 Jan 31, 2025
eda0cc1
docs: mention that the `stats` option `"auc"` is not supported in cas…
fweber144 Jan 31, 2025
95ee8cd
docs: mention log-normal approximation for MSE and RMSE, see
fweber144 Jan 31, 2025
6c6a596
`plot.vsel()`: mention log-normal approximation for MSE and RMSE, see
fweber144 Jan 31, 2025
25a3ba7
docs: `baseline = "best"` is not supported in case of subsampled LOO-CV
fweber144 Feb 1, 2025
dd0390a
vignettes: mention subsampled LOO
fweber144 Feb 1, 2025
79c7b25
update `NEWS.md`
fweber144 Feb 2, 2025
6bdade6
fixup! docs: mention log-normal approximation for MSE and RMSE, see
fweber144 Feb 2, 2025
d06f43d
fixup! subsampled LOO and AUC: switch from warning to error, see
fweber144 Feb 2, 2025
a33e614
set `nloo` to `NULL` in case of K-fold CV
fweber144 Feb 4, 2025
944899f
modify the tests so that subsampled LOO is tested more thoroughly
fweber144 Feb 3, 2025
27d47ea
fix a test (only discovered this now after changing the tests and
fweber144 Feb 5, 2025
1889bfe
Merge remote-tracking branch 'upstream/master' into misc_from_fix-sub…
fweber144 Feb 11, 2025
92ad481
revert everything not related to `progressr`
fweber144 Feb 7, 2025
7bef2c2
document use of the progressr package,
fweber144 Feb 10, 2025
d512dba
add `identical(foreach::getDoParName(), "doFuture")` to the default f…
fweber144 Feb 10, 2025
2730bcc
update progressor *after* executing the corresponding code, not befor…
fweber144 Feb 10, 2025
39b662e
add `NEWS.md` entry
fweber144 Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ Suggests:
doParallel,
future,
future.callr,
doFuture
doFuture,
progressr
LinkingTo: Rcpp, RcppArmadillo
Additional_repositories:
https://mc-stan.org/r-packages/
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ If you read this from a place other than <https://mc-stan.org/projpred/news/inde
## Minor changes

* Use the updated threshold for high Pareto-$\hat{k}$ values presented by Vehtari et al. (2024, "Pareto smoothed importance sampling", *Journal of Machine Learning Research*, 25(72):1-58, <https://www.jmlr.org/papers/v25/19-556.html>). This threshold depends on the Monte Carlo sample size and is often close to the former fixed threshold of 0.7 (a short introduction may also be found in the [LOO glossary](https://mc-stan.org/loo/reference/loo-glossary.html)). Correspondingly, the former "secondary" threshold of 0.5 is not used anymore either. (GitHub: #490, #498)
* When using the **doFuture** backend for parallelization, progression updates can now be received via the **progressr** package, see `` ?`projpred-package` `` (section "Parallelization"). (GitHub: #504)

# projpred 2.8.0

Expand Down
32 changes: 25 additions & 7 deletions R/cv_varsel.R
Original file line number Diff line number Diff line change
Expand Up @@ -1036,17 +1036,26 @@ loo_varsel <- function(refmodel, method, nterms_max, ndraws,
if (!requireNamespace("doRNG", quietly = TRUE)) {
stop("Please install the 'doRNG' package.")
}
if (verbose && use_progressr()) {
progressor_obj <- progressr::progressor(length(inds))
} else {
progressor_obj <- NULL
}
dot_args <- list(...)
`%do_projpred%` <- doRNG::`%dorng%`
res_cv <- foreach::foreach(
run_index = seq_along(inds),
.export = c("one_obs", "dot_args"),
.packages = c("projpred"),
.export = c("one_obs", "dot_args", "progressor_obj"),
.noexport = c("mu_offs_oscale", "loglik_forPSIS", "psisloo", "y_lat_E",
"loo_ref_oscale", "validset", "loo_sub", "mu_sub",
"loo_sub_oscale", "mu_sub_oscale")
) %do_projpred% {
do.call(one_obs, c(list(run_index = run_index, verbose_search = FALSE),
dot_args))
out_one_obs <- do.call(one_obs, c(list(run_index = run_index,
verbose_search = FALSE),
dot_args))
if (!is.null(progressor_obj)) progressor_obj()
return(out_one_obs)
}
}
# For storing the fold-wise predictor rankings:
Expand Down Expand Up @@ -1357,17 +1366,26 @@ kfold_varsel <- function(refmodel, method, nterms_max, ndraws, nclusters,
if (!requireNamespace("doRNG", quietly = TRUE)) {
stop("Please install the 'doRNG' package.")
}
if (verbose && use_progressr()) {
progressor_obj <- progressr::progressor(length(list_cv))
} else {
progressor_obj <- NULL
}
dot_args <- list(...)
`%do_projpred%` <- doRNG::`%dorng%`
res_cv <- foreach::foreach(
list_cv_k = list_cv,
search_out_rks_k = search_out_rks,
.export = c("one_fold", "dot_args"),
.packages = c("projpred"),
.export = c("one_fold", "dot_args", "progressor_obj"),
.noexport = c("list_cv", "search_out_rks")
) %do_projpred% {
do_call(one_fold, c(list(fold = list_cv_k, rk = search_out_rks_k,
verbose_search = FALSE),
dot_args))
out_one_fold <- do_call(one_fold, c(list(fold = list_cv_k,
rk = search_out_rks_k,
verbose_search = FALSE),
dot_args))
if (!is.null(progressor_obj)) progressor_obj()
return(out_one_fold)
}
}
verb_out("-----", verbose = verbose)
Expand Down
18 changes: 16 additions & 2 deletions R/divergence_minimizers.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,19 @@ divmin <- function(
if (!requireNamespace("iterators", quietly = TRUE)) {
stop("Please install the 'iterators' package.")
}
if (verbose_divmin && use_progressr()) {
progressor_obj <- progressr::progressor(length(formulas))
} else {
progressor_obj <- NULL
}
dot_args <- list(...)
`%do_projpred%` <- foreach::`%dopar%`
outdmin <- foreach::foreach(
formula_s = formulas,
projpred_var_s = iterators::iter(projpred_var, by = "column"),
projpred_formula_no_random_s = projpred_formulas_no_random,
.export = c("sdivmin", "projpred_random", "dot_args"),
.packages = c("projpred"),
.export = c("sdivmin", "projpred_random", "dot_args", "progressor_obj"),
.noexport = c(
"object", "p_sel", "search_path", "p_ref", "refmodel", "formulas",
"projpred_var", "projpred_ws_aug", "projpred_formulas_no_random"
Expand All @@ -113,6 +119,7 @@ divmin <- function(
dot_args)
)
)
if (!is.null(progressor_obj)) progressor_obj()
return(nlist(soutdmin, mssgs_warns_capt))
}
}
Expand Down Expand Up @@ -649,13 +656,19 @@ divmin_augdat <- function(
if (!requireNamespace("iterators", quietly = TRUE)) {
stop("Please install the 'iterators' package.")
}
if (verbose_divmin && use_progressr()) {
progressor_obj <- progressr::progressor(ncol(projpred_ws_aug))
} else {
progressor_obj <- NULL
}
dot_args <- list(...)
`%do_projpred%` <- foreach::`%dopar%`
outdmin <- foreach::foreach(
projpred_w_aug_s = iterators::iter(projpred_ws_aug, by = "column"),
.packages = c("projpred"),
.export = c(
"sdivmin", "formula", "data", "family", "projpred_formula_no_random",
"projpred_random", "dot_args"
"projpred_random", "dot_args", "progressor_obj"
),
.noexport = c(
"object", "p_sel", "search_path", "p_ref", "refmodel", "projpred_var",
Expand All @@ -674,6 +687,7 @@ divmin_augdat <- function(
dot_args)
)
)
if (!is.null(progressor_obj)) progressor_obj()
return(nlist(soutdmin, mssgs_warns_capt))
}
}
Expand Down
7 changes: 7 additions & 0 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -713,3 +713,10 @@ element_unq <- function(list_obj, nm) {
}
return(el_unq)
}

use_progressr <- function() {
getOption("projpred.use_progressr",
requireNamespace("progressr", quietly = TRUE) &&
interactive() &&
identical(foreach::getDoParName(), "doFuture"))
}
13 changes: 13 additions & 0 deletions R/projpred-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@
#' (i.e., a parallelization of \pkg{projpred}'s cross-validation) which can be
#' activated via argument `parallel`.
#'
#' During parallelization (either of the projection or the CV), progression
#' updates can be received via the \pkg{progressr} package. This only works if
#' the \pkg{doFuture} backend is used for parallelization, e.g., via
#' `doFuture::registerDoFuture()` and `future::plan(future::multisession,
#' workers = 4)`. In that case, the \pkg{progressr} package can be used, e.g.,
#' by calling `progressr::handlers(global = TRUE)` before running the projection
#' or the CV in parallel. The \pkg{projpred} package also offers the global
#' option `projpred.use_progressr` for controlling whether to use the
#' \pkg{progressr} package (`TRUE` or `FALSE`), but since that global option
#' defaults to `requireNamespace("progressr", quietly = TRUE) && interactive()
#' && identical(foreach::getDoParName(), "doFuture")`, it usually does not need
#' to be set by the user.
#'
#' # Multilevel models: "Integrating out" group-level effects
#'
#' In case of multilevel models, \pkg{projpred} offers two global options for
Expand Down
11 changes: 11 additions & 0 deletions man/projpred-package.Rd

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