Skip to content

Manual training of models for multi-step direct forecasting #304

Answered by jmoralez
laxhammar asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @laxhammar, thanks for using mlforecast. It's possible to use MLForecast.fit_models, that method checks if the target is a matrix and if it is it trains one model for each column. Here's a minimal example:

from mlforecast import MLForecast
from mlforecast.utils import generate_series
from sklearn.linear_model import LinearRegression

series = generate_series(5)
fcst = MLForecast(
    models=[LinearRegression()],
    freq='D',
    lags=[1],
)
X, y = fcst.preprocess(series, max_horizon=4, return_X_y=True)
fcst.fit_models(X, y)
assert len(fcst.models_['LinearRegression']) == 4

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@laxhammar
Comment options

Answer selected by laxhammar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants