03/03/2023, 12:14 AM
Hi Team, I am using hierarchicalforecast I am getting this error when I run HierarchicalReconciliation : hrec = HierarchicalReconciliation(reconcilers=reconcilers) reconciled_forecasts = hrec.reconcile(Y_hat_df=forecasts_df, S=S, tags=tags)
Copy code
ValueError                                Traceback (most recent call last)
Cell In[185], line 3
      1 hrec = HierarchicalReconciliation(reconcilers=reconcilers)
----> 3 reconciled_forecasts = hrec.reconcile(Y_hat_df=forecasts_df, S=S, tags=tags2)

File ~\Anaconda3\envs\pycaret\lib\site-packages\hierarchicalforecast\, in HierarchicalReconciliation.reconcile(self, Y_hat_df, S, tags, Y_df, level, intervals_method, num_samples, seed, sort_df)
    261     fcsts_model = reconciler.predict(S=reconciler_args['S'], 
    262                                      y_hat=reconciler_args['y_hat'], level=level)
    263 else:
    264     # Memory efficient reconciler's fit_predict
--> 265     fcsts_model = reconcile_fn(**kwargs, level=level)
    267 # Parse final outputs
    268 Y_tilde_df[recmodel_name] = fcsts_model['mean'].flatten()

File ~\Anaconda3\envs\pycaret\lib\site-packages\hierarchicalforecast\, in MiddleOut.fit_predict(self, S, y_hat, tags, y_insample, level, intervals_method)
    456 """Middle Out Reconciliation Method.
    458 **Parameters:**<br>
    465 `y_tilde`: Reconciliated y_hat using the Middle Out approach.
    466 """
    467 if not is_strictly_hierarchical(S, tags):
--> 468     raise ValueError('Middle out reconciliation requires strictly hierarchical structures.')
    469 if self.middle_level not in tags.keys():
    470     raise ValueError('You have to provide a `middle_level` in `tags`.')

ValueError: Middle out reconciliation requires strictly hierarchical structures.
This is how my tags looks like :
Copy code
{'Total': array(['Total'], dtype=object),
 'Total/level0': array(['DRAM_DRAM_M', 'NAND_SSD', 'DRAM_DRAM', 'NAND_FLASH'], dtype=object),
 'Total/level0/Level1': array(['DRAM_DRAM_M_DDR3', 'DRAM_DRAM_M_DDR4', 'NAND_SSD_PCI-e',
 'Total/level0/Level1/Level2': array(['DRAM_DRAM_M_DDR3_DDR3', 'DRAM_DRAM_M_DDR4_DDR4',
        'DRAM_DRAM_M_DDR5_DDR5'], dtype=object)}
can anyone pls help ?

Kin Gtz. Olivares

03/03/2023, 12:19 AM
Hi @Arjun , Thanks for using the library the MiddleOut and TopDown reconciliation methods are available for strictly hierarchical structures (not grouped series). Here is an explanation of the difference between hierarchical and grouped series:
🙌 1