Efron-Tibshirani (1997), Breiman (1996): score each observation
ONLY with the fits whose bootstrap sample excluded it. Honesty is
structural – no point is ever scored by a fit that saw it – and
each point is out of bag for about 36.8% of replicates, the 0.632
complement, which the tests assert. Points in every bag are
dropped and counted; a large count means B is too small.
Usage
morie_bt_oob(x, y, fit_fn, predict_fn, B = 100L, loss = NULL, seed = 0)
Arguments
- x, y
predictors and response.
- fit_fn
function(x_boot, y_boot) returning a fitted object.
- predict_fn
function(fitted, x_new) returning predictions.
- B
replicates.
- loss
elementwise loss; squared error when NULL.
- seed
resampling seed.
Value
list: err_oob, err_apparent, per_observation, n_dropped,
oob_fraction, B, n, method.
References
Efron and Tibshirani (1997), JASA 92:548-560;
Breiman (1996), "Out-of-bag estimation", UC Berkeley.
Examples
set.seed(1)
if (morie_crypto_liboqs_available()) {
x <- matrix(stats::rnorm(60), 30)
y <- x[, 1] + stats::rnorm(30)
fit <- function(Xa, ya) qr.coef(qr(cbind(1, Xa)), ya)
prd <- function(b, Xn) as.numeric(cbind(1, Xn) %*% b)
morie_bt_oob(x, y, fit, prd, B = 20)$err_oob
}