[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.convolution_based 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
[19]:
((40, 6, 100), (40, 6, 100))
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.
[15]:
# cs = channel_selection.ElbowClassSum() # ECS
cs = channel_selection.ElbowClassPairwise(prototype_type="mad") # ECP
rocket_pipeline = make_pipeline(cs, Rocket(), RidgeClassifierCV())
[16]:
rocket_pipeline.fit(X_train, y_train)
rocket_pipeline.score(X_test, y_test)
[16]:
1.0
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
[17]:
X_selected = cs.fit(X_train, y_train)
cs.channels_selected_
[17]:
[0, 1]
[18]:
cs.distance_frame
[18]:
| Centroid_badminton_running | Centroid_badminton_standing | Centroid_badminton_walking | Centroid_running_standing | Centroid_running_walking | Centroid_standing_walking | |
|---|---|---|---|---|---|---|
| 0 | 72.883920 | 37.486167 | 32.843063 | 95.139594 | 89.360656 | 9.786164 |
| 1 | 82.974076 | 19.586588 | 28.068407 | 87.661718 | 89.326726 | 21.778564 |
| 2 | 21.381712 | 18.196532 | 17.131596 | 26.885354 | 24.524588 | 4.834320 |
| 3 | 11.289843 | 9.402970 | 9.932407 | 7.750558 | 8.613671 | 3.744539 |
| 4 | 8.140510 | 6.623146 | 6.877631 | 6.112858 | 6.304372 | 1.546983 |
| 5 | 29.041896 | 9.025905 | 12.876751 | 27.785727 | 28.527294 | 9.650223 |
[ ]:
Generated using nbsphinx. The Jupyter notebook can be found here.