View source: R/evaluate_resampling.R
evaluate_resampling | R Documentation |
evaluate_resampling()
uses repeated K-fold cross-validation and
the Root Mean Square Error (RMSE) of testing sets to measure the predictive
power of a single model. Methods are provided for
trending::trending_model
(and lists of these) objects.
evaluate_resampling(x, ...)
## Default S3 method:
evaluate_resampling(x, ...)
## S3 method for class 'trending_model'
evaluate_resampling(
x,
data,
metric = c("rmse", "rsq", "mae"),
metric_arguments = list(na.rm = TRUE),
v = nrow(data),
repeats = 1,
...
)
## S3 method for class 'list'
evaluate_resampling(
x,
data,
metric = c("rmse", "rsq", "mae"),
metric_arguments = list(na.rm = TRUE),
v = nrow(data),
repeats = 1,
...
)
x |
An R object. |
... |
Not currently used. |
data |
a |
metric |
One of "rmse" (see calculate_rmse), "mae" (see calculate_mae) and "rsq" (see calculate_rsq). |
metric_arguments |
A named list of arguments passed to the underlying functions that calculate the metrics. |
v |
the number of equally sized data partitions to be used for K-fold
cross-validation; |
repeats |
the number of times the random K-fold cross validation should be repeated for; defaults to 1; larger values are likely to yield more reliable / stable results, at the expense of computational time |
These functions wrap around existing functions from several
packages. evaluate_resampling.trending_model()
and
evaluate_resampling.list()
both use rsample::vfold_cv()
for sampling
and, for the calculating the different metrics, the
yardstick package.
calculate_aic()
, calculate_rmse()
, calculate_mae()
and
calculate_rsq()
.
x <- rnorm(100, mean = 0)
y <- rpois(n = 100, lambda = exp(x + 1))
dat <- data.frame(x = x, y = y)
model <- trending::glm_model(y ~ x, poisson)
models <- list(
poisson_model = trending::glm_model(y ~ x, poisson),
linear_model = trending::lm_model(y ~ x)
)
evaluate_resampling(model, dat)
evaluate_resampling(models, dat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.