我在具有36个核心的AWS实例上运行模型。虚拟数据示例:
library(mlbench)
data(Sonar)
library(caret)
library(doParallel)
set.seed(95014)
# create training & testing data sets
inTraining <- createDataPartition(Sonar$Class, p = .75, list=FALSE)
training <- Sonar[inTraining,]
testing <- Sonar[-inTraining,]
# set up training run for x / y syntax because model format performs poorly
x <- training[,-61]
y <- training[,61]
cl <- makePSOCKcluster(36)
registerDoParallel(cl)
fitControl <- trainControl(method = "cv",
number = 5,
allowParallel = TRUE)
fit <- train(x,y, method="cforest",data=Sonar,trControl = fitControl)
stopCluster(cl)
但是当我在htop
中查看时,只有一半的核心在计算。 doParallel
或caret
是否存在核心限制?