Closed jmberutich closed 1 week ago
I have the same issue but in my case, it returns NaN for both TopDown_method-average_proportions and TopDown_method-proportion_averages. it returns values for bottom-up and MinTrace_method. I have tried with previous release versions starting from 0.2.0 and got the same results for my data. please advise!
Hey. The TopDown method requires the in-sample predictions of the models to be provided in Y_df
, so if you add the following to your example it should work:
Y_hat_df = fcst.forecast(h=4, fitted=True) # added fitted=True here
insample_df = fcst.forecast_fitted_values() # get in-sample predictions
Y_rec_df = hrec.reconcile(Y_hat_df=Y_hat_df, Y_df=insample_df, S=S, tags=tags) # provide insample_df through Y_df
Thanks for the quick response. I followed your suggestion and adding the model insample predictions worked.
I have some questions regarding the TopDown (average_proportions and proportion_averages) methods are how the are calculated.
For forecast_proportions would it not make sense to use the out of sample predictions?
@jmoralez thanks for the response, in my case, my code was correct I provided the in-sample predictions in Y_df but still the TopDown results are "NaN". it works for the BottomUp and other methods that I tested like "OptimalCombination" and "MinTrace". So it is strange that is returning NaN for the TopDown method.
any recommendation, please ? below is a snippet of my code:
hey @jmberutich, regarding your questions on the methods:
average_proportions
and proportion_averages
approaches use the actual data (the target values used for training). The insample_df
is required because it contains the historical target values (just adding an insample_df
with columns unique_id
, ds
, and y
should work for TopDown
). insample_df
with the historical target variable. forecast_proportions
methods use the out-of-sample predictions.So, the solution would be
Y_hat_df = fcst.forecast(h=group.horizon, fitted=True)
insample_df = fcst.forecast_fitted_values()
Y_rec_df = hrec.reconcile(Y_hat_df=Y_hat_df, Y_df=insample_df, S=S_df, tags=tags)
option B
insample_df = Y_train_df.copy()
insample_df["AutoARIMA"] = insample_df["y"]
insample_df["Naive"] = insample_df["y"]
Y_rec_df = hrec.reconcile(Y_hat_df=Y_hat_df, Y_df=insample_df, S=S_df, tags=tags)
What happened + What you expected to happen
The TopDown methods:
Are broken after version 0.2.1.
Error output:
Versions / Dependencies
v.0.3.0 v0.4.0 v0.4.1
Reproduction script
Issue Severity
None