Comments (7)
Hi @valentin-fngr,
Thanks for using skforecast.
You are right, the graph represents the transformation applied internally by the forecaster.
The current implementation does not allow to use a different exogenous variable for each time series, they are considered as global for all of them.
We will try to improve the documentation in the next release for better clarity.
from skforecast.
So, I cam with a work around which is not exactly what I want but it somehow yields interesting results so I might as well share it.
I create pivot tables for both the targets and the features. This is in the case of a multi-series approach :
# features
_df_features = _df.pivot_table(index='timestamp', columns='hub', values=[col for col in _df.columns[:140] )
_df_features.columns = [f'{col[0]}_{col[1]}' for col in _df_features.columns]
_df_features = _df.sort_index()
_df_features = _df.asfreq('H')
# targets
_df_series = pd.pivot_table(
data=_df,
values="y",
index="timestamp",
columns=["hub"]
)
_df_series.columns.name = None
_df_series.columns = [f"hub_{col}" for col in _df_series.columns]
_df_series = _df_series.sort_index()
_df_series = _df_series.asfreq('H')
train_end = "2022-03-31 11:00:00"
results = grid_search_forecaster_multiseries(
forecaster = forecaster,
series = _df,
exog = _df_features,
levels = None,
lags_grid = lags_grid,
param_grid = param_grid,
steps = 24,
gap = 12,
metric = [mean_absolute_error, mean_squared_error],
initial_train_size = len(_df.loc[:train_end]),
refit = True,
fixed_train_size = True,
return_best = False,
n_jobs = 'auto',
verbose = False,
show_progress = True
)
return results
So basically this allows me to stack, for each timestamp, all features for each time series.
This is the best I can do, which is not too bad. But, you can imagine that if I have 800 features for 10 time series, it gives me 8000 exogenous features, which, surprisingly helps my Ridge model ahah.
from skforecast.
After reading the source code, I figured that the drawing is representing what is happening under the hood.
Nonetheless, I believe this is confusing and does not help on how to prepare the data in the case of multi_series + exogenous features.
I still do not know how to prepare my data in that case.
from skforecast.
Hello @valentin-fngr
Thanks for opening the issue. If I understand you correctly, your problem is that you want to add a different exogenous variable per series. Could you give us some information about your use case? We have this feature in the backlog, but the only use case that comes to my mind that needs this is for example modeling a time series by countries and you need a different vacation indicator for each of them.
As for the documentation, yes, you are right, this is what happens under the hood. Please see the updated user guide at the following link, where I have added a new section on exogenous variables:
https://skforecast.org/latest/user_guides/independent-multi-time-series-forecasting
It is important to know that the dataframe that ForecasterAutoregMultiSeries
expects looks like this:
One column for each target variable (item_1, item_2 and item_3) and additionals with the exogenous variables.
Please, let us know your thoughts on this 😄
from skforecast.
Thanks for your reply.
Here is my use case :
I have 10 different stocks (my time series). All of them have the same 100 features X1 to X100 but with different values.
for example :
Here, HUB is the time serie id. imagine you have different values for hub.
I thought about implementing the feature and submitting a pull request, I started, but time was ticking and I could not propose a clean pull request with all associated tests.
Regarding your modification, I think it is much better and clears any confusion. I would really suggest to build that feature as a lot of people might benefit from it.
Valentin
from skforecast.
Do you have any workaround regarding my specific problem ?
I would like to keep using your library for its simplicity.
from skforecast.
Hi @valentin-fngr,
Unfortunately, we do not currently have a solution for incorporating different exogenous variables for each series in the multi-series forecasting models. However, this feature is currently on our radar and is part of our backlog for upcoming feature releases.
We are always open to new ideas. If you have any suggestions, we would be happy to discuss them with you.
from skforecast.
Related Issues (20)
- `ForecasterAutoreg` fails to fit when `exog` do not have string column names HOT 1
- `ForecasterAutoreg` fails to fit when index do not start from 0 HOT 3
- How to use it with planning input or other forecast as a guide? HOT 5
- grid_search_sarimax stuck without any progress HOT 1
- Back testing HOT 1
- Backrest and hyper parameter tuning HOT 1
- Just a question about probabilistic forecasting HOT 3
- Naming convention for backtesting methods HOT 2
- Feature request regarding time series with different lengths HOT 5
- bayesian_search_forecaster (Optuna) & Saving/Resuming Study with RDB Backend HOT 1
- Feature request: Recursive multistep multivariate forecasting and direct multistep multi-series forecasting HOT 4
- A single model multivariate forecaster HOT 3
- Issue saving ForecasterSarimax object HOT 4
- Custom predictors are inefficient for window features HOT 1
- grid_search_sarimax takes a very long time to run HOT 1
- Feature request: Add ability to skip steps in backtesting HOT 6
- Bad error handling when Index is neither RangeIndex nor DateIndex HOT 3
- Why do i have faster runtime when using more frequent refits HOT 2
- syntax error !! HOT 1
- Feature request: Custom predictors for multivariate forecasting
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skforecast.