MLForecast+Prediction Intervals+Transfer Learning
What happened + What you expected to happen
I am trying to predict target components over prediction intervals using Transfer Learning approach. But I am getting below error:
ValueError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/mlforecast/forecast.py in predict(self, h, before_predict_callback, after_predict_callback, new_df, level, X_df, ids) 706 if new_df is not None: 707 if level is not None: --> 708 raise ValueError( 709 "Prediction intervals are not supported in transfer learning." 710 )
ValueError: Prediction intervals are not supported in transfer learning.
Versions / Dependencies
import mlforecast print(mlforecast.version)
0.15.0
Reproduction script
Y_df_M3, _, _ = M3.load(directory='./', group='Monthly') models = [lgb.LGBMRegressor(verbosity=-1)]
fcst = MLForecast( models=models, lags=range(1, 13), freq='MS', target_transforms=[Differences([1, 12])], ) fcst.fit(Y_df_M3); Y_df = pd.read_csv('https://datasets-nixtla.s3.amazonaws.com/air-passengers.csv', parse_dates=['ds'])
We define the train df.
Y_train_df = Y_df[Y_df.ds<='1959-12-31'] # 132 train Y_test_df = Y_df[Y_df.ds>'1959-12-31'] # 12 test
levels = [50, 80, 95] Y_hat_df = fcst.predict(h=12, level = levels, new_df=Y_train_df) Y_hat_df.head()
ValueError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/mlforecast/forecast.py in predict(self, h, before_predict_callback, after_predict_callback, new_df, level, X_df, ids) 706 if new_df is not None: 707 if level is not None: --> 708 raise ValueError( 709 "Prediction intervals are not supported in transfer learning." 710 )
ValueError: Prediction intervals are not supported in transfer learning.
Issue Severity
High: It blocks me from completing my task.
Hi, I am encountering this issue too. Did you find a workarount ? Moreover, I really could'nt wrap my head around why is the model is refitted when doing a predict with new_df. Help needed pls!