Johannes Emme
06/07/2024, 7:59 AMmax_horizon
larger than 10 (it works for 10 and lower).
from mlforecast import MLForecast
from lightgbm import LGBMRegressor
import pandas as pd
df = pd.concat([
pd.DataFrame({
'id': ['A'] * 1000,
'ds': pd.date_range(start='2020-01-01', periods=1000, freq='H'),
'y': range(1000)
}),
pd.DataFrame({
'id': ['B'] * 1000,
'ds': pd.date_range(start='2020-01-01', periods=1000, freq='H'),
'y': range(1000)
})
])
fcst = MLForecast(
models=LGBMRegressor(),
freq='H',
lags=[1, 2, 3],
)
fcst.fit(df, id_col='id', time_col='ds', target_col='y', max_horizon=11, fitted=True )
in_sample_predictions = fcst.forecast_fitted_values()
print(in_sample_predictions)
File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.9/site-packages/mlforecast/forecast.py:412, in MLForecast._compute_fitted_values(self, base, X, y, id_col, time_col, target_col, max_horizon)
409 for horizon in range(max_horizon):
410 horizon_base = ufp.copy_if_pandas(base, deep=True)
411 horizon_base = ufp.assign_columns(
--> 412 horizon_base, target_col, y[:, horizon]
413 )
414 horizon_fitted_values.append(horizon_base)
415 for name, horizon_models in self.models_.items():
IndexError: index 10 is out of bounds for axis 1 with size 10
José Morales
06/08/2024, 6:18 AMJohannes Emme
06/08/2024, 4:09 PM