'I need good model serialization. Default R serialization is nighter safe nor effective from the point of model size

MLR3 model includes a lot of redundant data not needed when applying the model. The traditional R approach is to save all the data used for model training. It leads to the growth of used memory. What leads to the growth of used memory. In the traditional R model, it usually can be fixed easily by just assigning NULL to redundant fields. But it is not so clear for mlr3.



Solution 1:[1]

You can directly access the underlying model in mlr3 using the $model slot, see e.g. the basics chapter in the mlr3 book. This is where the trained model is put and what's used to make the predictions, so you can modify this in exactly the same way as you would modify the model directly.

Of course, some of this may break other mlr3 functionality, e.g. information on feature importance that is used by some other functions. But in principle, you can perform exactly the same model customization that you can do for the "raw" model.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lars Kotthoff