Replies: 2 comments 1 reply
-
Please respond as I need to solve this problem as soon as possible. I tried using Linear Regression from sklearn and that works ok. I also tried using GradientBooster but that does not work |
Beta Was this translation helpful? Give feedback.
1 reply
-
I think you posted this twice, @nyk2001? You have received some answers here: Summary:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have used ARIMA and Prophet algorithms for multivariate forecasting, which works fine. You can see the plot with Prophet as follows:
Now, I am trying to use LightGBM to make predictions and it does not work. For instance, I am getting the following output:
Please help me to resolve the issue. My code is as follows:
`
Load data
df = sm.datasets.macrodata.load_pandas()['data']
df['q_date'] = df.apply(lambda x: str(int(x['year'])) + '-Q' + str(int(x['quarter'])), axis=1)
df['date'] = pd.PeriodIndex(df['q_date'], freq='Q').to_timestamp()
df.loc[:, 'realinv_lagged'] = df.loc[:, 'realinv'].shift()
df[['realinv_lagged']] = df[['realinv_lagged']].fillna(method='backfill')
Split into x and y
y = df['realgdp']
X = df[['realinv_lagged','cpi','m1']] #could be more features
Split dataset
y_train, y_test, X_train, X_test = temporal_train_test_split(y, X, test_size=30)
Create LGBM regressor
regressor = lgb.LGBMRegressor()
forecaster = make_reduction(regressor, window_length=10, strategy="recursive", scitype="tabular-regressor")
Define horizon
fh_abs = ForecastingHorizon(y_test.index, is_relative=False)
Fit model
forecaster.fit(y_train, X_train)
Make predictions
y_pred = forecaster.predict(X=X_test, fh=fh_abs)
Plot preditcions
plot_series(y_train, y_test, y_pred, labels=["y_train", "y_test", "y_pred"])
`
Beta Was this translation helpful? Give feedback.
All reactions