Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: restrict input forecast #314

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions nbs/nixtla_client.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -613,16 +613,26 @@
" 'Please consider using a smaller horizon.'\n",
" )\n",
" # restrict input if\n",
" # - we dont want to finetune\n",
" # - we dont have exogenous regegressors\n",
" # - and we dont want to produce pred intervals\n",
" # - no add history\n",
" restrict_input = self.finetune_steps == 0 and X_df is None and self.level is not None and not add_history\n",
" # we dont want to fine-tune\n",
" # we dont have exogenous regressors\n",
" # no add history\n",
" restrict_input = self.finetune_steps == 0 and X_df is None and not add_history\n",
" if restrict_input:\n",
" # add sufficient info to compute\n",
" # conformal interval\n",
" main_logger.info('Restricting input...')\n",
" new_input_size = 3 * self.input_size + max(self.model_horizon, self.h)\n",
" if self.level is not None:\n",
" # add sufficient info to compute\n",
" # conformal interval\n",
" # @AzulGarza\n",
" # this is an old opinionated decision\n",
" # about reducing the data sent to the api\n",
" # to reduce latency when\n",
" # a user passes level. since currently the model\n",
" # uses conformal prediction, we can change a minimum\n",
" # amount of data if the series are too large\n",
" new_input_size = 3 * self.input_size + max(self.model_horizon, self.h)\n",
" else:\n",
" # we only want to forecast\n",
" new_input_size = self.input_size\n",
" Y_df = Y_df.groupby(\"unique_id\").tail(new_input_size)\n",
" if X_df is not None:\n",
" X_df = X_df.groupby(\"unique_id\").tail(\n",
Expand Down
31 changes: 18 additions & 13 deletions nixtla/nixtla_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,21 +555,26 @@ def forecast(
"Please consider using a smaller horizon."
)
# restrict input if
# - we dont want to finetune
# - we dont have exogenous regegressors
# - and we dont want to produce pred intervals
# - no add history
restrict_input = (
self.finetune_steps == 0
and X_df is None
and self.level is not None
and not add_history
)
# we dont want to fine-tune
# we dont have exogenous regressors
# no add history
restrict_input = self.finetune_steps == 0 and X_df is None and not add_history
if restrict_input:
# add sufficient info to compute
# conformal interval
main_logger.info("Restricting input...")
new_input_size = 3 * self.input_size + max(self.model_horizon, self.h)
if self.level is not None:
jmoralez marked this conversation as resolved.
Show resolved Hide resolved
# add sufficient info to compute
# conformal interval
# @AzulGarza
# this is an old opinionated decision
# about reducing the data sent to the api
# to reduce latency when
# a user passes level. since currently the model
# uses conformal prediction, we can change a minimum
# amount of data if the series are too large
new_input_size = 3 * self.input_size + max(self.model_horizon, self.h)
else:
# we only want to forecast
new_input_size = self.input_size
Y_df = Y_df.groupby("unique_id").tail(new_input_size)
if X_df is not None:
X_df = X_df.groupby("unique_id").tail(
Expand Down
Loading