Skip to content

[ENH] Add Extended Isolation Forest anomaly detector (#2113)#3626

Open
CedricConday wants to merge 1 commit into
aeon-toolkit:mainfrom
CedricConday:enh/extended-isolation-forest
Open

[ENH] Add Extended Isolation Forest anomaly detector (#2113)#3626
CedricConday wants to merge 1 commit into
aeon-toolkit:mainfrom
CedricConday:enh/extended-isolation-forest

Conversation

@CedricConday

Copy link
Copy Markdown
Contributor

Fixes #2113.

Adds ExtendedIsolationForest, a series anomaly detector implementing the Extended Isolation Forest (Hariri et al., 2021), next to the existing IsolationForest.

Following the discussion in the issue, this is a direct implementation rather than a wrapper of the eif package: the isolation trees split on random hyperplanes (x - p) · n <= 0 instead of axis-parallel cuts, and an extension_level parameter sets how many components of the normal vector are non-zero. extension_level=0 zeroes all but one component and recovers the standard axis-parallel Isolation Forest; n_features - 1 (the default when None) uses fully oriented hyperplanes. The detector reuses the existing sliding-window pattern (window_size, stride, reverse_windowing) and supports univariate, multivariate, unsupervised and semi-supervised use.

Why a direct implementation: it needs no new dependency (pure NumPy), and the eif reference package has not been updated in ~5 years and no longer installs on current toolchains, so a wrapper would be fragile.

Validation I ran locally (throwaway script, not committed):

  • With extension_level=0 the window scores rank-correlate with sklearn.ensemble.IsolationForest on identical windows at Spearman ≈ 0.97, i.e. the model reduces to the original algorithm as expected.
  • Injected point anomalies in a synthetic series are separated with ROC-AUC 1.0.
  • Output is identical across runs for a fixed random_state.

Worth a careful look:

  • The c(n) normalisation and the score formula 2 ** (-E[h(x)] / c(psi)).
  • Degenerate splits (e.g. constant windows) fall back to a leaf node rather than recursing.
  • Whether extension_level=None → n_features - 1 is the right default.

Tests: 9 unit tests covering uni/multivariate, stride, no-window, semi-supervised, determinism, the extension_level=0 reduction, and parameter validation; the estimator also passes check_estimator. pre-commit is clean.

This pull request includes code written with the assistance of AI. The code has not yet been reviewed by a human.

Direct, dependency-free implementation of the Extended Isolation Forest
(Hariri et al., 2021) as a series anomaly detector, alongside the existing
IsolationForest. Trees split on random hyperplanes rather than axis-parallel
cuts, with an extension_level parameter; extension_level=0 recovers the
standard Isolation Forest. Follows the existing sliding-window detector
pattern and supports uni/multivariate, unsupervised and semi-supervised use.
@aeon-actions-bot aeon-actions-bot Bot added anomaly detection Anomaly detection package enhancement New feature, improvement request or other non-bug code enhancement labels Jul 9, 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: [ enhancement ].
I have added the following labels to this PR based on the changes made: [ anomaly detection ]. 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

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

Labels

anomaly detection Anomaly detection package enhancement New feature, improvement request or other non-bug code enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] Implement Extended Isolation Forest

1 participant