R中的插入符号:设置allowParallel的核心数量? [英] Caret in R: Set number of cores for allowParallel?
问题描述
我正在使用R的插入符号包,并且在训练函数(火车)中使用了有效的allowParallel参数.但是,它使用了所有内核,并且由于培训是在本地PC上运行的,所以我宁愿为自己留一个内核,以便能够在培训模型的同时进行工作.有什么办法吗?
I am using R's caret package, and in the training function (train) I use the allowParallel Parameter, which works. However, it uses all of the cores, and since the training runs on my local PC I would rather leave one core for myself to be able to work while training models. Is there any way to do this?
从我收集的数据来看,似乎不同的模型类型可能会使用不同的并行化程序包.我正在Windows上工作,所以我想它没有使用doMC(我知道如何设置内核数...)
From what I've gathered it seems that different model types might use different parallelization packages. I am working on windows, so I guess it's not using doMC (where I know how to set the number of cores...)
推荐答案
因此,在进行了更多研究之后,我找到了一种使用所需内核数的方法:train可以选择直接指定与num.threads = 7
(8个核中有7个)
So after more research, I found a way to use the number of cores I want: train has the option to directly specify the number of cores to use with num.threads = 7
(for 7 out of 8 cores)
rf_model<-train(Target~., data = df_tree_train, method = "ranger",
trControl = trainControl(method = "oob"
, verboseIter = TRUE
, allowParallel = TRUE
, classProbs = TRUE
)
, verbose = T
, tuneGrid = tuneGrid
, num.trees = 50
, num.threads = 7 # <- This one
)
这篇关于R中的插入符号:设置allowParallel的核心数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!