Skip to content
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

[ENH] Shapelet visualization tools #1715

Merged
merged 16 commits into from
Jul 9, 2024

Conversation

baraline
Copy link
Member

@baraline baraline commented Jun 22, 2024

Reference Issues/PRs

Fixes #1703 #1684

What does this implement/fix? Explain your changes.

Add 3 classes for the following visualisation cases:

  • ShapeletVisualizer to visualize one shapelet, its values, itself on a time series on best match location, and its distance vector to a time series.
  • ShapeletTransformerVisualizer takes a fitted shapelet transformer and use ShapeletVisualizer methods. The shapelet to visualize is specified by ID when calling one of the three functions.
  • ShapeletClassifierVisualizer takes a fitted shapelet classifier and use ShapeletTransformerVisualizer methods. It adds another method to visualize the best shapelets for a given class. Only linear and forest based classifiers are supported for now.

The structure might be a bit naïve for now and could use some refactoring, but I feel like this belong in a future PR.

For use with ShapeletTransformClassifier, the rotation forest need to be switched to another classifier.

While playing with the new visualisation, I wanted to add the option to switch the distance function used to compute the distance vectors, so I added the distance parameter (interfacing with the distance module) to RDST and ShapeletVisualizer , which uses methods defined in RDST to compute distance vectors.

Example output :

from aeon.visualisation import ShapeletClassifierVisualizer
from aeon.datasets import load_classification
from aeon.classification.shapelet_based import RDSTClassifier
X, y = load_classification("Beef")
rdst = RDSTClassifier().fit(X, y)
shpt = ShapeletClassifierVisualizer(rdst)
class_id = 1
shpt.visualize_best_shapelets_one_class(X, y, class_id)

image

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

No.

Any other comments?

As MrSEQL and LS have non-standard structure compared to the others, they might not be supported directly in this PR

PR checklist

For new estimators and functions
  • I've added the estimator to the online API documentation.
  • (OPTIONAL) I've added myself as a __maintainer__ at the top of relevant files and want to be contacted regarding its maintenance. Unmaintained files may be removed. This is for the full file, and you should not add yourself if you are just making minor changes or do not want to help maintain its contents.
For developers with write access
  • (OPTIONAL) I've updated aeon's CODEOWNERS to receive notifications about future changes to these files.

@baraline baraline self-assigned this Jun 22, 2024
@baraline baraline linked an issue Jun 22, 2024 that may be closed by this pull request
@aeon-actions-bot aeon-actions-bot bot added enhancement New feature, improvement request or other non-bug code enhancement transformations Transformations package visualisation Visualisation module labels Jun 22, 2024
@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: [ $\color{#FEF1BE}{\textsf{enhancement}}$ ].
I have added the following labels to this PR based on the changes made: [ $\color{#41A8F6}{\textsf{transformations}}$, $\color{#FBCA04}{\textsf{visualisation}}$ ]. 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 all pytest tests and configurations
  • Run all notebook example tests
  • Run numba-disabled codecov tests
  • Stop automatic pre-commit fixes (always disabled for drafts)

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@baraline baraline linked an issue Jul 1, 2024 that may be closed by this pull request
@baraline baraline marked this pull request as ready for review July 1, 2024 20:28
@TonyBagnall
Copy link
Contributor

awesome stuff, I'll take a look now

@TonyBagnall
Copy link
Contributor

not here obvs, but it would be good to standardise the naming etc with internsal shapelets, eg

  """
    if isinstance(self.estimator, (RDSTClassifier, ShapeletTransformClassifier)):
        classifier = self.estimator._estimator
    elif isinstance(self.estimator, (RSASTClassifier, SASTClassifier)):
        classifier = self.estimator._classifier
    else:

Copy link
Contributor

@TonyBagnall TonyBagnall left a comment

Choose a reason for hiding this comment

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

@baraline maybe Im just looking in the wrong place, but the shapelet notebook seems not to have changed? Is it possible to demo all this in a notebook?

@baraline
Copy link
Member Author

baraline commented Jul 4, 2024

Hi Tony, the notebook content didn't change, I just opened it, and it seems to have render the image again, leading to à change in the cells metadata. This is probably due to a notebook version change.
My goal once the pr is in is to use all this in the shapelet notebook while I update it.

@baraline baraline requested a review from TonyBagnall July 4, 2024 14:06
Copy link
Contributor

@TonyBagnall TonyBagnall left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for this

@baraline baraline merged commit 2003cf2 into main Jul 9, 2024
14 checks passed
@baraline baraline deleted the 1703-enh-add-shapelet-visualization-method branch July 9, 2024 14:18
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 visualisation Visualisation module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ENH] Add shapelet visualization method [ENH] SATClassifier plot_most_important_feature_on_ts
2 participants