JoaquinAmatRodrigo / skforecast

Time series forecasting with machine learning models
https://skforecast.org
BSD 3-Clause "New" or "Revised" License
1.08k stars 123 forks source link

Custom predictors with additional variables that unrelated to time series #124

Closed oy321 closed 1 year ago

oy321 commented 2 years ago

Thanks for the great library! I am trying to apply it to a use case where I need to train a predictor to make a recursive multi-step predictions into the future, where I'd wish to use multiple predicting variables that not related to the target time series itself, but it seems impossible.

First I am aware of the exogenous variables but it requires the future values of exogenous variables are known. In my case, as I need the final forecaster to be able to make multi-steps prediction into future, so this function is not relevant.

For the 'ForecasterAutoregCustom' function where it supports argument of 'fun_predictors', I looked at the source code line 246: X_train.append(self.create_predictors(y=y_values[train_index]))

It only takes the "y" values as the input but not the other variables that not related to "y". Well, it's very common to have a multi-variate and multi-step forecasting scenario when the future exogenous variables are unknown, I am not quite sure how to do it with this library.

Thank you

JoaquinAmatRodrigo commented 2 years ago

Hi @oy321 If I do understood your explanation, you are trying to train a forecaster using multiple time series at once. This feature is not yet available, but will be in the 0.5 release, that I hope will be release soon.

oy321 commented 2 years ago

Dear author,

Yes that's correct. I'll implement it manually as for now. Hopefully can use this package later.

JoaquinAmatRodrigo commented 2 years ago

This is something already demanded by several users so it will be one of the priorities for next release. @JavierEscobarOrtiz let's keep in mind.

oy321 commented 2 years ago

That's great. Please let me know if I can be of any help. Excuse me from going further on this topic, would this new feature support multi-step recursive predictions with multiple time series inputs, or only the direct predictions using multiple models?

JoaquinAmatRodrigo commented 2 years ago

The idea I have so fare is to generalizer the input y in a way that it allows using dataframes. Each column of the dataframe will be considered as independent time series from which the forecaster will learn. This approach should be compatible with both, multi-step recursive and multi-step direct. I will share an initial draft as soon as possible :-)

oy321 commented 2 years ago

Thanks for sharing your thoughts. I could imagine the way you described as "Each column of the dataframe will be considered as independent time series from which the forecaster will learn". However I have a doubt about how it could work with multi-step recursive forecasting. When there is only one predictor which is the target 'y', the recursive strategy works. But when there are multiple (independent or interdependent) time series inputs besides the target time series, you could make one step prediction on 'y', but then for the following steps it would require not only the target variable but also the other input time series to move forward together, but the future values of those X's would not be available. Therefore I thought only the multi-step direct approach is possible?

JoaquinAmatRodrigo commented 2 years ago

You are right @oy321 I will do some research about how multiple time series may be used in a multi-step recursive strategy but, as you explained, it may be only possible for multi-step direct approach. Thanks a lot for sharing your thoughts, any new idea is very welcome!

oy321 commented 2 years ago

My pleasure! Would get in touch if there is any. And please let me know if I am proved wrong re. above.

JoaquinAmatRodrigo commented 1 year ago

New feature for multi-series forecasting has been added in version 0.5.0

https://joaquinamatrodrigo.github.io/skforecast/0.5.0/user_guides/multi-time-series-forecasting.html

pmateosmasa1 commented 1 year ago

Hi, first of all congrats for your incredible library, awesome work! I have been exploring the latest features in 0.5.0 and specially the Multi Time Series forecasting. One question arised was about the idea of Multivariate Multi time series ones. Due to the recursive way isn't possible because the interdependencies between targets and lagged features, the only way to deal with this problem would be the direct approach, right? I guess using the MultiOutput function.

JoaquinAmatRodrigo commented 1 year ago

Hi @pmateosmasa1, You are right, for multivariate time series forecasting, the aproach we are working on is by using the Direct strtategy. However, there are also other models that are able to handle multivariate scenarios, one of them is Vector Autoregression (VAR).

https://www.machinelearningplus.com/time-series/vector-autoregression-examples-python/

JavierEscobarOrtiz commented 1 year ago

Hi @pmateosmasa1

Multivariate approach has been released in skforecast 0.6.0 😄 Check the user guide:

https://joaquinamatrodrigo.github.io/skforecast/latest/user_guides/multivariate-forecasting.html

JoaquinAmatRodrigo commented 1 year ago

It has been more than 60 days since the last activity on this GitHub issue. Since we have not received any updates or progress reports, we will be closing this issue.

If this issue is still relevant and requires attention, please feel free to reopen it and provide an update. We appreciate your contributions and would love to see this issue resolved if it is still relevant.

Thank you for your participation and cooperation!