functime-org / functime

Time-series machine learning at scale. Built with Polars for embarrassingly parallel feature extraction and forecasts on panel data.
https://docs.functime.ai
Apache License 2.0
1.02k stars 55 forks source link

Allow `lags=0` in linear_model Class for Standard Regression Functionality #205

Open jhug12 opened 5 months ago

jhug12 commented 5 months ago

Description:

I am proposing an enhancement for the Forecaster class in the functime library, specifically to support setting lags=0 in classes that inherit from Forecaster, such as linear_model. Currently, it is not possible to pass lags=0 as an argument to linear_model or probably other similar models that derive from the Forecaster class.

Issue:

The lack of support for lags=0 restricts users from implementing a standard multiple regression approach within the forecasting framework provided by functime. Here's an example of how one might attempt to set up a linear model forecaster without specifying lags, which implicitly requires non-zero lags:

from functime.forecasting import linear_model

forecaster_linear = linear_model(
    freq="1mo",
    lags=None
)

Desired Enhancement:

By allowing lags=0, users would be able to perform standard multiple regression analyses while benefiting from the features of functime, such as straightforward model changes and extensive cross-validation capabilities. This enhancement would make the library more versatile and applicable to a broader range of forecasting scenarios where traditional regression might be necessary.

Use Case:

This feature would be particularly useful in scenarios where the target is not known for the last n days. One Case would be the the target is the difference from current temperature to future temperature (the change) over n days. If I want to look at the future change over two days then I wouldn't have a value for the last day. Sometimes directly predicting a future value is not possible as the time series is not stationary and therefore differencing is needed.

baggiponte commented 5 months ago

Ciao @jhug12, thanks for the comment. Agree, it might just be a lags: int | None = None. As outlined in the Discord, this implies working a bit more on functime's internals (of which I am not super familiar) so I can't work on it immediately. Any help is of course welcome.