-
Notifications
You must be signed in to change notification settings - Fork 75
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
ENH: Add sparse top-down reconciliation via TopDownSparse
#277
ENH: Add sparse top-down reconciliation via TopDownSparse
#277
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Great work - can you also maybe add a small test demonstrating output equivalence (up to dtype precision)? |
Thanks, Olivier! I just added a test to check for equivalence between |
Hi, @elephaint. Can you think of any more changes or is it OK to be merged now? |
Thanks - sorry for the late reply. Great work! I have a small comment, I think other than that it's good to go. Thanks also for adding the output equivalence test! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See small comment - might want to initialize P as a csr_matrix directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, awesome! One minor thing, left a suggestion in the code.
Co-authored-by: Olivier Sprangers <45119856+elephaint@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
This PR adds a top-down reconciliation class called$S$ , to significantly reduce the wall time for reconciling large hierarchical structures using disaggregation proportions, which now take $98 \%$ to $100 \%$ less time to reconcile.
TopDownSparse
for sparse "summing" matrices,TopDownSparse
uses the_get_PW_matrices
method to efficiently instantiate and allocateThe same tests for
TopDown
innbs/methods.ipynb
are now evaluated onTopDownSparse
as well, and the class supports all of the disaggregation methods ofTopDown
. This required a small change in_get_child_nodes
to check for the presence of a sparse matrix if disaggregating using forecast proportions.method
average_proportions
proportion_averages
forecast_proportions
The benchmarks for
fit_predict
across a few large hierarchical datasets are below, measured on a machine with 6/12 x 2.6 GHz (dynamic frequency scaling to 4.5 GHz) cores and 16 GB RAM.Note:$P$ is only used for methods A and F, not FP, so there will be no performance gain with $p_j$ for each $j$ , depending on the respective disaggregation pathway. There are practical approaches to deal with this while accepting further information loss, like creating a synthetic disaggregation pathway directly from the top node to the bottom nodes, such that $p_j=\hat{y}_{j, h} / \hat{y}_{h}$ , selecting a single disaggregation pathway for each $j$ , or averaging them, but that is beyond the scope of this PR. Also, note that the private dataset is quite interesting in the sense that the number of aggregated time series is greater than the number of bottom level time series, which is not usually the case for practical problems. This is not an issue here, but becomes more consequential in min trace reconciliation as inverting $S'W^{-1}S$ in the structural representation becomes more efficient than inverting $CWC'$ in the zero-constrained representation as $n_{a} > n_{b}$ , not that min trace reconciliation scales particularly well on large hierarchical structures anyway, apart from perhaps structural scaling.
TopDownSparse
when disaggregating using forecast proportions, only historical proportions. Although the private and M5 datasets are not strictly hierarchical, this is not an issue when disaggregating using methods A and F, because the proportions do not depend on the disaggregation pathways from the top node to the bottom nodes. However, this is not the case with method FP, which is invalid for these structures as there are multipleTopDown
TopDownSparse