-
-
Notifications
You must be signed in to change notification settings - Fork 45
Resolving issue #260 ( added exogenous variables to Chronos-2 ) #264
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds exogenous variable support to Chronos-2 models by introducing a new _forecast_chronos2_df method and improving cross-validation error handling.
- Adds exogenous variable handling to Chronos-2 models via the new
_forecast_chronos2_dfmethod - Updates cross-validation to check model support for exogenous variables before raising errors
- Sets
supports_exogenousflag based on model type detection
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| timecopilot/models/foundation/chronos.py | Implements Chronos-2 specific forecasting with exogenous variables and sets the supports_exogenous flag |
| timecopilot/models/utils/forecaster.py | Improves cross-validation exogenous variable handling with model-specific error messages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
|
||
| required = {id_col, ts_col, target_col} | ||
| if not required.issubset(df.columns): | ||
| raise ValueError("missing required columns") |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message should specify which columns are missing for better debugging. Consider: raise ValueError(f'Missing required columns: {required - set(df.columns)}')
| raise ValueError("missing required columns") | |
| missing = required - set(df.columns) | |
| raise ValueError(f"Missing required columns: {missing}") |
| pred_df = pred_df.rename(columns={id_col: "unique_id", ts_col: "ds"}) | ||
|
|
||
| if "predictions" not in pred_df.columns: | ||
| raise ValueError("predictions column missing") |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message should mention the source and available columns for debugging. Consider: raise ValueError(f'predictions column missing from model output. Available columns: {list(pred_df.columns)}')
| raise ValueError("predictions column missing") | |
| raise ValueError(f"predictions column missing from model output. Available columns: {list(pred_df.columns)}") |
| exog_cols = [] | ||
| for col in df.columns: | ||
| if col not in base_cols: | ||
| exog_cols.append(col) |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This loop can be simplified using a list comprehension: exog_cols = [col for col in df.columns if col not in base_cols]
| exog_cols = [] | |
| for col in df.columns: | |
| if col not in base_cols: | |
| exog_cols.append(col) | |
| exog_cols = [col for col in df.columns if col not in base_cols] |
| supports_exogenous = getattr(self, "supports_exogenous", False) | ||
| for _, (cutoffs, train, valid) in tqdm(enumerate(splits)): | ||
| if len(valid.columns) > 3: | ||
|
|
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace on line 256. Remove the spaces to follow PEP 8 style guidelines.
make sense. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
saving carbon Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
saving carbon 2 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR adds exogenous-feature handling to the Chronos-2 forecast.
The function
_forecast_chronos2_dfnow identifies non target columns as exogenous inputs, prepares them consistently with the existing codebase, and passes them through predict_df.Quantile outputs follow the same pattern as other model types.