Skip to content

Conversation

@Kushagra7777
Copy link
Collaborator

This PR adds exogenous-feature handling to the Chronos-2 forecast.
The function _forecast_chronos2_df now 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.

@AzulGarza AzulGarza requested a review from Copilot November 24, 2025 22:12
Copilot finished reviewing on behalf of AzulGarza November 24, 2025 22:14
Copy link
Contributor

Copilot AI left a 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_df method
  • Updates cross-validation to check model support for exogenous variables before raising errors
  • Sets supports_exogenous flag 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")
Copy link

Copilot AI Nov 24, 2025

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)}')

Suggested change
raise ValueError("missing required columns")
missing = required - set(df.columns)
raise ValueError(f"Missing required columns: {missing}")

Copilot uses AI. Check for mistakes.
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")
Copy link

Copilot AI Nov 24, 2025

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)}')

Suggested change
raise ValueError("predictions column missing")
raise ValueError(f"predictions column missing from model output. Available columns: {list(pred_df.columns)}")

Copilot uses AI. Check for mistakes.
Comment on lines +185 to +188
exog_cols = []
for col in df.columns:
if col not in base_cols:
exog_cols.append(col)
Copy link

Copilot AI Nov 24, 2025

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]

Suggested change
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]

Copilot uses AI. Check for mistakes.
supports_exogenous = getattr(self, "supports_exogenous", False)
for _, (cutoffs, train, valid) in tqdm(enumerate(splits)):
if len(valid.columns) > 3:

Copy link

Copilot AI Nov 24, 2025

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.

Suggested change

Copilot uses AI. Check for mistakes.
Kushagra7777 and others added 4 commits November 26, 2025 11:50
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant