.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/transformation/plot_rocket.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_transformation_plot_rocket.py: ============================================== RandOm Convolutional KErnel Transform (ROCKET) ============================================== The RandOm Convolutional KErnel Transform (ROCKET) algorithm randomly generates a great variety of convolutional kernels and extracts two features for each convolution: the maximum and the proportion of positive values. This example illustrates basic usage of this algorithm and plots the weights of the most relevant kernels according to mutual information. It is implemented as :class:`pyts.transformation.ROCKET`. .. GENERATED FROM PYTHON SOURCE LINES 14-46 .. image-sg:: /auto_examples/transformation/images/sphx_glr_plot_rocket_001.png :alt: Weights of the four most discriminative kernels (criterion: mutual information) :srcset: /auto_examples/transformation/images/sphx_glr_plot_rocket_001.png :class: sphx-glr-single-img .. code-block:: default # Author: Johann Faouzi # License: BSD-3-Clause import numpy as np import matplotlib.pyplot as plt from pyts.datasets import load_gunpoint from pyts.transformation import ROCKET from sklearn.feature_selection import mutual_info_classif # Toy dataset X, _, y, _ = load_gunpoint(return_X_y=True) # ROCKET transformation rocket = ROCKET(n_kernels=500, random_state=42) X_rocket = rocket.fit_transform(X) # Find the most discriminative kernels n_kernels = 4 mutual_info = mutual_info_classif(X_rocket, y, random_state=42) indices = np.floor_divide(np.argsort(mutual_info), 2)[-n_kernels:] # Visualize the weights of the most discriminative kernels plt.figure(figsize=(8, 4)) for idx in indices: plt.plot(rocket.weights_[idx, :rocket.length_[idx]], 'o-', label='Kernel {}'.format(idx)) plt.legend(loc='best') plt.title('Weights of the four most discriminative kernels \n' '(criterion: mutual information)', fontsize=14) plt.xticks([]) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 6.466 seconds) .. _sphx_glr_download_auto_examples_transformation_plot_rocket.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_rocket.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_rocket.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_