Created
August 9, 2021 15:42
-
-
Save hrzn/049ad00595d0f94703f2b7e347f5387d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from darts.metrics import rmse | |
# We first set aside the first 80% as training series: | |
flow_train, _ = flow.split_before(0.8) | |
def eval_model(model, past_covariates=None, future_covariates=None): | |
# Past and future covariates are optional because they won't always be used in our tests | |
# We backtest the model on the last 20% of the flow series, with a horizon of 10 steps: | |
backtest = model.historical_forecasts(series=flow, | |
past_covariates=past_covariates, | |
future_covariates=future_covariates, | |
start=0.8, | |
retrain=False, | |
verbose=True, | |
forecast_horizon=10) | |
flow[-len(backtest)-100:].plot() | |
backtest.plot(label='backtest (n=10)') | |
print('Backtest RMSE = {}'.format(rmse(flow, backtest))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment