set_threads | R Documentation |
Control the parallelism via threading while calling external packages from mlr3.
For example, the random forest implementation in package ranger (connected
via mlr3learners) supports threading via OpenMP.
The number of threads to use can be set via hyperparameter num.threads
, and
defaults to 1. By calling set_threads(x, 4)
with x
being a ranger learner, the
hyperparameter is changed so that 4 cores are used.
If the object x
does not support threading, x
is returned as-is.
If applied to a list, recurses through all list elements.
Note that threading is incompatible with other parallelization techniques such as forking via the future::plan future::multicore. For this reason all learners connected to mlr3 have threading disabled in their defaults.
set_threads(x, n = availableCores(), ...)
## Default S3 method:
set_threads(x, n = availableCores(), ...)
## S3 method for class 'R6'
set_threads(x, n = availableCores(), ...)
## S3 method for class 'list'
set_threads(x, n = availableCores(), ...)
x |
(any) |
n |
( |
... |
(any) |
Same object as input x
(changed in-place),
with possibly updated parameter values.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.