Yacoub Alatrash
11/10/2023, 7:36 PMToni Borders
11/14/2023, 4:54 PMTraceback (most recent call last):
File “/Users/tmb/PycharmProjects/data-science/UFE/code/hierarchFrcstEx.py”, line 14, in <module>
from hierarchicalforecast.methods import BottomUp, TopDown, MiddleOut
File “/Users/tmb/Library/Caches/pypoetry/virtualenvs/data-science-zw503lJq-py3.10/lib/python3.10/site-packages/hierarchicalforecast/methods.py”, line 14, in <module>
_from quadprog import solve_qp_
_ImportError: dlopen(/Users/tmb/Library/Caches/pypoetry/virtualenvs/data-science-zw503lJq-py3.10/lib/python3.10/site-packages/quadprog.cpython-310-darwin.so, 0x0002): tried: ‘/Users/tmb/Library/Caches/pypoetry/virtualenvs/data-science-zw503lJq-py3.10/lib/python3.10/site-packages/quadprog.cpython-310-darwin.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’)), ‘/System/Volumes/Preboot/Cryptexes/OS/Users/tmb/Library/Caches/pypoetry/virtualenvs/data-science-zw503lJq-py3.10/lib/python3.10/site-packages/quadprog.cpython-310-darwin.so’ (no such file), ‘/Users/tmb/Library/Caches/pypoetry/virtualenvs/data-science-zw503lJq-py3.10/lib/python3.10/site-packages/quadprog.cpython-310-darwin.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’))_
Toni Borders
11/21/2023, 12:07 PMTraceback (most recent call last):
File “/Users/tmb/PycharmProjects/data-science/UFE/code/hierFcst.py”, line 106, in <module>
_main(data, freq, metadata_str, account)_
File “/Users/tmb/PycharmProjects/data-science/UFE/code/hierFcst.py”, line 88, in main
_Y_df = aggregate(Y_df, spec)_
File “/Users/tmb/PycharmProjects/data-science/UFE/code/hierFcst.py”, line 81, in aggregate
_Y_df, S_df, tags = aggregate(Y_df, spec)_
File “/Users/tmb/PycharmProjects/data-science/UFE/code/hierFcst.py”, line 81, in aggregate
_Y_df, S_df, tags = aggregate(Y_df, spec)_
File “/Users/tmb/PycharmProjects/data-science/UFE/code/hierFcst.py”, line 81, in aggregate
_Y_df, S_df, tags = aggregate(Y_df, spec)_
[Previous line repeated 995 more times]
RecursionError: maximum recursion depth exceededHere is my code:
def get_spec():
spec = [
['org'],
['org', 'account'],
['org','meter'],
['org','account','meter']
]
return spec
def aggregate(Y_df, spec):
Y_df, S_df, tags = aggregate(Y_df, spec)
Y_df = Y_df.reset_index()
def main(data):
Y_df = clean_data(data)
spec = get_spec()
Y_df = aggregate(Y_df, spec)
print(Y_df.head(20))
Any thoughts on what could be going wrong?Graeme Davidson
11/22/2023, 4:28 PMA
11/25/2023, 4:24 PMYacoub Alatrash
12/01/2023, 7:20 PMIsmail EL MASSI
12/13/2023, 10:52 PMIsmail EL MASSI
12/20/2023, 4:02 PMSlackbot
12/26/2023, 11:04 PMIsmail EL MASSI
12/27/2023, 9:53 PMToni Borders
01/15/2024, 10:10 PMGraeme Davidson
01/26/2024, 12:26 PMJD Money
02/05/2024, 7:03 AMToni Borders
02/07/2024, 4:29 PMY_hat_df = fcst.forecast(h=h, level=[95], fitted=True)
Y_fitted_df = fcst.forecast_fitted_values()
when doing a reconciliation as opposed to the original time series, Y_df?
Y_rec_df = hrec.reconcile(Y_hat_df=Y_hat_df,
Y_df=Y_fitted_df, #Y_fitted_df or Y_train_df ?
S=S_df,
tags=tags)
The examples in the documentation show examples of both.
Thanks in advance.Bryce Davies
02/09/2024, 2:52 AMIrina
02/13/2024, 4:55 PMNaren Castellon
02/16/2024, 8:58 PMNaren Castellon
02/22/2024, 9:01 PMNaren Castellon
02/27/2024, 12:15 AMreconcilers = [BottomUp(),
TopDown(method='forecast_proportions'),
#MiddleOut(middle_level='STORE ID/CITY/CATEGORY', top_down_method='forecast_proportions'),
#MinTrace(method='ols'),
#OptimalCombination(method='ols')
]
hrec = HierarchicalReconciliation(reconcilers=reconcilers)
# Redes Neurales
Y_rec_nf = hrec.reconcile(Y_hat_df=Y_hat_nf, Y_df=Y_df, S=S_df, tags=tags, )
Doesn't make the reconcilersAnthony Gonzalez
02/29/2024, 8:42 PMGalvan Goh
03/22/2024, 3:19 AMJakov Glavac
04/11/2024, 8:57 AMmf = MLForecast(models=[xgb.XGBRegressor()],
freq='MS',
lags=[1,2,12,24],
date_features=['month'],
)
mf.fit(Y_train_df, fitted=True, prediction_intervals=PredictionIntervals(n_windows=10, h=horizon))
Y_hat_mf = mf.predict(horizon, level=level).set_index('unique_id')
insample_mf = mf.forecast_fitted_values()
Hi, I'm woundering if xgboost here predicts for each unique id with different if not, how to make it do so? Beacuse I want to avoid stuff like this where model predictions are ok for on level but on other thay are way off. I would appreciate point in right direction.victor michon
04/23/2024, 5:59 PMH
05/14/2024, 5:25 AMaggregate
function it seems the matrix it’s trying to make becomes too large because of the 130k products. I get MemoryError: unable to allocate 62.2 GiB for an array with shape (130000, 130000) and data type float32
. I was wondering if there is a way to do hierarchical forecasting without creating this intermediate matrix S_df
? My understanding is that S_df
is tracking the relationships of the hierarchy, but I’m thinking maybe there’s a more condensed way to represent the relationships, especially given that I just have a two level hierarchy with level 1 being of size 1.
if it’s not possible, any other solutions you may have are very much appreciated. Thank you!Truong Hoang
05/29/2024, 6:17 AMhierarchicalforecast
and encounter this strange KeyError
as shown below. I'm only encountering this error when using the MinTrace
reconciler. For TopDown
, BottomUp
and MiddleOut
reconcilers, there were no errors.
My Y_hat_df
has 3 columns with unique_id
set as index:
ds Naive
unique_id
A 2023-01-01 12113.0
A 2023-02-01 12113.0
A 2023-03-01 12113.0
A 2023-04-01 12113.0
A 2023-05-01 12113.0
Everything seems fairly standard, so I'm not sure what is the issue here. After checking the source code, I found this part below. From my understanding, Y_df
is supposed to be the training data (based on this example), so I dont understand why you would try to select the column with the model name there, when it's supposed to be in Y_hat_df
instead?
if (self.insample and has_fitted) or intervals_method in ['bootstrap', 'permbu']:
if is_balanced:
y_hat_insample = Y_df[model_name].values.reshape(len(S_df), -1).astype(np.float32)
else:
y_hat_insample = Y_df.pivot(columns='ds', values=model_name).loc[S_df.index].values.astype(np.float32)
Dinis Timoteo
06/06/2024, 9:16 AMToni Borders
06/07/2024, 11:58 AMreconcilers = [
BottomUp(),
MinTrace(method='ols', nonnegative=True),
MinTrace(method='wls_var', nonnegative=True),
MinTrace(method='mint_shrink', nonnegative=True)
]
hrec = HierarchicalReconciliation(reconcilers=reconcilers)
Y_rec_df = hrec.reconcile(Y_hat_df=Y_hat_df,
Y_df=Y_df, #Y_fitted_df or Y_train_df
S=S_df,
tags=tags,
level=[95],
intervals_method='permbu')
cc: @Kin Gtz. OlivaresToni Borders
06/08/2024, 6:38 AMSarim Zafar
07/22/2024, 4:45 PMSarim Zafar
07/22/2024, 4:49 PM