You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying out Nixtla's TopDown reconciliation with the method "forecast_proportions", I encountered the following issue: Apart from the top node in my hierarchy, all other nodes resulted in a reconciled value of 0. Since I was not sure if I had made any mistake with my inputs, I also tried out the same reconciliation approach with a test set from "Forecasting: Principles and Practice, the Pythonic Way" (aus_tourism.csv => https://otexts.com/fpppy/data/aus_tourism.csv ) and just replaced the BottomUp / MintShrink reconciliation approaches by TopDown(method="forecast_proportions"). However, once again, most of the reconciliation results are equal to 0. Is this a bug or do you have any hints on how I can implement a TopDown reconciliation that will break down the values of different top nodes to lower nodes in a proportionate way? (For context, in my actual use case, I will not have a Y_fitted_df, so the proportions should be purely based on the forecast proportions, not on historical proportions). Thanks a lot in advance :)
Here is the sample code for the aus_tourism dataframe:
from hierarchicalforecast.core import HierarchicalReconciliation
from hierarchicalforecast.methods import BottomUp, TopDown, MiddleOut, MinTrace
from hierarchicalforecast.utils import aggregate, HierarchicalPlot
from statsforecast import StatsForecast
from statsforecast.models import AutoETS, Naive
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Dear community,
While trying out Nixtla's TopDown reconciliation with the method "forecast_proportions", I encountered the following issue: Apart from the top node in my hierarchy, all other nodes resulted in a reconciled value of 0. Since I was not sure if I had made any mistake with my inputs, I also tried out the same reconciliation approach with a test set from "Forecasting: Principles and Practice, the Pythonic Way" (aus_tourism.csv => https://otexts.com/fpppy/data/aus_tourism.csv ) and just replaced the BottomUp / MintShrink reconciliation approaches by TopDown(method="forecast_proportions"). However, once again, most of the reconciliation results are equal to 0. Is this a bug or do you have any hints on how I can implement a TopDown reconciliation that will break down the values of different top nodes to lower nodes in a proportionate way? (For context, in my actual use case, I will not have a Y_fitted_df, so the proportions should be purely based on the forecast proportions, not on historical proportions). Thanks a lot in advance :)
Here is the sample code for the aus_tourism dataframe:
First some processing steps that I added:
Split unique_id into Country, State, and Purpose
aus_tourism[['Country', 'State', 'Purpose']] = aus_tourism['unique_id'].str.split('-', expand=True)
Convert ds to datetime
aus_tourism['ds'] = pd.to_datetime(aus_tourism['ds'])
Then the official code from the website:
from hierarchicalforecast.core import HierarchicalReconciliation
from hierarchicalforecast.methods import BottomUp, TopDown, MiddleOut, MinTrace
from hierarchicalforecast.utils import aggregate, HierarchicalPlot
from statsforecast import StatsForecast
from statsforecast.models import AutoETS, Naive
2. Define the spec and aggregate the data
spec = [
["Country"],
["Country", "State"],
["Country", "Purpose"],
["Country", "State", "Purpose"],
]
Y_df, S_df, tags = aggregate(aus_tourism.drop(columns=["unique_id"]), spec)
Y_train_df = Y_df.query("ds.dt.year <= 2015")
Y_test_df = Y_df.query("ds.dt.year > 2015")
3. Specify a set of models and forecast
sf = StatsForecast(models=[AutoETS(season_length=4)], freq="Q", n_jobs=-1)
Y_hat_df = sf.forecast(h=8, df=Y_train_df, fitted=True)
Y_fitted_df = sf.forecast_fitted_values()
4. Specify the reconcilers
reconcilers = [TopDown(method="forecast_proportions")]
5. Reconcile the forecasts
hrec = HierarchicalReconciliation(reconcilers=reconcilers)
Y_rec_df = hrec.reconcile(Y_hat_df=Y_hat_df, Y_df=Y_fitted_df, S=S_df, tags=tags)
Beta Was this translation helpful? Give feedback.
All reactions