自定义调参网格

在 R 中使用 caret 的机器学习

Zach Mayer

Data Scientist at DataRobot and co-author of caret

自定义调参的利弊

  • 将自定义调参网格传给 tuneGrid
  • 优点
    • 拟合 caret 模型的最灵活方法
    • 完全控制模型的拟合方式
  • 缺点
    • 需要一定的模型知识
    • 可能大幅增加运行时间
在 R 中使用 caret 的机器学习

自定义调参示例

# Define a custom tuning grid
myGrid <- data.frame(mtry = c(2, 3, 4, 5, 10, 20))
# Fit a model with a custom tuning grid
set.seed(42)
model <- train(
  Class ~ ., 
  data = Sonar, 
  method = "ranger",            
  tuneGrid = myGrid
)
# Plot the results
plot(model)
在 R 中使用 caret 的机器学习

自定义调参

图片为准确率与随机选择的预测变量数量的折线图,在 x=10 处达到峰值。

在 R 中使用 caret 的机器学习

让我们来练习!

在 R 中使用 caret 的机器学习

Preparing Video For Download...