Skip to content

[ENH] TAR forecaster #3012

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

[ENH] TAR forecaster #3012

wants to merge 17 commits into from

Conversation

TonyBagnall
Copy link
Contributor

@TonyBagnall TonyBagnall commented Aug 7, 2025

Resolves #2817

Implements a numba TAR and AutoTAR forecaster. TAR is simple, if not a bit odd to me.

Given or find a threshold value. All points where previous delay point was below the threshold go in one series ("regime"), all values above in another. Fit separate AR models to each.

Also refactors TVPForecaster to just TVP for consistency

@TonyBagnall TonyBagnall added the forecasting Forecasting package label Aug 7, 2025
@aeon-actions-bot aeon-actions-bot bot added the enhancement New feature, improvement request or other non-bug code enhancement label Aug 7, 2025
@aeon-actions-bot
Copy link
Contributor

Thank you for contributing to aeon

I have added the following labels to this PR based on the title: [ enhancement ].
I would have added the following labels to this PR based on the changes made: [ forecasting ], however some package labels are already present.

The Checks tab will show the status of our automated tests. You can click on individual test runs in the tab or "Details" in the panel below to see more information if there is a failure.

If our pre-commit code quality check fails, any trivial fixes will automatically be pushed to your PR unless it is a draft.

Don't hesitate to ask questions on the aeon Slack channel if you have any.

PR CI actions

These checkboxes will add labels to enable/disable CI functionality for this PR. This may not take effect immediately, and a new commit may be required to run the new configuration.

  • Run pre-commit checks for all files
  • Run mypy typecheck tests
  • Run all pytest tests and configurations
  • Run all notebook example tests
  • Run numba-disabled codecov tests
  • Stop automatic pre-commit fixes (always disabled for drafts)
  • Disable numba cache loading
  • Push an empty commit to re-run CI checks

@TonyBagnall
Copy link
Contributor Author

comparing to our current optimised for speed ARIMA and current SETAR tree. MSE on simulated low order ARMA. Cheating a bit as giving TAR the correct AR order (doesnt fit MA though).

image

runtime
image

super fast TAR, but also super simple. Not trying to make the definitive version, if someone is a fan of the forecaster they might do so, Im only interested in potential components. Also shows we can optimise SETAR tree.

@TonyBagnall TonyBagnall changed the title [ENH] TAR and SETAR forecasters [ENH] TAR forecaster Aug 7, 2025
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Contributor

@alexbanwell1 alexbanwell1 left a comment

Choose a reason for hiding this comment

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

Can't comment much on the actual correctness of the model, but it seems from the graph that it is doing the correct thing, but otherwise looks good

@TonyBagnall
Copy link
Contributor Author

TonyBagnall commented Aug 14, 2025

so this has got more complex. It now includes TAR: fixed parameters with optional defaults and AutoTAR, which finds the parameters. ChatGPT gave me a much more efficient way of auto fitting based on storing sum of squares (reminded me of shapelets). Its complex, so I have tested this against a grid search using the basic one, output identical (tested for each value of n), run times much faster (30x-70x),
image

For correctness, there are no proper TAR implementations in python to compare against and I will not go into R. It should be as good as AR/ARMA though, which gives us a core experiment

AutoTAR comparable in ARMA data, which you would hope.
image
Interestingly faster than ARMA, which has fixed p and q, which is the fastest ARMA I could find. much faster than our current SETAR, which I will optimise. Setting AR parameters with OLS is very fast

image

@TonyBagnall TonyBagnall marked this pull request as ready for review August 14, 2025 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, improvement request or other non-bug code enhancement forecasting Forecasting package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ENH] Implement Threshold Autoregressive model(s)
2 participants