.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/02_nbvfs/plot_05_fused_similarity.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_05_fused_similarity.py: Beyond the paper: fused similarities and pattern communities ============================================================= The paper closes with two open questions: how to *combine* similarity measures, and how to *segment* the network into groups. Here the confidence (tree structure), transaction (co-occurrence) and content (longest common subsequence) similarities are fused by similarity network fusion (Wang et al., 2014), and Louvain communities of the similarity graph are extracted. Each community is a candidate sub-process; its supporting traces form a sub-log. .. GENERATED FROM PYTHON SOURCE LINES 12-22 .. code-block:: Python import matplotlib.pyplot as plt import spmviz as sv from spmviz.networks import pattern_communities, sublogs from spmviz.viz import plot_communities, plot_transition_graph db = sv.datasets.make_alarm_cascades(600, random_state=0) ps = sv.mine(db, 0.05, max_length=5).filter(min_length=2) .. GENERATED FROM PYTHON SOURCE LINES 23-25 The fused map ------------- .. GENERATED FROM PYTHON SOURCE LINES 25-27 .. code-block:: Python fused = sv.NBVFS("fused").fit(ps) fused.plot(labels=14) .. image-sg:: /auto_examples/02_nbvfs/images/sphx_glr_plot_05_fused_similarity_001.png :alt: NBVFS fused-similarity MDS :srcset: /auto_examples/02_nbvfs/images/sphx_glr_plot_05_fused_similarity_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 28-30 Communities and sub-logs ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 30-37 .. code-block:: Python labels, modularity, G = pattern_communities(ps, similarity="transaction", knn=8) print(f"{labels.max() + 1} communities, modularity {modularity:.2f}") parts = sublogs(ps, labels) for c, sub in parts.items(): print(c, len(sub), "traces", sub.attributes["scenario"].value_counts().index[0]) plot_communities(ps, knn=8) .. image-sg:: /auto_examples/02_nbvfs/images/sphx_glr_plot_05_fused_similarity_002.png :alt: 5 pattern communities (modularity 0.78) :srcset: /auto_examples/02_nbvfs/images/sphx_glr_plot_05_fused_similarity_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 5 communities, modularity 0.78 0 42 traces pump+compressor 1 183 traces cooling 2 200 traces compressor 3 201 traces pump 4 209 traces separator .. GENERATED FROM PYTHON SOURCE LINES 38-40 One sub-log as a process map ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: Python plot_transition_graph(parts[0], top_edges=20, title="transition graph of the traces of community 1") .. image-sg:: /auto_examples/02_nbvfs/images/sphx_glr_plot_05_fused_similarity_003.png :alt: transition graph of the traces of community 1 :srcset: /auto_examples/02_nbvfs/images/sphx_glr_plot_05_fused_similarity_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 43-45 Parameter study: resolution --------------------------- .. GENERATED FROM PYTHON SOURCE LINES 45-49 .. code-block:: Python for r in (0.5, 1.0, 2.0): lab, mod, _ = pattern_communities(ps, knn=8, resolution=r) print(f"resolution {r}: {lab.max() + 1} communities, modularity {mod:.2f}") plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none resolution 0.5: 5 communities, modularity 0.78 resolution 1.0: 5 communities, modularity 0.78 resolution 2.0: 7 communities, modularity 0.73 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.688 seconds) .. _sphx_glr_download_auto_examples_02_nbvfs_plot_05_fused_similarity.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_05_fused_similarity.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_05_fused_similarity.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_05_fused_similarity.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_05_fused_similarity.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_