Repository: aeon-toolkit/aeon
Pull request #1739 (2024-06-29 11:06:03)

[BUG] Cluster predict proba edge cases
<!--
Thanks for contributing a pull request! Please ensure you have taken a look at our
contribution guide: https://www.aeon-toolkit.org/en/stable/contributing.html

Feel free to delete sections of this template if they do not apply to your PR,
avoid submitting a blank template or empty sections.
-->

#### Reference Issues/PRs

<!--
Example: Fixes #1234. See also #3456.
Please use keywords (e.g., Fixes) to create link to the issues or pull requests
you resolved, so that they will automatically be closed when your pull request
is merged. See https://github.com/blog/1506-closing-issues-via-pull-requests
-->

#### What does this implement/fix? Explain your changes.

There were two edge cases with the clustering predict_proba function that would cause crashes.

1) If there wasn't at least 1 prediction in every cluster
2) If the prediction didn't use cluster values of 0-n_clusters. For example I used a k-medoids package that when predict was called returned [22, 22, 32, 3, 32, 22] where instead of the cluster values being a value from 0-n_clusters it was referring to the index of the cluster centre that each value was assigned to. 

<!--
A clear and concise description of what you have implemented.
-->

This PR makes two main changes to address the above.
1) Instead of using .shape[0] to create the dist array n_clusters is used (when available isn't required):

```
            n_clusters = self.n_clusters
            if n_clusters is None:
                n_clusters = int(max(preds)) + 1
            dists = np.zeros((X.shape[0], n_clusters))
```

2) A additional sanitisation of the predict result is done to convert predictions value to 0-n_clusters. This allows the other logic to work if the predictions doesn't return 0-n_clusters:

```
  unique = np.unique(preds)
  for i, u in enumerate(unique):
      preds[preds == u] = i
```


#### Does your contribution introduce a new dependency? If yes, which one?

<!--
If your contribution does add a dependency, we may suggest adding it as an
optional/soft dependency to keep external dependencies of the core aeon package
to a minimum.
-->

#### Any other comments?

<!--
Please be aware that we are a loose team of volunteers so patience is
necessary; assistance handling other issues is very welcome. We value all
user contributions, no matter how minor they are. If we are slow to
review, either the pull request needs some benchmarking, tinkering,
convincing, etc. or more likely the reviewers are simply busy. In either
case, we ask for your understanding during the review process.
-->

### PR checklist

<!--
Please go through the checklist below. Please feel free to remove points if they are not applicable.
-->

##### For all contributions
- [ ] I've added myself to the [list of contributors](https://github.com/aeon-toolkit/aeon/blob/main/.all-contributorsrc). Alternatively, you can use the [@all-contributors](https://allcontributors.org/docs/en/bot/usage) bot to do this for you.
- [ ] The PR title starts with either [ENH], [MNT], [DOC], [BUG], [REF], [DEP] or [GOV] indicating whether the PR topic is related to enhancement, maintenance, documentation, bugs, refactoring, deprecation or governance.

##### For new estimators and functions
- [ ] I've added the estimator to the online [API documentation](https://www.aeon-toolkit.org/en/latest/api_reference.html).
- [ ] (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](https://github.com/aeon-toolkit/aeon/blob/main/CODEOWNERS) to receive notifications about future changes to these files.


<!--
Thanks for contributing!
-->


aeon-actions-bot[bot]: 
## Thank you for contributing to `aeon`

I have added the following labels to this PR based on the title: **[ $\\color{#d73a4a}{\\textsf{bug}}$ ]**.
I have added the following labels to this PR based on the changes made: **[ $\\color{#4011F3}{\\textsf{clustering}}$ ]**. Feel free to change these if they do not properly represent the PR.

The [Checks](https://github.com/aeon-toolkit/aeon/pull/1739/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](https://join.slack.com/t/aeon-toolkit/shared_invite/zt-22vwvut29-HDpCu~7VBUozyfL_8j3dLA) 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)
    
TonyBagnall: is this related to https://github.com/aeon-toolkit/aeon/issues/882?
chrisholder: No this is just a general bug fix

Patch:
diff --git a/aeon/classification/dictionary_based/_redcomets.py b/aeon/classification/dictionary_based/_redcomets.py
index 446af7b1..4e782f2e 100644
--- a/aeon/classification/dictionary_based/_redcomets.py
+++ b/aeon/classification/dictionary_based/_redcomets.py
@@ -1,5 +1,3 @@
-# copyright: aeon developers, BSD-3-Clause License (see LICENSE file)
-
 """Random EnhanceD Co-eye for Multivariate Time Series (RED CoMETS).
 
 Ensemble of symbolically represented time series using random forests as the base
@@ -16,10 +14,10 @@ from joblib import Parallel, delayed
 from sklearn.ensemble import RandomForestClassifier
 from sklearn.model_selection import cross_val_score
 from sklearn.neighbors import NearestNeighbors
-from sklearn.preprocessing import scale
 from sklearn.utils import check_random_state
 
 from aeon.classification.base import BaseClassifier
+from aeon.transformations.collection import TimeSeriesScaler
 from aeon.transformations.collection.dictionary_based import SAX, SFA
 from aeon.utils.validation._dependencies import _check_soft_dependencies
 
@@ -42,15 +40,15 @@ class REDCOMETS(BaseClassifier):
     n_trees : int, default=100
         Number of trees used by each random forest sub-classifier.
     random_state : int, RandomState instance or None, default=None
-        If `int`, random_state is the seed used by the random number generator;
-        If `RandomState` instance, random_state is the random number generator;
-        If `None`, the random number generator is the `RandomState` instance used
-        by `np.random`.
+        If ``int``, random_state is the seed used by the random number generator;
+        If ``RandomState`` instance, ``random_state`` is the random number generator;
+        If ``None``, the random number generator is the ``RandomState`` instance used
+        by ``np.random``.
     n_jobs : int, default=1
         The number of jobs to run in parallel for both `fit` and `predict`.
         ``-1`` means using all processors.
     parallel_backend : str, ParallelBackendBase instance or None, default=None
-        Specify the parallelisation backend implementation in joblib for Catch22,
+        Specify the parallelisation backend implementation in joblib,
         if ``None`` a 'prefer' value of "threads" is used by default.
         Valid options are "loky", "multiprocessing", "threading" or a custom backend.
         See the joblib Parallel documentation for more details.
@@ -119,13 +117,7 @@ class REDCOMETS(BaseClassifier):
         self.n_jobs = n_jobs
         self.parallel_backend = parallel_backend
 
-        self._n_channels = 1
-
-        self.sfa_clfs = []
-        self.sfa_transforms = []
-
-        self.sax_clfs = []
-        self.sax_transforms = []
+        self._n_channels = None
 
         super().__init__()
 
@@ -146,7 +138,9 @@ class REDCOMETS(BaseClassifier):
         self :
             Reference to self.
         """
-        if (n_channels := X.shape[1]) == 1:  # Univariate
+        self._n_channels = X.shape[1]
+
+        if self._n_channels == 1:  # Univariate
             assert self.variant in [1, 2, 3]
             (
                 self.sfa_transforms,
@@ -155,7 +149,6 @@ class REDCOMETS(BaseClassifier):
                 self.sax_clfs,
             ) = self._build_univariate_ensemble(np.squeeze(X), y)
         else:  # Multivariate
-            self._n_channels = n_channels
 
             if self.variant in [1, 2, 3]:  # Concatenate
                 X_concat = X.reshape(*X.shape[:-2], -1)
@@ -208,7 +201,7 @@ class REDCOMETS(BaseClassifier):
 
         from imblearn.over_sampling import SMOTE, RandomOverSampler
 
-        X = scale(X, axis=1)  # Z-normalise
+        X = TimeSeriesScaler().fit_transform(X).squeeze()
 
         if self.variant in [1, 2, 3]:
             perc_length = self.perc_length / self._n_channels
@@ -242,8 +235,8 @@ class REDCOMETS(BaseClassifier):
                 ).fit_resample(X, y)
 
         lenses = self._get_random_lenses(X_smote, n_lenses)
-        sax_lenses = lenses[: n_lenses // 2]
-        sfa_lenses = lenses[n_lenses // 2 :]
+        sfa_lenses = lenses[: n_lenses // 2]
+        sax_lenses = lenses[n_lenses // 2 :]
 
         cv = np.min([5, len(y_smote) // len(list(set(y_smote)))])
 
@@ -253,7 +246,6 @@ class REDCOMETS(BaseClassifier):
                 alphabet_size=a,
                 window_size=X_smote.shape[1],
                 binning_method="equi-width",
-                save_words=True,
                 n_jobs=self.n_jobs,
                 random_state=self.random_state,
             )
@@ -262,10 +254,8 @@ class REDCOMETS(BaseClassifier):
 
         sfa_clfs = []
         for sfa in sfa_transforms:
-            sfa.fit_transform(X_smote, y_smote)
-            X_sfa = np.array(
-                [sfa.word_list(word) for word in np.array(sfa.words).ravel()]
-            )
+            sfa_dics = sfa.fit_transform(X_smote, y_smote)
+            X_sfa = np.array([sfa.word_list(list(d.keys())[0]) for d in sfa_dics[0]])
 
             rf = RandomForestClassifier(
                 n_estimators=self.n_trees,
@@ -280,6 +270,7 @@ class REDCOMETS(BaseClassifier):
                 weight = cross_val_score(
                     rf, X_sfa, y_smote, cv=cv, n_jobs=self.n_jobs
                 ).mean()
+
             else:
                 weight = None
 
@@ -420,15 +411,13 @@ class REDCOMETS(BaseClassifier):
             2D np.ndarray of shape (n_cases, n_classes_)
             Predicted probabilities using the ordering in ``classes_``.
         """
-        X = scale(X, axis=1)  # Z-normalise
+        X = TimeSeriesScaler().fit_transform(X).squeeze()
+
         pred_mat = np.zeros((X.shape[0], self.n_classes_))
 
-        placeholder_y = np.zeros(X.shape[0])
         for sfa, (rf, weight) in zip(self.sfa_transforms, self.sfa_clfs):
-            sfa.fit_transform(X, placeholder_y)
-            X_sfa = np.array(
-                [sfa.word_list(word) for word in np.array(sfa.words).ravel()]
-            )
+            sfa_dics = sfa.transform(X)
+            X_sfa = np.array([sfa.word_list(list(d.keys())[0]) for d in sfa_dics[0]])
 
             rf_pred_mat = rf.predict_proba(X_sfa)
 
@@ -466,8 +455,9 @@ class REDCOMETS(BaseClassifier):
             2D np.ndarray of shape (n_cases, n_classes_)
             Predicted probabilities using the ordering in ``classes_``.
         """
+        X = TimeSeriesScaler().fit_transform(X)
+
         ensemble_pred_mats = None
-        placeholder_y = np.zeros(X.shape[0])
 
         for d in range(self._n_channels):
             sfa_transforms = self.sfa_transforms[d]
@@ -477,14 +467,13 @@ class REDCOMETS(BaseClassifier):
             sax_clfs = self.sax_clfs[d]
 
             X_d = X[:, d, :]
-            X_d = scale(X_d, axis=1)  # Z-normalise
 
             if self.variant in [6, 7, 8, 9]:
                 dimension_pred_mats = None
             for sfa, (rf, _) in zip(sfa_transforms, sfa_clfs):
-                sfa.fit_transform(X_d, placeholder_y)
+                sfa_dics = sfa.transform(X_d)
                 X_sfa = np.array(
-                    [sfa.word_list(word) for word in np.array(sfa.words).ravel()]
+                    [sfa.word_list(list(d.keys())[0]) for d in sfa_dics[0]]
                 )
 
                 rf_pred_mat = rf.predict_proba(X_sfa)
@@ -571,26 +560,19 @@ class REDCOMETS(BaseClassifier):
             Randomly selected lenses.
         """
         maxCoof = 130
-
         if X.shape[1] < maxCoof:
             maxCoof = X.shape[1] - 1
-        if X.shape[1] < 100:
-            n_segments = range(5, maxCoof, 5)
-        else:
-            n_segments = range(10, maxCoof, 10)
 
-        maxBin = 26
-        if X.shape[1] < maxBin:
-            maxBin = X.shape[1] - 2
-        if X.shape[0] < maxBin:
-            maxBin = X.shape[0] - 2
+        n_segments = range(3, maxCoof)
 
+        maxBin = 26
         alphas = range(3, maxBin)
 
         rng = check_random_state(self.random_state)
         lenses = np.transpose(
             [rng.choice(n_segments, size=n_lenses), rng.choice(alphas, size=n_lenses)]
         ).tolist()
+
         return lenses
 
     def _parallel_sax(self, sax_transforms, X):
@@ -633,6 +615,6 @@ class REDCOMETS(BaseClassifier):
             `params``.
         """
         return {
-            "variant": 1,
-            "n_trees": 1,
+            "variant": 3,
+            "n_trees": 3,
         }
diff --git a/aeon/clustering/base.py b/aeon/clustering/base.py
index 5e1b1472..c47d5e59 100644
--- a/aeon/clustering/base.py
+++ b/aeon/clustering/base.py
@@ -186,6 +186,9 @@ class BaseClusterer(BaseCollectionEstimator, ABC):
             (i, j)-th entry is predictive probability that i-th instance is of class j
         """
         preds = self._predict(X)
+        unique = np.unique(preds)
+        for i, u in enumerate(unique):
+            preds[preds == u] = i
         n_cases = len(preds)
         n_clusters = self.n_clusters
         if n_clusters is None:
diff --git a/aeon/clustering/feature_based/_catch22.py b/aeon/clustering/feature_based/_catch22.py
index 8f3c628e..eac0af37 100644
--- a/aeon/clustering/feature_based/_catch22.py
+++ b/aeon/clustering/feature_based/_catch22.py
@@ -202,8 +202,15 @@ class Catch22Clusterer(BaseClusterer):
             return self._estimator.predict_proba(self._transformer.transform(X))
         else:
             preds = self._estimator.predict(self._transformer.transform(X))
-            dists = np.zeros((X.shape[0], np.unique(preds).shape[0]))
-            for i in range(0, X.shape[0]):
+            unique = np.unique(preds)
+            for i, u in enumerate(unique):
+                preds[preds == u] = i
+            n_cases = len(preds)
+            n_clusters = self.n_clusters
+            if n_clusters is None:
+                n_clusters = int(max(preds)) + 1
+            dists = np.zeros((X.shape[0], n_clusters))
+            for i in range(n_cases):
                 dists[i, preds[i]] = 1
             return dists
 
diff --git a/aeon/clustering/feature_based/_summary.py b/aeon/clustering/feature_based/_summary.py
index 31b488ae..8c68142e 100644
--- a/aeon/clustering/feature_based/_summary.py
+++ b/aeon/clustering/feature_based/_summary.py
@@ -158,8 +158,15 @@ class SummaryClusterer(BaseClusterer):
             return self._estimator.predict_proba(self._transformer.transform(X))
         else:
             preds = self._estimator.predict(self._transformer.transform(X))
-            dists = np.zeros((X.shape[0], np.unique(preds).shape[0]))
-            for i in range(0, X.shape[0]):
+            unique = np.unique(preds)
+            for i, u in enumerate(unique):
+                preds[preds == u] = i
+            n_cases = len(preds)
+            n_clusters = self.n_clusters
+            if n_clusters is None:
+                n_clusters = int(max(preds)) + 1
+            dists = np.zeros((X.shape[0], n_clusters))
+            for i in range(n_cases):
                 dists[i, preds[i]] = 1
             return dists
 
diff --git a/aeon/clustering/feature_based/_tsfresh.py b/aeon/clustering/feature_based/_tsfresh.py
index cd77518b..d708afa6 100644
--- a/aeon/clustering/feature_based/_tsfresh.py
+++ b/aeon/clustering/feature_based/_tsfresh.py
@@ -182,8 +182,15 @@ class TSFreshClusterer(BaseClusterer):
             return self._estimator.predict_proba(self._transformer.transform(X))
         else:
             preds = self._estimator.predict(self._transformer.transform(X))
-            dists = np.zeros((X.shape[0], np.unique(preds).shape[0]))
-            for i in range(0, X.shape[0]):
+            unique = np.unique(preds)
+            for i, u in enumerate(unique):
+                preds[preds == u] = i
+            n_cases = len(preds)
+            n_clusters = self.n_clusters
+            if n_clusters is None:
+                n_clusters = int(max(preds)) + 1
+            dists = np.zeros((X.shape[0], n_clusters))
+            for i in range(n_cases):
                 dists[i, preds[i]] = 1
             return dists
 
diff --git a/aeon/networks/_ae_fcn.py b/aeon/networks/_ae_fcn.py
index 8693953c..37bbdf1a 100644
--- a/aeon/networks/_ae_fcn.py
+++ b/aeon/networks/_ae_fcn.py
@@ -56,6 +56,12 @@ class AEFCNNetwork(BaseDeepLearningNetwork):
     }
     """
 
+    _config = {
+        "python_dependencies": ["tensorflow"],
+        "python_version": "<3.12",
+        "structure": "auto-encoder",
+    }
+
     def __init__(
         self,
         latent_space_dim=128,
diff --git a/aeon/networks/_ae_resnet.py b/aeon/networks/_ae_resnet.py
index e66cec45..3b817efe 100644
--- a/aeon/networks/_ae_resnet.py
+++ b/aeon/networks/_ae_resnet.py
@@ -65,6 +65,12 @@ class AEResNetNetwork(BaseDeepLearningNetwork):
 
     """
 
+    _config = {
+        "python_dependencies": ["tensorflow"],
+        "python_version": "<3.12",
+        "structure": "auto-encoder",
+    }
+
     def __init__(
         self,
         latent_space_dim=128,
diff --git a/aeon/networks/_encoder.py b/aeon/networks/_encoder.py
index cc8dd072..6b40c17a 100644
--- a/aeon/networks/_encoder.py
+++ b/aeon/networks/_encoder.py
@@ -45,7 +45,11 @@ class EncoderNetwork(BaseDeepLearningNetwork):
 
     """
 
-    _tags = {"python_dependencies": ["tensorflow", "tensorflow_addons"]}
+    _config = {
+        "python_dependencies": ["tensorflow", "tensorflow-addons"],
+        "python_version": "<3.12",
+        "structure": "encoder",
+    }
 
     def __init__(
         self,
diff --git a/aeon/networks/base.py b/aeon/networks/base.py
index 4f09da11..aed3760b 100644
--- a/aeon/networks/base.py
+++ b/aeon/networks/base.py
@@ -28,9 +28,10 @@ class BaseDeepNetwork(BaseObject, ABC):
         super().__init__()
         _check_estimator_deps(self)
 
-    _tags = {
-        "python_dependencies": "tensorflow",
+    _config = {
+        "python_dependencies": ["tensorflow"],
         "python_version": "<3.12",
+        "structure": "encoder",
     }
 
     @abstractmethod
@@ -58,6 +59,12 @@ class BaseDeepLearningNetwork(ABC):
         _check_python_version(python_version)
         super().__init__()
 
+    _config = {
+        "python_dependencies": ["tensorflow"],
+        "python_version": "<3.12",
+        "structure": "encoder",
+    }
+
     @abstractmethod
     def build_network(self, input_shape, **kwargs):
         """Construct a network and return its input and output layers.


Test patch:
diff --git a/aeon/classification/dictionary_based/tests/test_redcomets.py b/aeon/classification/dictionary_based/tests/test_redcomets.py
index 5fa3273e..95258aad 100644
--- a/aeon/classification/dictionary_based/tests/test_redcomets.py
+++ b/aeon/classification/dictionary_based/tests/test_redcomets.py
@@ -22,19 +22,19 @@ def test_redcomets_score_univariate():
     X_train, y_train = load_unit_test(split="train")
     X_test, y_test = load_unit_test(split="test")
 
-    def test_variant(v):
+    def test_variant(v, expected_result):
         # train REDCOMETS-<v>
-        redcomets = REDCOMETS(variant=v, random_state=0)
+        redcomets = REDCOMETS(variant=v, n_trees=3, random_state=0)
         redcomets.fit(X_train, y_train)
 
         score = redcomets.score(X_test, y_test)
 
         assert isinstance(score, float)
-        np.testing.assert_almost_equal(score, 0.818181, decimal=4)
+        np.testing.assert_almost_equal(score, expected_result, decimal=4)
 
-    test_variant(1)
-    test_variant(2)
-    test_variant(3)
+    test_variant(1, 0.7272)
+    test_variant(2, 0.6818)
+    test_variant(3, 0.7272)
 
 
 @pytest.mark.skipif(
@@ -62,15 +62,14 @@ def test_redcomets_score_multivariate():
         np.testing.assert_almost_equal(score, expected_result, decimal=4)
 
     test_variant(1, 0.95)
-    test_variant(2, 0.95)
-    test_variant(3, 0.925)
-    test_variant(3, 0.925)
-    test_variant(4, 0.775)
-    test_variant(5, 0.8)
-    test_variant(6, 0.775)
-    test_variant(7, 0.775)
-    test_variant(8, 0.8)
-    test_variant(9, 0.8)
+    test_variant(2, 0.975)
+    test_variant(3, 0.975)
+    test_variant(4, 0.875)
+    test_variant(5, 0.875)
+    test_variant(6, 0.875)
+    test_variant(7, 0.875)
+    test_variant(8, 0.875)
+    test_variant(9, 0.875)
 
 
 @pytest.mark.skipif(
diff --git a/aeon/networks/tests/test_all_networks.py b/aeon/networks/tests/test_all_networks.py
index aa73e937..2100e488 100644
--- a/aeon/networks/tests/test_all_networks.py
+++ b/aeon/networks/tests/test_all_networks.py
@@ -2,33 +2,66 @@
 
 import inspect
 
+import pytest
+
 from aeon import networks
+from aeon.utils.validation._dependencies import (
+    _check_python_version,
+    _check_soft_dependencies,
+)
 
 __maintainer__ = []
 
+_networks = network_classes = [
+    member[1] for member in inspect.getmembers(networks, inspect.isclass)
+]
+
+
+@pytest.mark.parametrize("network", _networks)
+def test_network_config(network):
+    """Tests if the config dictionary of classes is correctly configured."""
+    assert "python_dependencies" in network._config.keys()
+    assert "python_version" in network._config.keys()
+    assert "structure" in network._config.keys()
+    assert isinstance(network._config["python_dependencies"], list) and (
+        "tensorflow" in network._config["python_dependencies"]
+    )
+    assert isinstance(network._config["python_version"], str)
+    assert isinstance(network._config["structure"], str)
 
-def test_all_networks_functionality():
+
+@pytest.mark.parametrize("network", _networks)
+def test_all_networks_functionality(network):
     """Test the functionality of all networks."""
-    network_classes = [
-        member[1] for member in inspect.getmembers(networks, inspect.isclass)
-    ]
     input_shape = (100, 2)
 
-    for i in range(len(network_classes)):
-        if (
-            "BaseDeepNetwork" in str(network_classes[i])
-            or "BaseDeepLearningNetwork" in str(network_classes[i])
-            or "AEFCNNetwork" in str(network_classes[i])
-            or "EncoderNetwork" in str(network_classes[i])
-        ):
-            continue
-
-        try:
-            my_network = network_classes[i]()
-        except ModuleNotFoundError:
-            continue
+    if not (
+        network.__name__
+        in ["BaseDeepNetwork", "BaseDeepLearningNetwork", "EncoderNetwork"]
+    ):
+        if _check_soft_dependencies(
+            network._config["python_dependencies"], severity="none"
+        ) and _check_python_version(network._config["python_version"], severity="none"):
+            my_network = network()
 
-        input_layer, output_layer = my_network.build_network(input_shape=input_shape)
+            if network._config["structure"] == "auto-encoder":
+                encoder, decoder = my_network.build_network(input_shape=input_shape)
+                assert encoder.output_shape[1:] == (my_network.latent_space_dim,)
+                assert encoder.input_shape == decoder.output_shape
+            elif network._config["structure"] == "encoder":
+                import tensorflow as tf
 
-        assert input_layer is not None
-        assert output_layer is not None
+                input_layer, output_layer = my_network.build_network(
+                    input_shape=input_shape
+                )
+                assert input_layer is not None
+                assert output_layer is not None
+                assert tf.keras.backend.is_keras_tensor(input_layer)
+                assert tf.keras.backend.is_keras_tensor(output_layer)
+        else:
+            pytest.skip(
+                f"{network.__name__} dependencies not satisfied or invalid \
+                Python version."
+            )
+    else:
+        pytest.skip(f"{network.__name__} not to be tested since its a base class.")
diff --git a/aeon/testing/expected_results/expected_classifier_outputs.py b/aeon/testing/expected_results/expected_classifier_outputs.py
index 7980775e..1a1432f5 100644
--- a/aeon/testing/expected_results/expected_classifier_outputs.py
+++ b/aeon/testing/expected_results/expected_classifier_outputs.py
@@ -51,20 +51,6 @@ unit_test_proba["MUSE"] = np.array(
         [0.9474, 0.0526],
     ]
 )
-unit_test_proba["REDCOMETS"] = np.array(
-    [
-        [0.0, 0.4, 0.2, 0.4],
-        [0.1, 0.5, 0.1, 0.3],
-        [0.2, 0.1, 0.7, 0.0],
-        [0.1, 0.6, 0.0, 0.3],
-        [0.2, 0.2, 0.2, 0.4],
-        [0.2, 0.2, 0.4, 0.2],
-        [0.1, 0.6, 0.2, 0.1],
-        [0.2, 0.2, 0.6, 0.0],
-        [0.2, 0.5, 0.0, 0.3],
-        [0.2, 0.4, 0.1, 0.3],
-    ]
-)
 unit_test_proba["BOSSEnsemble"] = np.array(
     [
         [0.0, 1.0],
@@ -137,15 +123,15 @@ unit_test_proba["WEASEL_V2"] = np.array(
 )
 unit_test_proba["REDCOMETS"] = np.array(
     [
-        [0.1429, 0.8571],
-        [0.6429, 0.3571],
-        [0.6429, 0.3571],
-        [1.0, 0.0],
-        [0.1429, 0.8571],
-        [1.0, 0.0],
-        [1.0, 0.0],
-        [0.1429, 0.8571],
-        [1.0, 0.0],
+        [0.0, 1.0],
+        [0.7619, 0.2381],
+        [0.0, 1.0],
+        [0.7619, 0.2381],
+        [0.3571, 0.6429],
+        [0.881, 0.119],
+        [0.7619, 0.2381],
+        [0.7619, 0.2381],
+        [0.881, 0.119],
         [1.0, 0.0],
     ]
 )
@@ -612,6 +598,20 @@ basic_motions_proba["TemporalDictionaryEnsemble"] = np.array(
         [0.0, 0.7478, 0.2522, 0.0],
     ]
 )
+basic_motions_proba["REDCOMETS"] = np.array(
+    [
+        [0.1005, 0.2374, 0.1416, 0.5205],
+        [0.1461, 0.274, 0.347, 0.2329],
+        [0.0548, 0.0959, 0.6119, 0.2374],
+        [0.032, 0.6895, 0.0868, 0.1918],
+        [0.1324, 0.2329, 0.0639, 0.5708],
+        [0.1187, 0.1507, 0.1689, 0.5616],
+        [0.3196, 0.2146, 0.0639, 0.4018],
+        [0.0913, 0.0, 0.5845, 0.3242],
+        [0.0, 0.7717, 0.0639, 0.1644],
+        [0.0457, 0.79, 0.0411, 0.1233],
+    ]
+)
 basic_motions_proba["ElasticEnsemble"] = np.array(
     [
         [0.0, 0.0, 0.0, 1.0],