Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCMC chains are inappropriately shown as tables #2472

Open
nilshg opened this issue Feb 8, 2023 · 5 comments
Open

MCMC chains are inappropriately shown as tables #2472

nilshg opened this issue Feb 8, 2023 · 5 comments
Labels
display & PlutoRunner & AbstractPlutoDingetjes.jl other packages Integration with other Julia packages

Comments

@nilshg
Copy link

nilshg commented Feb 8, 2023

No video on this one, you just need one line of code (plus the relevant package):

image

The code is:

using TuringGLM
sample(turing_model(@formula(y ~ x1 + x2), (y = rand(10), x1 = rand(10), x2 = rand(10))), NUTS(), 2_000)

When running this in the REPL you get:

image

Which is the desired output as users are interested in the summary statistics by parameter, rather than the individual iterations of the MCMC chain.

The Pluto display used to be the same as in the REPL, so there must have been some recent change to how chains get displayed/when the table display kicks in.

@nilshg
Copy link
Author

nilshg commented Feb 8, 2023

julia> Tables.istable(chain)
true

where chain is the result of the sample call above - so I guess the answer is yes.

@pankgeorg
Copy link
Collaborator

julia> Tables.istable(chain)
true

where chain is the result of the sample call above - so I guess the answer is yes.

Context: In a now-deleted comment, I asked if the chains are Table.jl like objects. I understood a bit later that the chains are "overloaded" to include both the iteration data and the metadata about the run, and what you want to see is the metadata and that's why I removed my comment.

The action here is to check whether we can make an HTML show method for these objects, and to make sure that Pluto will prefer these to the table viewer. I'll check the latter and suggest the former, probably with a PR, when I find some time (I do double duties as a dad lately so my contributions are a bit more limited 😮‍💨; but I'll get to it! friends say Turing is way to important not to pay appropriate attention!)

@nilshg
Copy link
Author

nilshg commented Feb 8, 2023

Thanks - I can relate, if you look at my repos you see how much time I get to push forward the things I'd like to see in Julia, in large part due to my kids (not complaining!)

And probably agreed that Turing is one of these showcase packages with a large enough userbase that you probably want to provide a smooth experience in Pluto for its users.

@fonsp
Copy link
Owner

fonsp commented Feb 16, 2023

I'm busy moving but I will respond soonish!

We want to find a general solution to this (something like JuliaLang/julia#47270 or JuliaPluto/AbstractPlutoDingetjes.jl#10) but until then it might be easiest to add a special case for this package, just like Symbolics.jl:

Integration(
id = Base.PkgId(UUID("0c5d862f-8b57-4792-8d23-62f2024744c7"), "Symbolics"),
code = quote
pluto_showable(::MIME"application/vnd.pluto.tree+object", ::Symbolics.Arr) = false
end,
),

@fonsp fonsp added other packages Integration with other Julia packages display & PlutoRunner & AbstractPlutoDingetjes.jl labels Feb 16, 2023
@Batmaev
Copy link

Batmaev commented Apr 9, 2023

You can still see the summary statistics, just call summarize(..):

Снимок экрана 2023-04-09 в 14 24 11

I personally prefer displaying the chain as a table of individual iterations because it provides a better understanding of what is inside the object and what you can do with it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display & PlutoRunner & AbstractPlutoDingetjes.jl other packages Integration with other Julia packages
Projects
None yet
Development

No branches or pull requests

4 participants