Customising Loss Functions in R

Hi All,

I wondered if there were packages that allow the user to customise the loss function?

For example, if a package like ranger had a loss function which minimises OOB MSE. Is it somehow possible to customise this into a model which minimises negative loglikelihood?

Would appreciate any feedback here

It will depend on the package. Either ranger will allow it or not

Hi @nirgrahamuk . Valid point.

I know ranger does allow it. There is a published example where the authors have calculated the -loglik for their own model, alongside the ranger model.

However, it's not something you can do within the context of ranger itself. I think it has to be generated using another package. I just wondered if you knew of examples (ranger or otherwise), where customised loss functions can be imposed on a model?

Such as transforming the objective from minimising MSE, to minimising -loglik.

caret::trainControl has an arguments metric and summaryFunction that together give you a variety of options. The package gives you a variety of summaryFunctions for various types of problems to identify optimal R2, RMSE, Accuracy, Kappa etc. , but I believe you can also write your own summaryFunction.

thank you @arthur.t . I appreciate your feedback there. I'll check out more of the Caret stuff. Appreciated

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.