.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/09_visualization/plot_01_dashboard.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 or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_09_visualization_plot_01_dashboard.py: A one-page segmentation report ============================== A segmentation is only useful if it can be explained. The dashboard combines the segmented series, the timeline of states, the cost curve of the merge hierarchy and the contributions of the variables to every change (shifts of the mean, the variance and the correlation). The segment table summarizes every segment by its statistics and principal directions. .. GENERATED FROM PYTHON SOURCE LINES 11-23 .. code-block:: Python import matplotlib.pyplot as plt import mvtsa as mv from mvtsa import segmentation as sg from mvtsa.explain import boundary_contributions, describe_segments X, cps, states = mv.datasets.make_regime_process( n_regimes=3, n_segments=6, length=150, random_state=4 ) names = ["temperature", "pressure", "flow", "level"] .. GENERATED FROM PYTHON SOURCE LINES 24-26 The dashboard ------------- .. GENERATED FROM PYTHON SOURCE LINES 26-32 .. code-block:: Python st = sg.StateSegmenter( segmenter=sg.BottomUp("normal", n_segments=6, initial_size=15), n_states=3 ) seg = st.segment(X) tree = sg.BottomUp("normal", initial_size=15).full_tree(X) mv.viz.segmentation_dashboard(X, seg, names=names, truth=cps, tree=tree) .. image-sg:: /auto_examples/09_visualization/images/sphx_glr_plot_01_dashboard_001.png :alt: plot 01 dashboard :srcset: /auto_examples/09_visualization/images/sphx_glr_plot_01_dashboard_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 33-35 Which variables changed? ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: Python print(boundary_contributions(X, seg, kind="all", names=names).round(2)) print(describe_segments(X, seg, names=names).round(2).iloc[:, :8]) plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none temperature pressure flow level change_point 195 0.21 0.17 0.37 0.26 330 0.41 0.32 0.10 0.17 525 0.18 0.22 0.32 0.28 630 0.20 0.16 0.36 0.28 780 0.35 0.27 0.11 0.27 segment start ... std_temperature slope_temperature 0 0 0 ... 0.81 -0.00 1 1 195 ... 0.64 0.00 2 2 330 ... 1.09 -0.00 3 3 525 ... 0.92 -0.01 4 4 630 ... 0.70 0.00 5 5 780 ... 0.92 0.00 [6 rows x 8 columns] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.152 seconds) .. _sphx_glr_download_auto_examples_09_visualization_plot_01_dashboard.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/mvtsa/main?urlpath=lab/tree/notebooks/auto_examples/09_visualization/plot_01_dashboard.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_dashboard.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_dashboard.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_dashboard.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_