fix(examples): migrate anomaly-detection example to TimesFM 2.5 - #466
Open
ihubanov wants to merge 1 commit into
Open
fix(examples): migrate anomaly-detection example to TimesFM 2.5#466ihubanov wants to merge 1 commit into
ihubanov wants to merge 1 commit into
Conversation
detect_anomalies.py still calls the v1 API that 2.5 removed, so it fails on
the first model load:
AttributeError: module 'timesfm' has no attribute 'TimesFmHparams'
Port it to from_pretrained + ForecastConfig + forecast(horizon=...) and drop
the frequency indicator, using the same config as run_forecast.py in the
global-temperature example. The quantile column mapping here was already
correct (IDX_Q10..IDX_Q90 = 1/2/8/9), so only the loading path changes.
Regenerate the committed artifacts. The continuous quantile head in 2.5 gives
tighter intervals than the checkpoint the old artifacts came from: the 80% PI
width at month 12 goes 0.494 -> 0.329. One further month therefore falls
outside the band and the forecast CRITICAL count moves 4 -> 5. All three
injected anomalies are still caught, and the acceptance criterion documented
in SKILL.md still holds (Sep 2023 CRITICAL at z=+3.03).
Refs google-research#423
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
@googlebot I signed it! |
This was referenced Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to #465, for the other example still on the removed v1 API. Independent of it; either can merge first.
detect_anomalies.pyfails on the first model load:Changes
TimesFM_2p5_200M_torch.from_pretrained+model.compile(ForecastConfig(...)), using the same config asrun_forecast.pyin the global-temperature example.horizonexplicitly toforecast()and dropfreq=[0].The quantile column mapping in this file was already correct (
IDX_Q10, IDX_Q20, IDX_Q80, IDX_Q90 = 1, 2, 8, 9), so only the loading path changes. The diff is 20 lines.Behaviour change in the regenerated artifacts
2.5's continuous quantile head gives noticeably tighter intervals than the checkpoint the committed artifacts came from:
One more month therefore falls outside the band, so the forecast CRITICAL count moves 4 -> 5. Worth flagging rather than burying, though it does not weaken the example:
SKILL.md, Sep 2023 CRITICAL, still holds at z=+3.03.If you would rather keep the old detection counts, the honest lever is the injected offsets in
build_synthetic_future()rather than loosening the bands. I left them alone, since tuning the fixture to preserve a number seemed worse than reporting the difference.Verification
Ran end to end on CPU (Python 3.13, torch 2.13.0+cpu). Regenerated
anomaly_detection.jsonandanomaly_detection.png.Refs #423