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

ENH: Add sparse middle-out reconciliation via MiddleOutSparse #281

Merged
merged 3 commits into from
Aug 22, 2024

Conversation

christophertitchen
Copy link
Contributor

@christophertitchen christophertitchen commented Aug 17, 2024

This PR adds a middle-out reconciliation class called MiddleOutSparse for sparse "summing" matrices, $S$, to significantly reduce the wall time for reconciling large hierarchical structures from a "middle" level, which now take at least $99.6 \%$ less time to reconcile.

  • Uses the data structure encoded in $S$ to efficiently identify the aggregation pathways in the subgraph terminating at the "middle" level to create a sparse $S$ of the subgraph.
  • Performs bottom-up reconciliation via BottomUpSparse and allocates the reconciled point forecasts in a memory-efficient manner.
  • Uses the data structure encoded in $S$ to efficiently identify the subgraphs for each cut node in the "middle" level by identifying their respective leaf nodes and slicing $S$ to find the remaining nodes, which are then converted to a CSR matrices.
  • Constructs the tags argument only if required for out-of-sample disaggregation methods, i.e. forecast proportions.
  • Avoids repeated checks for the strictness of the hierarchical data structure by setting tags to None for in-sample methods.
  • Finds the "horizontal" intersection of the nodes for each level and the subgraph for each cut node to efficiently construct the tags argument for the subgraph in the out-of-sample case.
  • Performs top-down reconciliation via TopDownSparse for each cut node and allocates the reconciled point forecasts in a memory-efficient manner.
  • Tests the output of MiddleOutSparse and equivalence with MiddleOut up to the machine epsilon of a double.
Dataset $\textup{dim} \left ( P \right )$ $K$ $T$ $h$ $\ell$ Method MiddleOut MiddleOutSparse Reduction
M5 $\small{\left( 30\, 490 \times 42\, 840 \right)}$ $12$ $1\, 969$ $28$ $9$ A #277 $\gt 2\, hr$ * $28.1\, s$ $ \gt \, 99.6 \%$ *

* This was cancelled after 2 hours. 😴

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Contributor

@elephaint elephaint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks! A few minor comments, mainly I think it's good that we lift all the Sparse methods to also include all the show_doc methods, so that it will included in the generation of the API reference for the docs. Wdyt?

hierarchicalforecast/methods.py Show resolved Hide resolved
hierarchicalforecast/methods.py Show resolved Hide resolved
nbs/methods.ipynb Show resolved Hide resolved
Copy link
Contributor

@elephaint elephaint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, again great work! Looking forward to seeing what you're up to next :)

I think after all your work it would be awesome if we update the docs and have a tutorial showing the nice sparse methods that you implemented. Let me know if you'd like to work on that, otherwise I'll pick that up sometime.

@christophertitchen
Copy link
Contributor Author

Thanks, again great work! Looking forward to seeing what you're up to next :)

I think after all your work it would be awesome if we update the docs and have a tutorial showing the nice sparse methods that you implemented. Let me know if you'd like to work on that, otherwise I'll pick that up sometime.

Thank you for your reviews and great suggestions, Olivier!

I would be happy to both update the docs and create a tutorial for the sparse methods.

@elephaint
Copy link
Contributor

Thanks, again great work! Looking forward to seeing what you're up to next :)
I think after all your work it would be awesome if we update the docs and have a tutorial showing the nice sparse methods that you implemented. Let me know if you'd like to work on that, otherwise I'll pick that up sometime.

Thank you for your reviews and great suggestions, Olivier!

I would be happy to both update the docs and create a tutorial for the sparse methods.

Great! Let's do that in another PR, I'll merge this one then.

@elephaint elephaint merged commit c9cf1ee into Nixtla:main Aug 22, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants