Skip to content

Instantly share code, notes, and snippets.

@mikekeith52
Last active June 16, 2022 13:43
Show Gist options
  • Select an option

  • Save mikekeith52/b60e5fe7404e273d81490e29aa06dc44 to your computer and use it in GitHub Desktop.

Select an option

Save mikekeith52/b60e5fe7404e273d81490e29aa06dc44 to your computer and use it in GitHub Desktop.
def prepare_fcst(f, test_length=0.1, fcst_length=120):
""" adds all variables and sets the test length/forecast length in the object
Args:
f (Forecaster): the Forecaster object.
test_length (int or float): the test length as a size or proportion.
fcst_length (int): the forecast horizon.
Returns:
(Forecaster) the processed object.
"""
f.generate_future_dates(fcst_length)
f.set_test_length(test_length)
f.set_validation_length(f.test_length)
f.add_seasonal_regressors("month", raw=False, dummy=True)
for i in np.arange(60, 289, 12): # 12-month cycles from 12 to 288 months
f.add_cycle(i)
f.add_ar_terms(120) # AR 1-120
f.add_AR_terms((20, 12)) # seasonal AR up to 20 years, spaced one year apart
f.add_seasonal_regressors("year")
return f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment