Right now, you need a separate script to fit each model (e.g. fit_baseline_model.py). I would want all of that functionality inside the package, so that each "model" follows a common pattern for doing MCMC and then producing the samples.
My approach here was:
Define an object (which I have no better name for than a "model"), e.g., Baseline
This object has a factory for the function that you feed into the MCMC. E.g.,
This object has a method for doing the postprocessing:
samples = my_model.postprocess_mcmc(mcmc)
The ideas here are:
For a given "model" (e.g., baseline), you put the numpyro.sample "model" and the postprocessing into one place, in the package.
You can then access models programmatically. Eg given the string "Baseline", you can find the Baseline object with linmod.models.__dict__["Baseline"]. This means you can have a single fit_model.py that takes "Baseline" as a command line argument. This is a good thing, because then you can have a yaml config that reads in a list of models like "Baseline" and then can run that way.
You minimize the passing around of things like the number of chains, etc.
Something I didn't understand was the use of the word "samples," which seems to used both for the thing that comes out of the model (which is what I would have thought) but also metadata.csv. I might have made some mistake there.
Right now, you need a separate script to fit each model (e.g.
fit_baseline_model.py
). I would want all of that functionality inside the package, so that each "model" follows a common pattern for doing MCMC and then producing the samples.My approach here was:
Baseline
The ideas here are:
numpyro.sample
"model" and the postprocessing into one place, in the package."Baseline"
, you can find theBaseline
object withlinmod.models.__dict__["Baseline"]
. This means you can have a singlefit_model.py
that takes"Baseline"
as a command line argument. This is a good thing, because then you can have a yaml config that reads in a list of models like "Baseline" and then can run that way.Something I didn't understand was the use of the word "samples," which seems to used both for the thing that comes out of the model (which is what I would have thought) but also
metadata.csv
. I might have made some mistake there.