Skip to content

[BUG] Give each representation its own seed in interval forests - #3974

Draft
TonyBagnall wants to merge 1 commit into
mainfrom
ajb/interval-seed
Draft

TonyBagnall wants to merge 1 commit into
mainfrom
ajb/interval-seed

Conversation

@TonyBagnall

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

None

What does this implement/fix? Explain your changes.

Found this out when experimenting with alternatives. This is by claude and their comments, I will work through and check before taking out of draft

Interval forests with several representations drew every representation's intervals from the same random stream:

  • BaseIntervalForest._fit_estimator passed the tree's seed to the interval selector of each series transformer. This affects DrCIFClassifier, DrCIFRegressor and SupervisedTimeSeriesForest, which use the base series, the periodogram and first differences.
  • RSTSF._fit passed random_state=self.random_state to the SupervisedIntervals of all four of its representations.

Interval i of each representation therefore had the same channel, start/end choice and length draws, varying only where the representations differed in length. With random_state=0, 65% of the intervals at the same index were identical across representations.

This is a regression from #545. The original DrCIF drew the intervals of all representations in sequence from one rng.

Fix: each representation after the first gets its own seed, drawn from the tree's rng (in RSTSF, from check_random_state(self.random_state)). The first representation keeps the tree's seed, so forests with one representation (CIF, TSF, RISE, IntervalForestClassifier) give exactly the same results as before. RISTClassifier and RISTRegressor already drew a new state per representation and are unchanged.

The expected results change only for DrCIFClassifier, RSTSF and SupervisedTimeSeriesForest, which have been regenerated. DrCIFRegressor is excluded from the expected results.

Results

Default DrCIFClassifier (200 trees) on 100 UCR datasets, using the default train/test splits, 5 seeds each, main against this branch. The 28 slowest UCR datasets were left out. Datasets with variable lengths or missing values use their _eq and _nmv versions. The scores are averaged over seeds; the comparison is over datasets.

main this PR PR better / tie / worse Wilcoxon p
Accuracy 0.8481 0.8493 45 / 23 / 32 0.10
Balanced accuracy 0.8246 0.8260 50 / 17 / 33 0.087
Log loss 0.5422 0.5388 69 / 0 / 31 0.0002
Same-index interval overlap 64.6% 0.1%

With independent intervals, the ensemble is more diverse:

  • the probability estimates are better (log loss falls on 69 of 100 datasets);
  • accuracy is about the same, slightly higher on average but not significantly.

The fix adds one random draw per representation per tree, so it should have no effect on fit time.

Does your contribution introduce a new dependency? If yes, which one?

No.

Any other comments?

New tests:

  • a base interval forest given the same series twice (series_transformers=[None, None]) must sample different intervals for each copy, for both random and supervised selection. This test fails on main;
  • RSTSF must give each representation's SupervisedIntervals a different seed.

Tested locally:

  • the interval-based tests in aeon/base, aeon/classification, aeon/regression and aeon/transformations;
  • test_all_estimators for DrCIFClassifier, RSTSF and SupervisedTimeSeriesForest, including the expected-results checks;
  • pre-commit.

BaseIntervalForest passed the tree's seed to the interval selector of every
series transformer, so DrCIF and STSF drew the intervals of each
representation from the same random stream. RSTSF did the same with
random_state. Each representation after the first now gets its own seed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aeon-actions-bot aeon-actions-bot Bot added bug Something isn't working classification Classification package testing Testing related issue or pull request labels Oct 29, 2026
@aeon-actions-bot

Copy link
Copy Markdown
Contributor

Thank you for contributing to aeon

I have added the following labels to this PR based on the title: bug.
I have added the following labels to this PR based on the changes made: classification testing. Feel free to change these if they do not properly represent the PR.

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, please run pre-commit locally and push the fixes to your PR branch.

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

PR CI actions

These checkboxes will add labels to enable or 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
  • Disable numba cache loading
  • Regenerate expected results for testing
  • Push an empty commit to re-run CI checks

This branch has not been deployed

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

Labels

bug Something isn't working classification Classification package testing Testing related issue or pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant