0

I want to implement my own customized loss function for a random forest regression in R. I found this Random Forests with a Customized Loss Function on how to do it in python, however not in R.

I would think that maybe the mlr3 package lets you customize loss functions in any way? I only found how to customize performance measures for assessing performance, and not for training. Any help or hints are appreciated!

  • 2
    I don't know if package `randomForest` admits custom objective function (i guess no, because regression method is automatically established from the response data type). Xgboost [can be set to work as randomForest](https://xgboost.readthedocs.io/en/stable/tutorials/rf.html) and admits custom objective functions. An also has the benefit of speed. – Ric Nov 08 '22 at 16:59
  • thank you so much for your answer @RicVillalba, that looks promising – Max Mustermann Nov 08 '22 at 17:58

1 Answers1

0

mlr3 doesn't provide any of the actual learners, so you can only do this if the random forest implementation allows to do it. At least the common implementations in R don't allow this.

Of course you can always modify the source code, as suggested in the linked question for Python.

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204