[FEAT] Covariance Estimation Module & Cross-Temporal Reconciliation#465
Draft
[FEAT] Covariance Estimation Module & Cross-Temporal Reconciliation#465
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces a dedicated covariance estimation module with a pluggable registry, and adds support for temporal and cross-temporal forecast reconciliation methods.
New Features
Covariance Module (
hierarchicalforecast/covariance.py)covariance.pymodule with a registry-based architecture for covariance estimation methodsregister_covariance()— register custom covariance methodsestimate_covariance()— unified entry point for all covariance estimationlist_covariance_methods()/is_diagonal_method()— introspection helpersols,wls_struct,wls_var,sam/mint_cov,shr/mint_shrink,bu,oasdwlsv,wlsh,acov,strar1,sar1,har1csstr,testr,bdshr,bdsam,sshr,ssam,hshr,hsam,hbshr,hbsam,bshr,bsamCross-Temporal Reconciliation (
hierarchicalforecast/core.py)reconcile()now acceptscross_temporal=TruewithS_cs_dfandS_te_dfto buildS_ct = S_cs ⊗ S_teautomaticallymethod_kwargsparameter for passing extra arguments to covariance estimatorsagg_orderfrom the temporal summing matrix whentemporal=TrueUtilities (
hierarchicalforecast/utils.py)build_cross_temporal_S()— constructs the cross-temporal summing matrix via Kronecker product with proper bottom-level reorderingChanges
MinTrace Refactor (
hierarchicalforecast/methods.py)MinTrace._get_PW_matrices()now delegates covariance estimation to the newcovariancemodule instead of inline logicmethod_kwargsfor forwarding temporal/cross-temporal parametersshralias support alongsidemint_shrinkC++ Backend (
src/reconciliation.cpp)shrunk_covariance_ss_with_nans: thread-local vectors instead of per-pair heap allocationsset_num_threads(n)(must be >= 1)Tests
tests/test_covariance.py— 1356 lines of new tests covering all covariance methods (cross-sectional, temporal, cross-temporal), the registry API, edge cases, and NaN handlingtests/test_methods.py— Extended with tests for new method names and temporal/cross-temporal reconciliation through MinTracetests/test_core.py— End-to-end temporal reconciliation tests with insample data, parametrized across pandas/polarsStats