-
Notifications
You must be signed in to change notification settings - Fork 31
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
Mean of grouped variables as array #231
Comments
You can extract the mean column from the m = mean(group(chain, var))
m.nt.mean But I think you've highlighted a bigger issue, which is that we have no ability to reconstruct variables into their original shapes. We've thought about it a lot but have never gotten around to it. |
BTW I just learnt about JuliaArrays/AxisArrays.jl#182 some days ago (while reviewing the DiffEq tutorial), which is pretty bad - indexing by names will give surprising results (and probably lead to subtle bugs) since the parameters are always ordered according to the original chain instead of the provided vector. |
I'm beginning to not be very fond of |
Maybe we should consider switching to https://github.com/mcabbott/AxisKeys.jl soon while still thinking about other data formats such as StructArrays which might sometimes be more suitable? |
@phipsgabler ChainDataFrames implements the Tables interface, so at least it should be easy to convert it to a Vector of NamedTuples or a NamedTuple of Vectors by running |
I think the central issue is more that we're not taking Two months ago I was thinking about implementing a kind of trie- or R-tree-based dictionary, to store a mapping from This was because I always had the same kind of problems, like storing Do |
They do, but AxisArrays are kind of a non-starter for long-term development. They basically require all variables share a type, so including integer and continuous variables tends to make arrays of type I'm all for some kind of |
When a chain contains, say,
x[1]
andx[2]
, thenmean(group(chain, :x))
works nicely to see the mean ofx
. Now I'd have expectedArray(mean(group(chain, :x)))
to convert it to a vector, just likeArray(group(chain, :x))
does, but it doesn't work, as the result ofgroup
is aChainDataFrame
which can't be treated this way. Instead you have to do something likewhich is much longer and more unreadable. It would be cool to have a shorter variant -- I guess this is a pretty common operation?
Or is there an alternative I have overlooked? In that case, the documentation could be improved.
The text was updated successfully, but these errors were encountered: