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

[MNT] Tags using enums #2235 #2437

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
41 changes: 41 additions & 0 deletions aeon/clustering/_clustering_tags.py
Copy link
Member

Choose a reason for hiding this comment

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

I would not do this in the clustering module, it should be more integrated with the other tags stuff in aeon/utils/tags.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from enum import Enum


class ClusteringAlgorithmType(Enum):
lucifer4073 marked this conversation as resolved.
Show resolved Hide resolved
"""
An enumeration of clustering algorithm types, dependencies, and data structures.

This enum provides a comprehensive classification for different clustering-related
categorizations, including algorithm types, Python dependencies, and data structures
used in clustering processes.

Attributes
----------
Algorithm Types:
- DISTANCE: Clustering based on distance metrics
- DEEPLEARNING: Clustering using deep learning techniques
- FEATURE: Clustering driven by feature extraction

Python Dependencies:
lucifer4073 marked this conversation as resolved.
Show resolved Hide resolved
- TSLEARN: Time series machine learning library
- TENSORFLOW: Deep learning framework
- TSFRESH: Time series feature extraction library

Data Structure Types:
- NP_LIST: Numpy list-based data structure
- NUMPY3D: Three-dimensional Numpy array
"""

# Algorithm types for clustering strategies
DISTANCE = "distance"
DEEPLEARNING = "deeplearning"
FEATURE = "feature"

# Python dependencies for clustering implementations
TSLEARN = "tslearn"
TENSORFLOW = "tensorflow"
TSFRESH = "tsfresh"
lucifer4073 marked this conversation as resolved.
Show resolved Hide resolved

# Data structure types for clustering input
NP_LIST = "np-list"
NUMPY3D = "numpy3D"
3 changes: 2 additions & 1 deletion aeon/clustering/_elastic_som.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from numpy.random import RandomState
from sklearn.utils.random import check_random_state

from aeon.clustering._clustering_tags import ClusteringAlgorithmType
from aeon.clustering.base import BaseClusterer
from aeon.distances import get_alignment_path_function, pairwise_distance

Expand Down Expand Up @@ -148,7 +149,7 @@ class ElasticSOM(BaseClusterer):

_tags = {
"capability:multivariate": True,
"algorithm_type": "distance",
"algorithm_type": ClusteringAlgorithmType.DISTANCE.value,
}

def __init__(
Expand Down
4 changes: 3 additions & 1 deletion aeon/clustering/_k_means.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from typing import Optional

from aeon.clustering._clustering_tags import ClusteringAlgorithmType

__maintainer__ = []

from typing import Callable, Union
Expand Down Expand Up @@ -153,7 +155,7 @@ class TimeSeriesKMeans(BaseClusterer):

_tags = {
"capability:multivariate": True,
"algorithm_type": "distance",
"algorithm_type": ClusteringAlgorithmType.DISTANCE.value,
}

def __init__(
Expand Down
4 changes: 3 additions & 1 deletion aeon/clustering/_k_medoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from typing import Optional

from aeon.clustering._clustering_tags import ClusteringAlgorithmType

__maintainer__ = []

import warnings
Expand Down Expand Up @@ -146,7 +148,7 @@ class TimeSeriesKMedoids(BaseClusterer):

_tags = {
"capability:multivariate": True,
"algorithm_type": "distance",
"algorithm_type": ClusteringAlgorithmType.DISTANCE.value,
}

def __init__(
Expand Down
3 changes: 2 additions & 1 deletion aeon/clustering/_k_sc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from numpy.random import RandomState

from aeon.clustering import TimeSeriesKMeans
from aeon.clustering._clustering_tags import ClusteringAlgorithmType


class KSpectralCentroid(TimeSeriesKMeans):
Expand Down Expand Up @@ -92,7 +93,7 @@ class KSpectralCentroid(TimeSeriesKMeans):

_tags = {
"capability:multivariate": True,
"algorithm_type": "distance",
"algorithm_type": ClusteringAlgorithmType.DISTANCE.value,
}

def __init__(
Expand Down
5 changes: 3 additions & 2 deletions aeon/clustering/_k_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
from numpy.random import RandomState

from aeon.clustering._clustering_tags import ClusteringAlgorithmType
from aeon.clustering.base import BaseClusterer


Expand Down Expand Up @@ -69,8 +70,8 @@ class TimeSeriesKShape(BaseClusterer):

_tags = {
"capability:multivariate": True,
"python_dependencies": "tslearn",
"algorithm_type": "distance",
"python_dependencies": ClusteringAlgorithmType.TSLEARN.value,
"algorithm_type": ClusteringAlgorithmType.DISTANCE.value,
}

def __init__(
Expand Down
3 changes: 2 additions & 1 deletion aeon/clustering/_kernel_k_means.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
from numpy.random import RandomState

from aeon.clustering._clustering_tags import ClusteringAlgorithmType
from aeon.clustering.base import BaseClusterer


Expand Down Expand Up @@ -86,7 +87,7 @@ class TimeSeriesKernelKMeans(BaseClusterer):
_tags = {
"capability:multivariate": True,
"capability:multithreading": True,
"python_dependencies": "tslearn",
"python_dependencies": ClusteringAlgorithmType.TSLEARN.value,
}

def __init__(
Expand Down
6 changes: 5 additions & 1 deletion aeon/clustering/compose/_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from aeon.base._estimators.compose.collection_pipeline import BaseCollectionPipeline
from aeon.clustering import BaseClusterer
from aeon.clustering._clustering_tags import ClusteringAlgorithmType


class ClustererPipeline(BaseCollectionPipeline, BaseClusterer):
Expand Down Expand Up @@ -75,7 +76,10 @@ class ClustererPipeline(BaseCollectionPipeline, BaseClusterer):
"""

_tags = {
"X_inner_type": ["np-list", "numpy3D"],
"X_inner_type": [
ClusteringAlgorithmType.NP_LIST.value,
ClusteringAlgorithmType.NUMPY3D.value,
],
}

def __init__(self, transformers, clusterer, random_state=None):
Expand Down
7 changes: 4 additions & 3 deletions aeon/clustering/deep_learning/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from copy import deepcopy

from aeon.base._base import _clone_estimator
from aeon.clustering._clustering_tags import ClusteringAlgorithmType
from aeon.clustering._k_means import TimeSeriesKMeans
from aeon.clustering.base import BaseClusterer

Expand All @@ -29,12 +30,12 @@ class BaseDeepClusterer(BaseClusterer):
"""

_tags = {
"X_inner_type": "numpy3D",
"X_inner_type": ClusteringAlgorithmType.NUMPY3D.value,
"capability:multivariate": True,
"algorithm_type": "deeplearning",
"algorithm_type": ClusteringAlgorithmType.DEEPLEARNING.value,
"non_deterministic": True,
"cant_pickle": True,
"python_dependencies": "tensorflow",
"python_dependencies": ClusteringAlgorithmType.TENSORFLOW.value,
}

@abstractmethod
Expand Down
8 changes: 6 additions & 2 deletions aeon/clustering/feature_based/_catch22.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from aeon.base._base import _clone_estimator
from aeon.clustering import BaseClusterer
from aeon.clustering._clustering_tags import ClusteringAlgorithmType
from aeon.transformations.collection.feature_based import Catch22


Expand Down Expand Up @@ -92,11 +93,14 @@ class Catch22Clusterer(BaseClusterer):
"""

_tags = {
"X_inner_type": ["np-list", "numpy3D"],
"X_inner_type": [
ClusteringAlgorithmType.NP_LIST.value,
ClusteringAlgorithmType.NUMPY3D.value,
],
"capability:multivariate": True,
"capability:unequal_length": True,
"capability:multithreading": True,
"algorithm_type": "feature",
"algorithm_type": ClusteringAlgorithmType.FEATURE.value,
}

def __init__(
Expand Down
3 changes: 2 additions & 1 deletion aeon/clustering/feature_based/_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from aeon.base._base import _clone_estimator
from aeon.clustering import BaseClusterer
from aeon.clustering._clustering_tags import ClusteringAlgorithmType
from aeon.transformations.collection.feature_based import SevenNumberSummary


Expand Down Expand Up @@ -64,7 +65,7 @@ class SummaryClusterer(BaseClusterer):
_tags = {
"capability:multivariate": True,
"capability:multithreading": True,
"algorithm_type": "feature",
"algorithm_type": ClusteringAlgorithmType.FEATURE.value,
}

def __init__(
Expand Down
5 changes: 3 additions & 2 deletions aeon/clustering/feature_based/_tsfresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from aeon.base._base import _clone_estimator
from aeon.clustering import BaseClusterer
from aeon.clustering._clustering_tags import ClusteringAlgorithmType
from aeon.transformations.collection.feature_based import TSFresh


Expand Down Expand Up @@ -74,8 +75,8 @@ class TSFreshClusterer(BaseClusterer):
_tags = {
"capability:multivariate": True,
"capability:multithreading": True,
"algorithm_type": "feature",
"python_dependencies": "tsfresh",
"algorithm_type": ClusteringAlgorithmType.FEATURE.value,
"python_dependencies": ClusteringAlgorithmType.TSFRESH.value,
}

def __init__(
Expand Down