.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/multivariate/plot_weasel_muse.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_multivariate_plot_weasel_muse.py: =========== WEASEL+MUSE =========== WEASELMUSE stand for Word ExtrAction for time SEries cLassification plus Multivariate Unsupervised Symbols and dErivatives. This example shows how the WEASELMUSE algorithm transforms multivariate time series of real numbers into a sequence of frequencies of words, and illustrates the features obtained for two time series. It is implemented as :class:`pyts.multivariate.transformation.WEASELMUSE`. .. GENERATED FROM PYTHON SOURCE LINES 13-55 .. image-sg:: /auto_examples/multivariate/images/sphx_glr_plot_weasel_muse_001.png :alt: WEASEL+MUSE transformation :srcset: /auto_examples/multivariate/images/sphx_glr_plot_weasel_muse_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_basic_motions from pyts.multivariate.transformation import WEASELMUSE from sklearn.preprocessing import LabelEncoder # Toy dataset X_train, _, y_train, _ = load_basic_motions(return_X_y=True) y_train = LabelEncoder().fit_transform(y_train) # WEASEL+MUSE transformation transformer = WEASELMUSE(word_size=2, n_bins=2, window_sizes=[12, 36], chi2_threshold=15, sparse=False) X_weasel = transformer.fit_transform(X_train, y_train) # Visualize the transformation for the first time series plt.figure(figsize=(6, 4)) vocabulary_length = len(transformer.vocabulary_) width = 0.3 plt.bar(np.arange(vocabulary_length) - width / 2, X_weasel[y_train == 0][0], width=width, label='First time series in class 0') plt.bar(np.arange(vocabulary_length) + width / 2, X_weasel[y_train == 1][0], width=width, label='First time series in class 1') plt.xticks(np.arange(vocabulary_length), np.vectorize(transformer.vocabulary_.get)( np.arange(X_weasel[0].size)), fontsize=12, rotation=60, ha='right') y_max = np.max(np.concatenate([X_weasel[y_train == 0][0], X_weasel[y_train == 1][0]])) plt.yticks(np.arange(y_max + 1), fontsize=12) plt.xlabel("Words", fontsize=14) plt.ylabel("Frequencies", fontsize=14) plt.title("WEASEL+MUSE transformation", fontsize=16) plt.legend(loc='best', fontsize=10) plt.subplots_adjust(bottom=0.27) plt.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.276 seconds) .. _sphx_glr_download_auto_examples_multivariate_plot_weasel_muse.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_weasel_muse.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_weasel_muse.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_