Skip to content

[FEAT] Add support for historical and static exogenous in TimeXer#1404

Merged
marcopeix merged 5 commits intomainfrom
feat/timexer_exog_support
Nov 6, 2025
Merged

[FEAT] Add support for historical and static exogenous in TimeXer#1404
marcopeix merged 5 commits intomainfrom
feat/timexer_exog_support

Conversation

@marcopeix
Copy link
Contributor

TimeXer now supports all types of exogenous features.

Example usage:

Y_train_df = AirPassengersPanel[AirPassengersPanel['ds'] < AirPassengersPanel['ds'].values[-12]].reset_index(drop=True)
Y_test_df = AirPassengersPanel[AirPassengersPanel['ds'] >= AirPassengersPanel['ds'].values[-12]].reset_index(drop=True)
futr_df = Y_test_df.drop(columns=["y", "y_[lag12]"])

models = [
    TimeXer(
        h=12,
        input_size=24,
        n_series=2,
        hist_exog_list=["y_[lag12]"],
        futr_exog_list=["trend"],
        stat_exog_list=['airline1'],
        max_steps=20,
        scaler_type="robust",
    ),
]

nf = NeuralForecast(
    models=models, 
    freq="ME", 
)

nf.fit(
    df=Y_train_df,
    static_df=AirPassengersStatic
)
fcsts = nf.predict(futr_df=futr_df)

@marcopeix marcopeix marked this pull request as ready for review October 30, 2025 15:08
@marcopeix marcopeix requested review from JQGoh and elephaint October 30, 2025 15:09
Copy link
Contributor

@JQGoh JQGoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions and requests:

  • Suggest to add a minimal example of test using exogenous variables for in tests/test_models/test_timexer.py. Consider examples like 1) X with static exog, 2) X without static exog
  • I notice that you include pydantic dependency in this PR, is it because you ran into Ray-related failure and this helps to resolve it? If that is the case, do you still remember what kind of Ray error?

Otherwise, the PR LGTM

@marcopeix
Copy link
Contributor Author

@JQGoh

  1. Sure, I can add a test, good idea!
  2. Right, I added pydantic because of ray issues. The error message was
ImportError: `ray.train.v2` requires the pydantic package, which is missing. Run the following command to fix this: `pip install pydantic`

So I added the dependency to fix the issue.

Copy link
Contributor

@elephaint elephaint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, the dependency we need is ray.train, that is missing. So, I'd add the ray.train dependency

@marcopeix marcopeix requested a review from elephaint November 4, 2025 20:39
@marcopeix
Copy link
Contributor Author

For the tests, I agree we should have them, but I noticed that none of the models that support exogenous features have tests for exog features. I can make a separate PR to add a global test for models that support exog feat, something similar to the current test_model. And keep this PR only for TimeXer. Wdyt?

@JQGoh
Copy link
Contributor

JQGoh commented Nov 5, 2025

yes, I also notice that. Sounds good to me

For the tests, I agree we should have them, but I noticed that none of the models that support exogenous features have tests for exog features. I can make a separate PR to add a global test for models that support exog feat, something similar to the current test_model. And keep this PR only for TimeXer. Wdyt?

@JQGoh JQGoh self-requested a review November 6, 2025 00:07
Copy link
Contributor

@elephaint elephaint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice!

non-blocking - you can use "check_model" from .common._model_checks with "losses" to test models against each loss function, this typically uncovers bugs (I didn't run it on this PR, just "fyi" in case you didn't know)

@marcopeix marcopeix merged commit a37d6cf into main Nov 6, 2025
22 checks passed
@marcopeix marcopeix deleted the feat/timexer_exog_support branch November 6, 2025 19:38
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.

TimeXer Model - exogeneous variables support

3 participants