Learn R Programming

MachineShop (version 2.0.0)

TunedModel: Tuned Model

Description

Model tuning over a grid of parameter values.

Usage

TunedModel(
  model,
  grid = MachineShop::settings("grid"),
  fixed = NULL,
  control = MachineShop::settings("control"),
  metrics = NULL,
  stat = MachineShop::settings("stat.Train"),
  cutoff = MachineShop::settings("cutoff")
)

Arguments

model

model function, function name, or call defining the model to be tuned.

grid

data frame containing parameter values at which to evaluate a single model supplied to models, such as that returned by expand_params; the number of parameter-specific values to generate automatically if the model has a pre-defined grid; or a call to Grid or ParameterGrid.

fixed

list of fixed parameter values to combine with those in grid.

control

control function, function name, or call 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.

stat

function or character string naming a function to compute a summary statistic on resampled metric values for model tuning.

cutoff

argument passed to the metrics functions.

Value

TunedModel class object that inherits from MLModel.

Details

Response Types:

factor, numeric, ordered, Surv

See Also

fit, resample

Examples

Run this code
# NOT RUN {
# 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 = Grid(length = 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))))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab