TunedModel {MachineShop} | R Documentation |
Tuned Model
Description
Model tuning over a grid of parameter values.
Usage
TunedModel(
object,
grid = MachineShop::settings("grid"),
control = MachineShop::settings("control"),
metrics = NULL,
cutoff = MachineShop::settings("cutoff"),
stat = MachineShop::settings("stat.TrainingParams")
)
Arguments
object |
model function, function name, or object defining the model to be tuned. |
grid |
single integer or vector of integers whose positions or names
match the parameters in the model's pre-defined tuning grid if one exists
and which specify the number of values used to construct the grid;
|
control |
control function, function name, or object defining the resampling method to be employed. |
metrics |
metric function, function name, or vector of these with which to calculate performance. If not specified, default metrics defined in the performance functions are used. Model selection is based on the first calculated metric. |
cutoff |
argument passed to the |
stat |
function or character string naming a function to compute a summary statistic on resampled metric values for model tuning. |
Details
The expand_modelgrid
function enables manual extraction and
viewing of grids created automatically when a TunedModel
is fit.
- Response types:
factor
,numeric
,ordered
,Surv
Value
TunedModel
class object that inherits from MLModel
.
See Also
Examples
## Requires prior installation of suggested package gbm to run
## May require a long runtime
# Automatically generated grid
model_fit <- fit(sale_amount ~ ., data = ICHomes,
model = TunedModel(GBMModel))
varimp(model_fit)
(tuned_model <- as.MLModel(model_fit))
summary(tuned_model)
plot(tuned_model, type = "l")
# Randomly sampled grid points
fit(sale_amount ~ ., data = ICHomes,
model = TunedModel(
GBMModel,
grid = TuningGrid(size = 1000, random = 5)
))
# User-specified grid
fit(sale_amount ~ ., data = ICHomes,
model = TunedModel(
GBMModel,
grid = expand_params(
n.trees = c(50, 100),
interaction.depth = 1:2,
n.minobsinnode = c(5, 10)
)
))