.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/05_maps/plot_01_incidence_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_05_maps_plot_01_incidence_similarity.py: Matrices of a pattern set ========================= The pattern–sequence incidence matrix :math:`\mathbf{T}` (patterns in rows, supporting sequences in columns) is the data behind the transaction map. Seriated by hierarchical clustering, its blocks are groups of patterns supported by the same traces. The seriated similarity matrix with its dendrogram shows the same groups as a square heatmap. .. GENERATED FROM PYTHON SOURCE LINES 11-21 .. code-block:: Python import matplotlib.pyplot as plt import spmviz as sv from spmviz.viz import plot_incidence, plot_similarity_matrix db = sv.datasets.make_alarm_cascades(600, random_state=0) ps = sv.mine(db, 0.08, max_length=4) plot_incidence(ps, top=40) plot_similarity_matrix(ps, "transaction", top=40) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/05_maps/images/sphx_glr_plot_01_incidence_similarity_001.png :alt: pattern–sequence incidence matrix :srcset: /auto_examples/05_maps/images/sphx_glr_plot_01_incidence_similarity_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/05_maps/images/sphx_glr_plot_01_incidence_similarity_002.png :alt: transaction similarity of 40 patterns :srcset: /auto_examples/05_maps/images/sphx_glr_plot_01_incidence_similarity_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 22-25 Content instead of co-occurrence -------------------------------- The longest-common-subsequence similarity groups patterns that *look* alike. .. GENERATED FROM PYTHON SOURCE LINES 25-27 .. code-block:: Python plot_similarity_matrix(ps, "content", top=40) plt.show() .. image-sg:: /auto_examples/05_maps/images/sphx_glr_plot_01_incidence_similarity_003.png :alt: content similarity of 40 patterns :srcset: /auto_examples/05_maps/images/sphx_glr_plot_01_incidence_similarity_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.593 seconds) .. _sphx_glr_download_auto_examples_05_maps_plot_01_incidence_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/05_maps/plot_01_incidence_similarity.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_incidence_similarity.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_incidence_similarity.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_incidence_similarity.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_