.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/02_nbvfs/plot_03_transaction_mds.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_02_nbvfs_plot_03_transaction_mds.py: NBVFS-TM: transaction-based MDS map ==================================== The third map ignores the tree structure: two sequences are similar when they are supported by the same traces (Jaccard similarity of their supporting sequence sets). Groups of sequences that occur together — the events of a sub-process running in parallel with others — form clusters. The synthetic alarm floods below interleave cascades of four sub-processes (pump, cooling, compressor, separator) with nuisance alarms; the TM map separates the four cascades without knowing them. .. GENERATED FROM PYTHON SOURCE LINES 13-18 .. code-block:: Python import matplotlib.pyplot as plt import spmviz as sv .. GENERATED FROM PYTHON SOURCE LINES 19-21 Interleaved alarm cascades -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 21-26 .. code-block:: Python db = sv.datasets.make_alarm_cascades(600, random_state=0) print(db.attributes["scenario"].value_counts().head()) ps = sv.mine(db, min_support=0.05, max_length=5) tm = sv.NBVFS("tm").fit(ps) tm.plot(labels=14) .. image-sg:: /auto_examples/02_nbvfs/images/sphx_glr_plot_03_transaction_mds_001.png :alt: NBVFS-TM transaction-based MDS :srcset: /auto_examples/02_nbvfs/images/sphx_glr_plot_03_transaction_mds_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none scenario separator 114 pump 110 compressor 92 cooling 90 cooling+separator 27 Name: count, dtype: int64 .. GENERATED FROM PYTHON SOURCE LINES 27-29 The same map for the cooling cascade only ----------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 29-32 .. code-block:: Python tm.plot(start_items=["C-HITEMP", "C-HIPRES", "C-VALVE", "OP-COOLADJ"], labels=10, title="NBVFS-TM, sequences of the cooling sub-process highlighted") .. image-sg:: /auto_examples/02_nbvfs/images/sphx_glr_plot_03_transaction_mds_002.png :alt: NBVFS-TM, sequences of the cooling sub-process highlighted :srcset: /auto_examples/02_nbvfs/images/sphx_glr_plot_03_transaction_mds_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 33-37 Parameter study: the minimum support ------------------------------------ Lower supports add rare combinations (cascades mixed with nuisance alarms) between the clusters; higher supports keep only the cores. .. GENERATED FROM PYTHON SOURCE LINES 37-42 .. code-block:: Python fig, axes = plt.subplots(1, 3, figsize=(15, 4.6)) for ax, ms in zip(axes, (0.03, 0.06, 0.12)): p = sv.mine(db, ms, max_length=5) sv.NBVFS("tm").fit(p).plot(ax=ax, legend=False, labels=0, title=f"min support {ms}: {len(p)} sequences") plt.show() .. image-sg:: /auto_examples/02_nbvfs/images/sphx_glr_plot_03_transaction_mds_003.png :alt: min support 0.03: 344 sequences, min support 0.06: 75 sequences, min support 0.12: 61 sequences :srcset: /auto_examples/02_nbvfs/images/sphx_glr_plot_03_transaction_mds_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.629 seconds) .. _sphx_glr_download_auto_examples_02_nbvfs_plot_03_transaction_mds.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/spmviz/main?urlpath=lab/tree/notebooks/auto_examples/02_nbvfs/plot_03_transaction_mds.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_transaction_mds.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_transaction_mds.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_transaction_mds.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_