MansMeg / bayesbenchr

A bayesbench R package for quick posterior analysis
0 stars 0 forks source link

Inference engine input interface #2

Open eerolinna opened 5 years ago

eerolinna commented 5 years ago

Currently in this R version of bayesbench inference engines are defined like this

stan_vb <- function(cfg){
  model <- stan_model(cfg)
  data <- jsonlite::read_json(data_file_path(cfg), simplifyVector = TRUE)
  inference_engine_args <- inference_engine_arguments(cfg)
  ...
}

(simplified from ie_stan.R)

In python version of bayesbench I have used something like

stan_vb <- function(model, data, inference_engine_args=NULL, diagnostics=NULL){
  ...
}

Which one should we use?

Things I like with the python version

Downsides to the python version

MansMeg commented 5 years ago

Hmmm. I think the R-version is a little more clear with regards to our abstractions. We have the PDB and a cfg that contain everything. So for an IE creator the R version is more inline with abstractions. But this is not clear cut how to do.

eerolinna commented 5 years ago

We could also have

stan_vb <- function(cfg){
  model <- stan_model(cfg)
  data <- cfg$data
  inference_engine_args <- inference_engine_arguments(cfg)
  ...
}

Where we would still have everything in one object but bayesbench core would do some preprocessing, such as loading the json.

Slightly unrelated: how does stan_model(cfg) find the model as the config only specifies a posterior name and not the file paths etc? Wouldn't it need the posterior database also as a parameter? Or is stan_model(cfg) essentially an alias for (stan_model(cfg, posterior_database = get_default_posterior_database())?