-
Notifications
You must be signed in to change notification settings - Fork 31
Description
I wanted to collate some of the longer-term goals for MCMCChains. I think many of us would agree that MCMCChains is quite stable at this point. It generally works well, has an acceptably defined set of indexing and analysis tools, and has lots of interactions with the rest of the ecosystem (not just Turing anymore!).
However, I do think it's worth putting down in words the various issues we still have with MCMCChains. This issue will be the hub for general improvements to the package, big or small, that we hope we can get some other people to help out on.
Comments are appreciated.
Improvements:
Performance, particularly for display calls.
The first time the user calls display (explicitly or through REPL usage), it takes my machine about 6.5 seconds just to handle to display call. If you're a REPL user this is absolutely brutal. Granted, display(chain) does a ton of numerical work and thus lights up a lot of method compilation, but I wonder if there's a way to make the user experience here slightly better if possible.
Adding tools to reshape parameters into their original forms
We have a recent issue on this (#231) but it has appeared consistently for as long as I have been working on MCMCChains (nearly 2 years now). For example, if you have two parameters x[1]=4 and x[2]=2, it's pretty easy for us to say that these could be repacked into their semantic form x = [4, 2] and just given to the user that way. As of right now, it's not super easy to do this kind of thing -- you typically have to roll your own code that matches your model setup. get kind of solves this for you, but it could use a lot more work to create the (x=[4,2],) named tuple I would like to see.
Visual improvements to plotting and generally better heuristics
The plotting functionality of MCMCChains is pretty good, but it suffers from a lack of polish and doesn't have as many intuitive safeguards. For example, if you plot a chain with many parameters, by default all parameters will be thrown up with their own tiny density and trace plots that are completely unreadable. Obviously you can fix this quickly by just subsetting the chain (plot(chain["param1"])), but there should be a more palatable plot if the number of parameters is obscenely large. I think rstan has a good approach to this where it throws up just a mean and 95% posterior density for each parameter -- it's very compact.
On another note, we don't seem to specify plot spacing, so the text on plots can get smushed into other subplots. I'm not sure if this is a Plots.jl issue or our issue.
Heterogeneous variable types
My least favorite feature of MCMCChains behind the scenes is that it's all just a giant array when you get down to it. Arrays are great at lots of things, but not what we're using it for -- parameters might be Int or Float64 or Missing, and so including them all in one big array either type casts everything to Float64 or Union{Float64, Missing} (thus eliminating the value of Int parameters) or sets the type to Any which is garbage from the compiler's perspective.
I'm not really sure what the fix is here, other than providing either an alternative backend (with StructArrays or something else) or providing an entirely different AbstractChains object which would be in a separate package and evolve independently from MCMCChains.
I'm also not sure how valuable it is to fix this, considering the fact that arrays are actually really good for general purpose applications, and don't need too much extra work.