Learn R Programming

MachineShop (version 1.6.0)

resample: Resample Estimation of Model Performance

Description

Estimation of the predictive performance of a model estimated and evaluated on training and test samples generated from an observed data set.

Usage

resample(x, ...)

# S3 method for formula resample(x, data, model, control = MachineShop::settings("control"), ...)

# S3 method for matrix resample(x, y, model, control = MachineShop::settings("control"), ...)

# S3 method for ModelFrame resample(x, model, control = MachineShop::settings("control"), ...)

# S3 method for recipe resample(x, model, control = MachineShop::settings("control"), ...)

# S3 method for MLModel resample(x, ...)

# S3 method for MLModelFunction resample(x, ...)

Resamples(...)

Arguments

x

defines a relationship between model predictor and response variables. May be a formula, design matrix of predictors, ModelFrame, untrained recipe, or TunedRecipe object. Alternatively, a model function or call may be given first followed by objects defining the predictor and response relationship and the control value.

...

named or unnamed resample output to combine together with the Resamples constructor.

data

data frame containing observed predictors and outcomes.

model

model function, function name, or call.

control

control function, function name, or call defining the resampling method to be employed.

y

response variable.

Value

Resamples class object.

Details

Stratified resampling is performed for the formula method according to values of the response variable; i.e. categorical levels for factor, continuous for numeric, and event status Surv.

User-specified stratification variables may be specified for ModelFrames upon creation with the strata argument in its constructor. Resampling of this class is unstratified by default.

Variables in a recipe may be used for stratification by defining a "case_strata" role for them. Resampling will be unstratified if no variables have that role.

Output being combined from more than one model with the Resamples constructor must have been generated with the same resampling control object.

See Also

performance, metrics, plot, summary

Examples

Run this code
# NOT RUN {
## Factor response example

fo <- Species ~ .
control <- CVControl()

gbm_res1 <- resample(fo, iris, GBMModel(n.trees = 25), control)
gbm_res2 <- resample(fo, iris, GBMModel(n.trees = 50), control)
gbm_res3 <- resample(fo, iris, GBMModel(n.trees = 100), control)

summary(gbm_res1)
plot(gbm_res1)

res <- Resamples(GBM1 = gbm_res1, GBM2 = gbm_res2, GBM3 = gbm_res3)
summary(res)
plot(res)

# }

Run the code above in your browser using DataLab