#!/usr/bin/env python # coding: utf-8 # # In[19]: import warnings warnings.filterwarnings("ignore") from sklearn.linear_model import RidgeClassifierCV from sklearn.pipeline import make_pipeline from aeon.datasets import load_basic_motions from aeon.transformations.collection import channel_selection from aeon.transformations.collection.rocket import Rocket X_train, y_train = load_basic_motions(split="train") X_test, y_test = load_basic_motions(split="test") X_train.shape, X_test.shape # ## 1 Channel Selection in a Pipeline # # ``ElbowClassPairwise`` and ``ElbowClassSum`` are aeon transformers, so can be used in # a pipeline with other transformers and suitable classifiers. # In[15]: # cs = channel_selection.ElbowClassSum() # ECS cs = channel_selection.ElbowClassPairwise(prototype_type="mad") # ECP rocket_pipeline = make_pipeline(cs, Rocket(), RidgeClassifierCV()) # In[16]: rocket_pipeline.fit(X_train, y_train) rocket_pipeline.score(X_test, y_test) # ## 4 Identify channels selected # We can recover the selected channels from the transformer, and recover the centroids # uses in the selection process. We can of course do this directly from the transform # In[17]: X_selected = cs.fit(X_train, y_train) cs.channels_selected_idx # In[18]: cs.distance_frame # In[ ]: