Skip to content

[ENH] Fix binary IG calculation to respect identical split values#3206

Draft
musaqlain wants to merge 1 commit intoaeon-toolkit:mainfrom
musaqlain:fix/1322-shapelet-ig-calculation
Draft

[ENH] Fix binary IG calculation to respect identical split values#3206
musaqlain wants to merge 1 commit intoaeon-toolkit:mainfrom
musaqlain:fix/1322-shapelet-ig-calculation

Conversation

@musaqlain
Copy link
Copy Markdown

Reference Issues/PRs

Fixes #1322

What does this implement/fix? Explain your changes.

This PR fixes a logic error in ShapeletTransform where the binary Information Gain (IG) calculation was incorrectly evaluating split points between identical distance values.

Problem:
The _calc_binary_ig function iterated through every index in the sorted orderline to test split points. It failed to check if the current distance was equal to the next distance (orderline[i].distance == orderline[i+1].distance). This caused the algorithm to calculate splits inside groups of identical values, which is mathematically invalid and resulted in inflated IG scores (e.g., returning ~0.97 instead of ~0.42 for the reproduction case).

Solution:
Added a check to strictly skip invalid split points where the distance values are identical.

if orderline[split][0] == orderline[split+1][0]:
    continue

@aeon-actions-bot aeon-actions-bot bot added enhancement New feature, improvement request or other non-bug code enhancement transformations Transformations package labels Dec 26, 2025
@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: [ transformations ]. 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, 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
  • Regenerate expected results for testing
  • Push an empty commit to re-run CI checks

@musaqlain
Copy link
Copy Markdown
Author

PTAL @MatthewMiddlehurst @TonyBagnall

@MatthewMiddlehurst
Copy link
Copy Markdown
Member

This is less of a fix and more of a change to the algorithm itself. I would want to see it evaluated on benchmark datasets to see how it changes results before going forward. Either way skipping the last IG check does not seem correct.

@TonyBagnall
Copy link
Copy Markdown
Contributor

hi, I looked at this and I dont really think the change is necessary. Its a design decision, and it as no impact on performance when I tested it, so I think atm I go by if it aint broke, dont fix it. I'll convert to draft, but if you can show it adds value, happy to switch back

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 transformations Transformations package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] ShapeletTransform: binary ig calculation problem

3 participants