aeon-toolkit / aeon

A toolkit for machine learning from time series
https://aeon-toolkit.org/
BSD 3-Clause "New" or "Revised" License
1.02k stars 128 forks source link

[MNT] Tags using enums #2235

Open chrisholder opened 1 month ago

chrisholder commented 1 month ago

Describe the feature or idea you want to propose

In aeon we use the _tags to define the capabilities. For examples:

    _tags = {
        "X_inner_type": ["np-list", "numpy3D"],
        "capability:multivariate": True,
        "capability:unequal_length": True,
        "capability:multithreading": True,
        "algorithm_type": "feature",
    }

For values like "algorithm_type" and "X_inner_type" which we use a string value for it would be nice if these were defined with enums.

Describe your proposed solution

Add an enum for each tag form example:

from enum import Enum

class AlgorithmTypeTag(Enum):
    FEATURE = "feature"
    DISTANCE = "distance"
    DICTIONARY = "dictionary"
    HYBRID = "hybrid"
    INTERVAL = "interval"
    CONVOLUTION = "convolution"
    SHAPELET = "shapelet"
    DEEPLEARNING = "deeplearning"

Assuming we had a enum for each type we could then do something like this:

    _tags = {
        "X_inner_type": [InnerTypeTag.NP_LIST, InnerTypeTag.NUMPY3D],
        "capability:multivariate": True,
        "capability:unequal_length": True,
        "capability:multithreading": True,
        "algorithm_type": AlgorithmTypeTag.FEATURE,
    }

As the values of the enums that they resolve to are the same string values it means we don't need to change any of the actual tag logic. Additionally we can better assert the tag is valid by checking if a value is an instance for Enum.

Describe alternatives you've considered, if relevant

No response

Additional context

No response

itsdivya1309 commented 4 days ago

Hi, can I take up this issue?