No zero Forecast #388
Replies: 2 comments
-
Hello Jorge, could you please translate it into english? 😃 Thank you! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hello Javier,
i will try.
but for now:
a have a dataset of sales, since 2019 until today.
For now we can think this sales are just for one store, one store where is close at Sunday (but we had some lines with sales on Sundays in the past!!!)
i want to predict nex month (or 45 days), with closed Sundays.
So, to do that, i transformed my dataset:
* create feature like week, weekday, year and open
* This features were transformed on binary (0 and 1)
So, i want to predict SALES for next month for this store but, as you can see on figures, the model shows values for sales at sundays, even when i put OPEN=0 (i am using exog_variables).
So, why?
I have some lines in the past with SALES because the store was open at Sundays, but it was just 3 months on the beginning of 2019. Since that, the store was always closed, with my variable OPEN=0.
How can i predict SALES=0 on Sundays with closed store?
Could you understand now?
Cumprimentos,
Jorge Gomes
[cid:db173547-812f-4725-995d-90d413bcd20a]
…________________________________
De: Javier Escobar Ortiz ***@***.***>
Enviado: 5 de abril de 2023 12:11
Para: JoaquinAmatRodrigo/skforecast ***@***.***>
Cc: Jorge Gomes ***@***.***>; Author ***@***.***>
Assunto: Re: [JoaquinAmatRodrigo/skforecast] No zero Forecast (Discussion #388)
Hello Jorge, could you please translate it into english? 😃 Thank you!
—
Reply to this email directly, view it on GitHub<#388 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANXWWIEBB4LMZZW7FU4OR4TW7VHOBANCNFSM6AAAAAAWT42MRE>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm building a time series model, for forecasting Sales, based on the history since 2019.
My model uses SKForecast with XGBRegressor.
I want to forecast 75 days.
My target is SALES.
I use external features to help model, transformed in 0 and 1.
I would like to understand why my final forecast have non-zero values on target variable SALES on Sundays, even when i use a external feature OPEN=0.
My dataset have this struture:
DATA| SALES| YEAR | WEEK | WEEKDAY | OPEN
ex:
The variable "WEEKDAY"= 7 means Sunday.
On dataset i have some Sundays with SALES<>0, with OPEN=1 (first 3 months for 2019). But mostly SALES=0 on Sundays, with OPEN=0.
The external feature "OPEN"=0 means that store is closed, OPEN=1 means store open.
This is my final dataset (vendas_df2) before execute model :
The exog_variables uses all the external features, except target variable (SALES)
This is the train, validation and test :
This is the parameters for model:
Create forecaster
======================================
forecaster = ForecasterAutoreg(
regressor = XGBRegressor(random_state=123),
lags = 7 #24
)
Grid search of hyperparameters and lags
========================================
Regressor hyperparameters
param_grid = {
'n_estimators': [100, 500],
'max_depth': [3, 5, 10],
'learning_rate': [0.01, 0.1]
}
Lags used as predictors
lags_grid = [7, 30, 48, 72, [1, 2, 3, 7, 23, 24, 25, 71, 72, 73]]
results_grid = grid_search_forecaster(
forecaster = forecaster,
y = vendas_df2.loc[:end_validation, 'SALES'],
exog = vendas_df2.loc[:end_validation, exog_variables],
param_grid = param_grid,
lags_grid = lags_grid,
steps = 75,
refit = False,
metric = 'mean_squared_error',
initial_train_size = int(len(data_train)),
fixed_train_size = False,
return_best = True,
verbose = False
)
Backtesting test data
=========================================
metric, predictions = backtesting_forecaster(
forecaster = forecaster,
y = vendas_df2['SALES'],
exog = vendas_df2[exog_variables],
initial_train_size = len(vendas_df2.loc[:end_validation]),
fixed_train_size = False,
steps = 75,
refit = False,
metric = 'mean_squared_error',
verbose = False
)
print(f"Backtest error: {metric}")
This is the final result with forecast for May:
We can see that Sundays have SALES <>0.
My dataset has OPEN=0 for Sundays, so why i can't forecast zero values for Sundays (prev=0) ?
Can you help please?
Thank you!
Jorge Gomes
Beta Was this translation helpful? Give feedback.
All reactions