train_model | R Documentation |
caret::train()
.Train model using caret::train()
.
train_model(
train_data,
outcome_colname,
method,
cv,
perf_metric_name,
tune_grid,
...
)
train_data |
Training data. Expected to be a subset of the full dataset. |
outcome_colname |
Column name as a string of the outcome variable
(default |
method |
ML method.
Options:
|
cv |
Cross-validation caret scheme from |
perf_metric_name |
The column name from the output of the function
provided to perf_metric_function that is to be used as the performance metric.
Defaults: binary classification = |
tune_grid |
Tuning grid from |
... |
All additional arguments are passed on to |
Trained model from caret::train()
.
Zena Lapp, zenalapp@umich.edu
## Not run:
training_data <- otu_mini_bin_results_glmnet$trained_model$trainingData %>%
dplyr::rename(dx = .outcome)
method <- "rf"
hyperparameters <- get_hyperparams_list(otu_mini_bin, method)
cross_val <- define_cv(training_data,
"dx",
hyperparameters,
perf_metric_function = caret::multiClassSummary,
class_probs = TRUE,
cv_times = 2
)
tune_grid <- get_tuning_grid(hyperparameters, method)
rf_model <- train_model(
training_data,
"dx",
method,
cross_val,
"AUC",
tune_grid,
ntree = 1000
)
rf_model$results %>% dplyr::select(mtry, AUC, prAUC)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.