开始使用免费开始使用

Using custom trainControl

Now that you have a custom trainControl object, it's easy to fit caret models that use AUC rather than accuracy to tune and evaluate the model. You can just pass your custom trainControl object to the train() function via the trControl argument, e.g.:

train(<standard arguments here>, trControl = myControl)

This syntax gives you a convenient way to store a lot of custom modeling parameters and then use them across multiple different calls to train(). You will make extensive use of this trick in Chapter 5.

本练习是课程的一部分

Machine Learning with caret in R

查看课程

练习说明

  • Use train() to predict Class from all other variables in the Sonar data (that is, Class ~ .). It should be a glm model (that is, set method to "glm") using your custom trainControl object, myControl. Save the result to model.
  • Print the model to the console and examine its output.

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Train glm with custom trainControl: model



# Print model to console
编辑并运行代码