Hi, when i try to do a mintshrink or mint wls reco...
# hierarchicalforecast
b
Hi, when i try to do a mintshrink or mint wls reconciliation method I get an error. Bottomup and mintols work perfectly fine. Why could this be?
KeyError: 'value' The above exception was the direct cause of the following exception: KeyError Traceback (most recent call last)
j
you have some code?
hehe 🙂 here i cant't really see why you get an keyerror issue. sorry
b
Is there any extra input other MinTrace methods might need? Because I just tried TopDown and that one also seems to work.
j
doesnt need another keyword or param. i wonder where aggregation_df is coming from? is it the fitted values or the training df? maybe something off here?
b
The training df. I would assume that if something is off there, OLS also would not work.
j
when hierarchy is not strict, then maybe you have it nested somehow? can you show the hierarchy lists?
o
If you give a full code (not the above, that doesn't show the full code nor the error message) happy to help
b
That is the error I get. My code is too long for me to be able to put it here. Is this a known issue? I have tried mintacesparse too, get the same error.
KeyError Traceback (most recent call last) 3804 try: -> 3805 return self._engine.get_loc(casted_key) 3806 except KeyError as err: File index.pyx:167, in pandas._libs.index.IndexEngine.get_loc() File index.pyx:196, in pandas._libs.index.IndexEngine.get_loc() File pandas/_libs/hashtable_class_helper.pxi:7081, in pandas._libs.hashtable.PyObjectHashTable.get_item() File pandas/_libs/hashtable_class_helper.pxi:7089, in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'value' The above exception was the direct cause of the following exception: KeyError Traceback (most recent call last) Cell In[45], <vscode-notebook-cell:?execution_count=45&line=11|line 11> <vscode-notebook-cell:?execution_count=45&line=2|2> best_mae_per_unique_id = ( <vscode-notebook-cell:?execution_count=45&line=3|3> evaluaties_df.select_dtypes(include=["float32", "float64"]) <vscode-notebook-cell:?execution_count=45&line=4|4> .min(axis=1) (...) ... 3815 # InvalidIndexError. Otherwise we fall through and re-raise 3816 # the TypeError. 3817 self._check_indexing_error(key) KeyError: 'value' Output is truncated. View as a <command:cellOutput.enableScrolling?edfa2960-b4a1-4f49-8915-c42cbb6edff0|scrollable element> or open in a <command:workbench.action.openLargeOutput?edfa2960-b4a1-4f49-8915-c42cbb6edff0|text editor>. Adjust cell output <command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D|settings>...
o
Thanks, no it's not a known issue. Based on the error message I guess you don't have the proper column names in place. But again, basically shooting in the dark without a piece of code that reproduces the error.
b
Mint OLS, Bottomup and topdown do work however. The Nixtla AI tells me the following Yes, this is a known issue. The OLS method works because it uses a simpler estimation approach, while other MinTrace methods like "wls_var", "mint_cov", and "mint_shrink" require more complex covariance matrix calculations that can fail for certain data structures [(1)](https://github.com/Nixtla/hierarchicalforecast/issues/225) . From the documentation example, here's what works:
Copy code
python
reconcilers = [
    MinTrace(method="ols")
]

hrec = HierarchicalReconciliation(reconcilers=reconcilers)
[(2)](https://nixtlaverse.nixtla.io/nixtla/docs/tutorials/hierarchical_forecasting.html#3-hierarchical-forecasting-with-timegpt) The other methods may fail due to: 1. Zero-inflated time series [(1)](https://github.com/Nixtla/hierarchicalforecast/issues/225) 2. Covariance matrix invertibility issues [(3)](https://github.com/Nixtla/hierarchicalforecast/issues/223) For MinTraceSparse specifically, there are known limitations with certain methods [(4)](https://github.com/Nixtla/hierarchicalforecast/issues/239) . While it's available through GitHub installation, it may still have similar underlying issues with non-OLS methods. Would you like me to explain more about why OLS tends to be more stable, or would you prefer to explore alternative reconciliation approaches? this is what you said last time. i want to explore other mint methods
o
If these other methods dó work, your insample dataframe is likely the culprit. Make sure it has all the right columns and rows.
It's the dataframe that you enter in
.reconcile
with the
Y_df
argument
b
What could be missing? I see no problem
o
Me neither because I can't see the code. It could be a version issue, but most likely you don't have the correct format of that dataframe.