Parallelization refers to the process of running multiple jobs in parallel, simultaneously. This process allows for significant savings in computing power.
mlr3 is capable of parallelizing a variety of different scenarios.
One of the most used cases is to parallelize the
See Section Resampling for a detailed introduction to resampling.
In the following section, we will use the spam task and a simple classification tree (
"classif.rpart") to showcase parallelization.
We use the future package to parallelize the resampling by selecting a backend via the function
We use the
future::multiprocess backend here which uses forks (c.f.
parallel::mcparallel()) on UNIX based systems and a
socket cluster on Windows or if running in RStudio:
By default all CPUs of your machine are used unless you specify argument
On most systems you should see a decrease in the reported elapsed time. On some systems (e.g. Windows), the overhead for parallelization is quite large though. Therefore, it is advised to only enable parallelization for resamplings where each iteration runs at least 10 seconds.
Choosing the parallelization level
If you are transitioning from mlr, you might be used to selecting different parallelization levels, e.g. for resampling, benchmarking or tuning. In mlr3 this is no longer required. All kind of events are rolled out on the same level. Therefore, there is no need to decide whether you want to parallelize the tuning OR the resampling.
In mlr3 this is no longer required. All kind of events are rolled out on the same level - there is no need to decide whether you want to parallelize the tuning OR the resampling.
Just lean back and let the machine do the work :-)