Skip to content

feat(core): accept X_df / exogenous variables in detect_anomalies #75

Open

Description

@AzulGarza

Problem

forecast() takes known-future covariates via X_df (and cross_validation() reads the same columns from df). detect_anomalies() does not: it is implemented as in-sample cross-validation but the public API on both Forecaster and FoundationForecast omits X_df / futr_exog_list.

# forecast / CV
ff.forecast(df, h=24, X_df=X_df, level=[90])
ff.cross_validation(df, h=24, level=[90])  # exog columns on df

# anomalies — no way to pass covariates
ff.detect_anomalies(df, level=99)

Anomaly flags are residual-based (y vs the model forecast on each CV fold). Without horizon exog, models that actually use covariates (Chronos-2, TimesFM-3, TimeGPT, T0, TiRex-2, Timestral, …) score anomalies as if the series were univariate. Docs (docs/exogenous-variables.md) also never mention detect_anomalies.

Proposal

  1. Add X_df and futr_exog_list to detect_anomalies() on Forecaster and FoundationForecast, matching the existing forecast / CV contract and exog_strategy.
  2. Forward them into the CV path that already builds per-fold X_df from holdout rows (forecaster.py around the cross_validation split loop).
  3. Document the data shape: like CV, covariates must cover the windows being scored (typically columns on df; a separate X_df when the caller keeps history and horizon exog apart).
  4. Tests: extend the parametrized exog coverage in tests/models/test_models.py with a detect_anomalies + X_df case (skip when supports_native_futr_exog() is false). Add a focused unit test that detect_anomalies actually calls forecast with X_df.
  5. Docs: docs/exogenous-variables.md, docs/forecasting-parameters.md, and the README triad (forecast / cross_validation / detect_anomalies).

Related: Exogenous variables.

Activity

  1. sharmis-tp commented on Oct 27, 2026

    @sharmis-tp

    Right now detect_anomalies scores residuals from in-sample cross-validation but drops the exogenous support that forecast/cross_validation already have: def detect_anomalies on both Forecaster (core/forecaster.py) and the FoundationForecast wrapper (core/multi_model.py) takes no X_df/futr_exog_list, so covariate-aware models score as if the series were univariate. My read is to thread X_df and futr_exog_list through to the CV split loop that already builds per-fold holdout covariates, honouring exog_strategy. For the FoundationForecast ensemble path, should the exog be fanned out to each member and gated per-model on supports_native_futr_exog(), so a mixed ensemble with one univariate-only model doesn't error? Happy to add the parametrized exog test and the docs updates. Please assign me — PR within 1–2 days.

  2. AzulGarza commented on Oct 27, 2026

    @AzulGarza
    MemberAuthor

    hey @sharmis-tp. sounds good. for FoundationForecast, using exog_strategy=False should work for models that don't support exogenous variables.

    please feel free to open a PR.:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions