R package caret-Print iteration in parallel use

In any case, can we print the iteration while working with the function in parallel caret::train? I know there is an option called verbose, but it seems like it doesn't print anything if I use multicore.

+4
source share
1 answer

I have found a solution. All we need to do is register the kernels with the makeCluster function.

library(doSNOW)
cl <- makeCluster(30, outfile="")
registerDoSNOW(cl)

Thus, the magazine will be printed on the console. I tested on regular R / Rstudio / Rserver on mac / window / ubuntu (even AWS)

For instance,

iris <- iris[1:100,]
iris$Species <- as.factor(as.character(iris$Species))

tc <- trainControl(method="LGOCV",
                   summaryFunction=twoClassSummary,
                   classProb=T,verboseIter=TRUE)
train.rf <- train(Species ~ .,data=iris, 
                  method="rf", trControl=tc, 
                   metric =  "ROC")

will print

Type: EXEC 
loaded caret and set parent environment
Type: EXEC 
loaded caret and set parent environment
Type: EXEC 
Type: EXEC 
+ Resample01: mtry=2 
+ Resample01: mtry=3 
- Resample01: mtry=3 
Type: EXEC 
+ Resample02: mtry=2 
- Resample01: mtry=2 
Type: EXEC 
+ Resample01: mtry=4 
- Resample02: mtry=2 
Type: EXEC 
+ Resample02: mtry=3 
- Resample01: mtry=4 
Type: EXEC 
+ Resample02: mtry=4 
- Resample02: mtry=3 
Type: EXEC 
+ Resample03: mtry=2 
- Resample02: mtry=4 
Type: EXEC 
+ Resample03: mtry=3 
- Resample03: mtry=2 
Type: EXEC 
+ Resample03: mtry=4 
- Resample03: mtry=3 
Type: EXEC 
+ Resample04: mtry=2 
- Resample03: mtry=4 
Type: EXEC 
+ Resample04: mtry=3 
- Resample04: mtry=2 
Type: EXEC 
+ Resample04: mtry=4 
- Resample04: mtry=3 
Type: EXEC 
+ Resample05: mtry=2 
- Resample04: mtry=4 
Type: EXEC 
+ Resample05: mtry=3 
- Resample05: mtry=2 
Type: EXEC 
+ Resample05: mtry=4 
- Resample05: mtry=3 
Type: EXEC 
+ Resample06: mtry=2 
- Resample05: mtry=4 
Type: EXEC 
+ Resample06: mtry=3 
- Resample06: mtry=2 
Type: EXEC 
+ Resample06: mtry=4 
- Resample06: mtry=3 
Type: EXEC 
+ Resample07: mtry=2 
- Resample06: mtry=4 
Type: EXEC 
- Resample07: mtry=2 
+ Resample07: mtry=3 
Type: EXEC 
+ Resample07: mtry=4 
- Resample07: mtry=3 
- Resample07: mtry=4 
Type: EXEC 
Type: EXEC 
+ Resample08: mtry=2 
+ Resample08: mtry=3 
- Resample08: mtry=3 
Type: EXEC 
+ Resample09: mtry=2 
- Resample08: mtry=2 
Type: EXEC 
+ Resample08: mtry=4 
- Resample09: mtry=2 
Type: EXEC 
+ Resample09: mtry=3 
- Resample08: mtry=4 
Type: EXEC 
+ Resample09: mtry=4 
- Resample09: mtry=3 
Type: EXEC 
+ Resample10: mtry=2 
- Resample09: mtry=4 
Type: EXEC 
+ Resample10: mtry=3 
- Resample10: mtry=2 
Type: EXEC 
+ Resample10: mtry=4 
- Resample10: mtry=3 
Type: EXEC 
+ Resample11: mtry=2 
- Resample10: mtry=4 
Type: EXEC 
+ Resample11: mtry=3 
- Resample11: mtry=2 
Type: EXEC 
+ Resample11: mtry=4 
- Resample11: mtry=3 
Type: EXEC 
+ Resample12: mtry=2 
- Resample11: mtry=4 
Type: EXEC 
+ Resample12: mtry=3 
- Resample12: mtry=2 
Type: EXEC 
+ Resample12: mtry=4 
- Resample12: mtry=3 
Type: EXEC 
+ Resample13: mtry=2 
- Resample12: mtry=4 
Type: EXEC 
+ Resample13: mtry=3 
- Resample13: mtry=2 
Type: EXEC 
+ Resample13: mtry=4 
- Resample13: mtry=3 
Type: EXEC 
+ Resample14: mtry=2 
- Resample14: mtry=2 
Type: EXEC 
+ Resample14: mtry=4 
- Resample14: mtry=4 
Type: EXEC 
+ Resample15: mtry=2 
- Resample15: mtry=2 
Type: EXEC 
+ Resample15: mtry=3 
- Resample15: mtry=3 
Type: EXEC 
+ Resample15: mtry=4 
- Resample13: mtry=4 
Type: EXEC 
+ Resample14: mtry=3 
- Resample15: mtry=4 
Type: EXEC 
+ Resample16: mtry=2 
- Resample14: mtry=3 
Type: EXEC 
+ Resample16: mtry=3 
- Resample16: mtry=2 
Type: EXEC 
+ Resample16: mtry=4 
- Resample16: mtry=3 
Type: EXEC 
+ Resample17: mtry=2 
- Resample17: mtry=2 
Type: EXEC 
+ Resample17: mtry=4 
- Resample17: mtry=4 
Type: EXEC 
+ Resample18: mtry=2 
- Resample18: mtry=2 
Type: EXEC 
+ Resample18: mtry=3 
- Resample16: mtry=4 
Type: EXEC 
+ Resample17: mtry=3 
- Resample18: mtry=3 
Type: EXEC 
+ Resample18: mtry=4 
- Resample17: mtry=3 
Type: EXEC 
+ Resample19: mtry=2 
- Resample18: mtry=4 
Type: EXEC 
+ Resample19: mtry=3 
- Resample19: mtry=2 
Type: EXEC 
+ Resample19: mtry=4 
- Resample19: mtry=3 
Type: EXEC 
+ Resample20: mtry=2 
- Resample19: mtry=4 
Type: EXEC 
+ Resample20: mtry=3 
- Resample20: mtry=2 
Type: EXEC 
+ Resample20: mtry=4 
- Resample20: mtry=3 
Type: EXEC 
+ Resample21: mtry=2 
- Resample20: mtry=4 
Type: EXEC 
+ Resample21: mtry=3 
- Resample21: mtry=2 
Type: EXEC 
+ Resample21: mtry=4 
- Resample21: mtry=3 
Type: EXEC 
- Resample21: mtry=4 
+ Resample22: mtry=2 
Type: EXEC 
+ Resample22: mtry=3 
- Resample22: mtry=3 
Type: EXEC 
+ Resample23: mtry=2 
- Resample22: mtry=2 
Type: EXEC 
+ Resample22: mtry=4 
- Resample23: mtry=2 
Type: EXEC 
+ Resample23: mtry=3 
- Resample22: mtry=4 
Type: EXEC 
+ Resample23: mtry=4 
- Resample23: mtry=3 
Type: EXEC 
+ Resample24: mtry=2 
- Resample23: mtry=4 
Type: EXEC 
+ Resample24: mtry=3 
- Resample24: mtry=2 
Type: EXEC 
+ Resample24: mtry=4 
- Resample24: mtry=3 
Type: EXEC 
+ Resample25: mtry=2 
- Resample24: mtry=4 
Type: EXEC 
+ Resample25: mtry=3 
- Resample25: mtry=2 
Type: EXEC 
+ Resample25: mtry=4 
- Resample25: mtry=3 
- Resample25: mtry=4 
Aggregating results
Selecting tuning parameters
Fitting mtry = 2 on full training set
+4
source

Source: https://habr.com/ru/post/1547406/


All Articles