.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/UCR_example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_UCR_example.py: Minimal example of RDST with visualisation ========================================== This example give the minimal setup to run RDST and visualize the result on a dataset from the UCR archive. .. GENERATED FROM PYTHON SOURCE LINES 12-17 Load the dataset and run RDST with Ridge ---------------------------------------- We load a UCR dataset with its name, and initialise RDST with a Ridge classifier using the wrapper class R_DST_Ridge. .. GENERATED FROM PYTHON SOURCE LINES 17-30 .. code-block:: default from convst.classifiers import R_DST_Ridge from convst.utils.dataset_utils import load_sktime_dataset_split X_train, X_test, y_train, y_test, _ = load_sktime_dataset_split('GunPoint') rdst = R_DST_Ridge(n_shapelets=10000, n_jobs=1) rdst.fit(X_train, y_train) acc_score = rdst.score(X_test, y_test) print("Accuracy Score for RDST : {}".format(acc_score)) .. GENERATED FROM PYTHON SOURCE LINES 31-39 Visualize the best shapelet of a class -------------------------------------- To visualize a shapelet, we use the dedicated interpreter class. It uses the coefficients from the Ridge classifier to select a shapelet that was important for the classification task for one class. We can then plot the distribution of features the shapelet generate for both the training and the testing set, too see if the distributions are alike. .. GENERATED FROM PYTHON SOURCE LINES 39-51 .. code-block:: default from convst.interpreters import RDST_Ridge_interpreter target_class = 1 interpreter = RDST_Ridge_interpreter(rdst) interpreter.visualize_best_shapelets_one_class( X_train, y_train, target_class, n_shp=1 ) interpreter.visualize_best_shapelets_one_class( X_test, y_test, target_class, n_shp=1 ) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_UCR_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: UCR_example.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: UCR_example.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_