in sa-dsml-many-models/code/util/timeseries_utilities.py [0:0]
def forecast(self, X):
"""
Make forecasts over the prediction frame, X.
X can contain in-sample and out-of-sample data.
For out-of-sample data, the 1-step-ahead model is recursively applied.
Returns forecasts for the target in a pd.Series object with the same time index as X.
np.nan values will be returned for dates where a forecast could not be found.
"""
assert list(X.index.names) == [self.time_column_name], \
"Expected time column to comprise input dataframe index."
# Get in-sample forecasts if requested
X_insamp = X[X.index <= self._latest_training_date]
forecasts_insamp = pd.Series()
if len(X_insamp) > 0:
forecasts_insamp = self.pipeline.predict(X_insamp)
# Get out-of-sample forecasts
X_fcst = X[X.index > self._latest_training_date]
forecasts = pd.Series()
if len(X_fcst) > 0:
# Need to iterate/recurse 1-step forecasts here
forecasts = self._recursive_forecast(X_fcst)
forecasts = pd.concat((forecasts_insamp, forecasts))
return forecasts.reindex(X.index)