r/rstats • • 8d ago

Preferred libraries for Bayesian Optimization

I've been trying to move a Bayesian optimization setup I made in Python via Scikit Learn & Optuna over to R and I found a couple different ways to do it.

The first results I found were tutorials using caret and rBayesianOptimization packages. Upon digging further I found out about Tidymodels and the whole system with Parsnip + Dials seems to be similar to what I was using and more recently updated.

Wanted to ask if there was a significant difference in performance between these different Bayesian optimization methods, and if there is a package I haven't found yet that I really should be using for this. My guess is that I'm overthinking it and that if I like Tidyverse then I should use Tidymodels.

The specific models I'm optimizing are survival or time-to-event models. I initially made these via scikit-survival + lifelines but I've been moving to the survival + ranger R packages so I can run them with the MICE multiple imputation package.

11 Upvotes

11 comments sorted by

6

u/Mooks79 8d ago

You could also look at mlr3, which is a metaverse of modelling tools like tidymodels but using a more sklearn style syntax / paradigm, which may feel more natural to you.

1

u/Xenon_Chameleon 3d ago

Thank you, I did see this name come up but still need to check it out. Is there a big performance difference with large datasets?

1

u/Mooks79 3d ago

Not really. They are both essentially just wrappers to the underlying modelling packages so “under the hood” it’s the exact same stuff. With the caveat that the pre/post-processing they do is done primarily with dplyr or data.table so if you’re doing a lot of that on large datasets then you might see a difference; but it’s likely to be a fraction of a percent compared to your training time, for example.

Then it’s just a case of which syntax you prefer or which has functionality you need - not so long ago mlr3 was clearly more featureful and, with the way you can create pipelines, it probably still is. That said, tidymodels has come a long way in the last couple of years and supports some unusual packages.

It’s probably worth trying out both and deciding from there, it can’t hurt to be at least familiar with both.

2

u/novica 8d ago

1

u/Xenon_Chameleon 3d ago

Thank you! The parallelization is definitely needed here and the Github tutorial is very helpful.

4

u/PandaJunk 8d ago

Rather than Bayesian optimization, have you considered just regular optimization with something like JAX? Or something from the Julia ecosystem? For problems with no good priors, that may be a way to get a good enough solution without going full Bayes. Or could even be used as a first step towards full Bayes.

1

u/Junior_Bee7274 6d ago

I'd stick with what you're comfortable with. No need to overcomplicate things unless you're seeing actual performance issues.

1

u/Xenon_Chameleon 3d ago

Yeah, I wanted to gauge if there was some drastically better option for this kind of thing. The main reason I'm doing all of this in R is to avoid the bigger headache of trying to use MICE in R without having to jump back and forth between R and Python. Best Python equivalent I could find for it in scikit learn is labeled as "experimental" so I didn't want to use it for this particular project.

1

u/0rangetree_ 8d ago

mlr3mbo does what you want

1

u/si_wo 6d ago

I like BayesianTools which is an mcmc solver