class_docstr: 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:<br>
  - BottomUp<br>
  - MinTraceOLS<br>
  - MinTraceWLS<br>
  - Identity
  
  **Parameters:**<br>
  `h`: int, Forecast horizon. <br>
  `model`: NeuralForecast model, instantiated model class from [architecture collection](https://nixtla.github.io/neuralforecast/models.pytorch.html).<br>
  `S`: np.ndarray, dumming matrix of size (`base`, `bottom`) see HierarchicalForecast's [aggregate method](https://nixtla.github.io/hierarchicalforecast/utils.html#aggregate).<br>
  `reconciliation`: str, HINT's reconciliation method from ['BottomUp', 'MinTraceOLS', 'MinTraceWLS'].<br>
  `alias`: str, optional,  Custom name of the model.<br>
class_docstr_tok: ["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",":","<","br",">","-","BottomUp","<","br",">","-","MinTraceOLS","<","br",">","-","MinTraceWLS","<","br",">","-","Identity","*","*","Parameters",":","*","*","<","br",">","`","h","`",":","int",",","Forecast","horizon",".","<","br",">","`","model","`",":","NeuralForecast","model",",","instantiated","model","class","from","[","architecture","collection","]","(","https",":","\/\/nixtla.github.io\/neuralforecast\/models.pytorch.html",")",".","<","br",">","`","S","`",":","np.ndarray",",","dumming","matrix","of","size","(","`","base","`",",","`","bottom","`",")","see","HierarchicalForecast","'s","[","aggregate","method","]","(","https",":","\/\/nixtla.github.io\/hierarchicalforecast\/utils.html","#","aggregate",")",".","<","br",">","`","reconciliation","`",":","str",",","HINT","'s","reconciliation","method","from","[","'BottomUp","'",",","'MinTraceOLS","'",",","'MinTraceWLS","'","]",".","<","br",">","`","alias","`",":","str",",","optional",",","Custom","name","of","the","model.","<","br",">"]
docstr: HINT.predict
  
  After fitting a base model on the entire hierarchical dataset.
  HINT restores the hierarchical aggregation constraints using
  bootstrapped sample reconciliation.
  
  **Parameters:**<br>
  `dataset`: NeuralForecast's `TimeSeriesDataset` see details [here](https://nixtla.github.io/neuralforecast/tsdataset.html)<br>
  `step_size`: int, steps between sequential predictions, (default 1).<br>
  `random_seed`: int, random seed for the prediction.<br>
  `**data_kwarg`: additional parameters for the dataset module.<br>
  
  **Returns:**<br>
  `y_hat`: numpy predictions of the `NeuralForecast` model.<br>
docstr_tok: ["HINT.predict","After","fitting","a","base","model","on","the","entire","hierarchical","dataset",".","HINT","restores","the","hierarchical","aggregation","constraints","using","bootstrapped","sample","reconciliation",".","*","*","Parameters",":","*","*","<","br",">","`","dataset","`",":","NeuralForecast","'s","`","TimeSeriesDataset","`","see","details","[","here","]","(","https",":","\/\/nixtla.github.io\/neuralforecast\/tsdataset.html",")","<","br",">","`","step_size","`",":","int",",","steps","between","sequential","predictions",",","(","default","1",")",".","<","br",">","`","random_seed","`",":","int",",","random","seed","for","the","prediction.","<","br",">","`","*","*","data_kwarg","`",":","additional","parameters","for","the","dataset","module.","<","br",">","*","*","Returns",":","*","*","<","br",">","`","y_hat","`",":","numpy","predictions","of","the","`","NeuralForecast","`","model.","<","br",">"]
code: def predict(
      self, 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.
  
      **Parameters:**<br>
      `dataset`: NeuralForecast's `TimeSeriesDataset` see details [here](https://nixtla.github.io/neuralforecast/tsdataset.html)<br>
      `step_size`: int, steps between sequential predictions, (default 1).<br>
      `random_seed`: int, random seed for the prediction.<br>
      `**data_kwarg`: additional parameters for the dataset module.<br>
  
      **Returns:**<br>
      `y_hat`: numpy predictions of the `NeuralForecast` model.<br>
      """
      # Non-reconciled predictions
      if self.reconciliation == "Identity":
          forecasts = self.model.predict(
              dataset=dataset,
              step_size=step_size,
              random_seed=random_seed,
              **data_module_kwargs,
          )
          return forecasts
  
      num_samples = self.model.loss.num_samples
  
      # Hack to get samples by simulating quantiles (samples will be ordered)
      # Mysterious parsing associated to default [mean,quantiles] output
      quantiles_old = self.model.loss.quantiles
      names_old = self.model.loss.output_names
      self.model.loss.quantiles = self.sample_quantiles
      self.model.loss.output_names = ["1"] * (1 + num_samples)
      samples = self.model.predict(
          dataset=dataset,
          step_size=step_size,
          random_seed=random_seed,
          **data_module_kwargs,
      )
      samples = samples[:, 1:]  # Eliminate mean from quantiles
      self.model.loss.quantiles = quantiles_old
      self.model.loss.output_names = names_old
  
      # Hack requires to break quantiles correlations between samples
      idxs = np.random.choice(
          num_samples, size=samples.shape, replace=True
      )
      aux_col_idx = np.arange(len(samples))[:, None] * num_samples
      idxs = idxs + aux_col_idx
      samples = samples.flatten()[idxs]
      samples = samples.reshape(
          dataset.n_groups, -1, self.h, num_samples
      )
  
      # Bootstrap Sample Reconciliation
      # Default output [mean, quantiles]
      samples = np.einsum("ij,jwhp->iwhp", self.SP, samples)
      forecasts = np.quantile(
          samples, self.model.loss.quantiles, axis=-1
      )
      forecasts = forecasts.transpose(1, 2, 3, 0)  # [...,samples]
      forecasts = forecasts.reshape(-1, len(self.model.loss.quantiles))
  
      sample_mean = np.mean(forecasts, axis=-1, keepdims=True)
      forecasts = np.concatenate([sample_mean, forecasts], axis=-1)
      return forecasts
  
file_path: neuralforecast/neuralforecast/models/hint.py
imports: from typing import Optional
  import numpy
  import torch
label_desc: Use image node_id 4 for calling the HINT obj's underlying member method code with example usage: obj.predict(dataset, step_size, random_seed) and returns: forecasts, forecasts