Time Series Forecasting with Python and XGBoost: Forecasting with supervised machine learning methods by Dario Radečić

Time Series Forecasting with Python and XGBoost: Forecasting with supervised machine learning methods by Dario Radečić

Author:Dario Radečić [Radečić, Dario]
Language: eng
Format: azw3, epub
Published: 2020-10-03T00:00:00+00:00


if hyperparameters is None:

model = XGBRegressor()

else:

model = XGBRegressor(**hyperparameters)

model.fit(X, y)

self.model = model

We are nearly done - the only thing left to implement is the predic t method, which makes a forecast for n periods into the future.

Making a single prediction

This is the last point most online books and courses cover regarding time series modeling as a supervised problem. Somehow making a prediction only one step into the future seems reasonable enough that no one bothers going beyond. Making a single prediction is a necessary first step, don't get me wrong, but we won't stop there.

To make a single prediction, we'll need to know two things - what's our historical data and for which date we're making predictions. Keep in mind - we will never use this function directly, as getting only a single prediction won't be enough in 99% of the cases. Once we got these two pieces of information, we can call the _get_attribute s method to get the values for the provided date, and the _get_column_lis t method to get attribute names.

Next, we can make n lag variables, where n is the number of lags passed in the constructor, and use the _agg_equals_expressio n method to get the values. Finally, we can put both attributes and lags into a single list and turn it into a Pandas DataFrame object. Then, we'll make a call to the predic t method of our model,

Oh, before I forget, here's the code snippet for this method:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.