r - 在多个线程中使用 caret::trainControl 是否安全?
问题描述
我反复使用 caret::train 函数来生成许多独立的模型。我让它并行运行,我想知道是否需要为 caret::train 的每次迭代创建 caret::trainControl 对象。caret::train 函数在什么情况下会修改 trainControl 对象吗?
在代码中,我猜它可以简化为...
require(caret)
models <- c("mpg ~ wt", "mpg ~ hp")
# Do I have to do this?
for (m in models) {
tc <- caret::trainControl(method="repeatedcv", number=5, repeats=5)
model <- caret::train(as.formula(m), data=mtcars, trControl=tc, method="lm")
}
# Or can I get away with this
tc <- caret::trainControl(method="repeatedcv", number=5, repeats=5)
for (m in models) {
model <- caret::train(as.formula(m), data=mtcars, trControl=tc, method="lm")
}
显然,我所有的列车控制参数对于每个模型都是相同的。
谢谢!
解决方案
推荐阅读
- google-bigquery - 提取 UNNEST () 内部子查询的输出并传递给外部主查询
- bash - 无法从 Apache 日志中获取文件名
- typescript - spy.and.throwError() - 将错误作为对象抛出?
- linux - 如何在内核 4.19.x 中构建 debuginfo rpm
- c++ - VSCode C++编译的exe感染了Win32:TrojanX-gen[Trj]
- r - 创建一个新列,其字母跟在行数后面
- vue.js - Why are v-model inputs in my Vue app triggering mutation errors on change?
- java - 如何将maven父项目和子项目设置为单独的项目?
- javascript - Javascript 中的表达式和参数
- javascript - 选项卡更改时图像缩放滞后