Skip to main content

module neuralforecast.models.hint


function get_bottomup_P

get_bottomup_P(S: ndarray)
BottomUp Reconciliation Matrix. Creates BottomUp hierarchical “projection” matrix is defined as: PBU=[0[b],[a]    I[b][b]]\mathbf{P}_{\text{BU}} = [\mathbf{0}_{\mathrm{[b],[a]}}\;|\;\mathbf{I}_{\mathrm{[b][b]}}] Args:
  • S (np.ndarray): Summing matrix of size (base, bottom).
Returns:
  • np.ndarray: Reconciliation matrix of size (bottom, base).
References:

function get_mintrace_ols_P

get_mintrace_ols_P(S: ndarray)
MinTraceOLS Reconciliation Matrix. Creates MinTraceOLS reconciliation matrix as proposed by Wickramasuriya et al. PMinTraceOLS=(SS)1S\mathbf{P}_{\text{MinTraceOLS}}=\left(\mathbf{S}^{\intercal}\mathbf{S}\right)^{-1}\mathbf{S}^{\intercal} Args:
  • S (np.ndarray): Summing matrix of size (base, bottom).
Returns:
  • np.ndarray: Reconciliation matrix of size (bottom, base).
References:

function get_mintrace_wls_P

get_mintrace_wls_P(S: ndarray)
MinTraceOLS Reconciliation Matrix. Creates MinTraceOLS reconciliation matrix as proposed by Wickramasuriya et al. Depending on a weighted GLS estimator and an estimator of the covariance matrix of the coherency errors Wh\mathbf{W}_{h}. Wh=Diag(S1[b]) \mathbf{W}_{h} = \mathrm{Diag}(\mathbf{S} \mathbb{1}_{[b]}) PMinTraceWLS=(SWhS)1SWh1\mathbf{P}_{\text{MinTraceWLS}}=\left(\mathbf{S}^{\intercal}\mathbf{W}_{h}\mathbf{S}\right)^{-1} \mathbf{S}^{\intercal}\mathbf{W}^{-1}_{h} Args:
  • S (np.ndarray): Summing matrix of size (base, bottom).
Returns:
  • np.ndarray: Reconciliation matrix of size (bottom, base).
References:

function get_identity_P

get_identity_P(S: ndarray)

class HINT

HINT The Hierarchical Mixture Networks (HINT) are a highly modular framework that combines SoTA neural forecast architectures with a task-specialized mixture probability and advanced hierarchical reconciliation strategies. This powerful combination allows HINT to produce accurate and coherent probabilistic forecasts. HINT’s incorporates a TemporalNorm module into any neural forecast architecture, the module normalizes inputs into the network’s non-linearities operating range and recomposes its output’s scales through a global skip connection, improving accuracy and training robustness. HINT ensures the forecast coherence via bootstrap sample reconciliation that restores the aggregation constraints into its base samples. Available reconciliations:
  • BottomUp
  • MinTraceOLS
  • MinTraceWLS
  • Identity
Args:
  • h (int): Forecast horizon.
  • model (NeuralForecast model): Instantiated model class from architecture collection.
  • S (np.ndarray): Dumming matrix of size (base, bottom) see HierarchicalForecast’s aggregate method.
  • reconciliation (str): HINT’s reconciliation method from [‘BottomUp’, ‘MinTraceOLS’, ‘MinTraceWLS’].
  • alias (str, optional): Custom name of the model.

method __init__

__init__(
    h: int,
    S: ndarray,
    model,
    reconciliation: str,
    alias: Optional[str] = None
)

method fit

fit(dataset, val_size=0, test_size=0, random_seed=None, distributed_config=None)
HINT.fit HINT trains on the entire hierarchical dataset, by minimizing a composite log likelihood objective. HINT framework integrates TemporalNorm into the neural forecast architecture for a scale-decoupled optimization that robustifies cross-learning the hierachy’s series scales. Args:
  • dataset (TimeSeriesDataset): NeuralForecast’s TimeSeriesDataset see details here
  • val_size (int): size of the validation set, (default 0).
  • test_size (int): size of the test set, (default 0).
  • random_seed (int): random seed for the prediction.
Returns:
  • self: A fitted base NeuralForecast model.

method get_test_size

get_test_size()

method predict

predict(dataset, step_size=1, random_seed=None, **data_module_kwargs)
HINT.predict After fitting a base model on the entire hierarchical dataset. HINT restores the hierarchical aggregation constraints using bootstrapped sample reconciliation. Args:
  • dataset (TimeSeriesDataset): NeuralForecast’s TimeSeriesDataset see details here
  • step_size (int): steps between sequential predictions, (default 1).
  • random_seed (int): random seed for the prediction.
  • **data_kwarg: additional parameters for the dataset module.
Returns:
  • y_hat: numpy predictions of the NeuralForecast model.

method save

save(path)
HINT.save Save the HINT fitted model to disk. Args:
  • path (str): path to save the model.

method set_test_size

set_test_size(test_size)