.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/07_applications/plot_01_benchmarks.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_07_applications_plot_01_benchmarks.py: Benchmark databases of sequential pattern mining ================================================ The databases distributed with SPMF (Fournier-Viger et al., 2016) are the common yardstick of the literature: SIGN (sign language), LEVIATHAN and BIBLE (text), BMS1/BMS2, FIFA and KOSARAK (click streams), BIKE (bike stations), MSNBC (page categories). :func:`~spmviz.datasets.fetch_spmf` downloads and caches them. Here SIGN is mined and drawn; the book reports run times on all of them. .. GENERATED FROM PYTHON SOURCE LINES 11-26 .. code-block:: Python import matplotlib.pyplot as plt import spmviz as sv from spmviz.viz import plot_nbvfs, plot_sunburst print(sv.datasets.benchmark_table()[["name", "sequences", "items", "avg_length"]]) try: db = sv.datasets.fetch_spmf("SIGN") except OSError as exc: # no network: fall back to a synthetic database of the same size print("download failed:", exc) db = sv.datasets.make_quest(730, n_items=267, avg_elements=52, avg_itemset=1.0, random_state=0) print(db.stats()) ps = sv.mine(db, min_support=0.5, max_length=5) print(ps) .. rst-class:: sphx-glr-script-out .. code-block:: none name sequences items avg_length 0 BIBLE 36369 13905.0 21.60 1 BMS1 59601 497.0 2.42 2 BMS2 77512 3340.0 4.62 3 FIFA 20450 2990.0 34.74 4 KOSARAK10K 10000 NaN NaN 5 LEVIATHAN 5834 9025.0 33.80 6 MSNBC 31790 17.0 13.23 7 SIGN 730 267.0 52.00 8 BIKE 21078 67.0 7.27 n_sequences 730.000000 n_items 267.000000 n_elements 37958.000000 avg_length 51.997260 min_length 18.000000 max_length 94.000000 avg_itemset_size 1.000000 avg_distinct_items 51.997260 density 0.194746 dtype: float64 PatternSet(n_patterns=173, algorithm='cmspam', min_support=0.5, n_sequences=730) .. GENERATED FROM PYTHON SOURCE LINES 27-29 Maps of the frequent sequences ------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 29-34 .. code-block:: Python fig, axes = plt.subplots(1, 2, figsize=(14, 6)) plot_nbvfs(sv.NBVFS("cm").fit(ps.filter(min_length=2)), ax=axes[0], legend=False, labels=10) plot_sunburst(db, ax=axes[1], max_depth=3, min_angle=8, title="first three signs") axes[1].get_legend().remove() plt.show() .. image-sg:: /auto_examples/07_applications/images/sphx_glr_plot_01_benchmarks_001.png :alt: NBVFS-CM confidence-based MDS, first three signs :srcset: /auto_examples/07_applications/images/sphx_glr_plot_01_benchmarks_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.332 seconds) .. _sphx_glr_download_auto_examples_07_applications_plot_01_benchmarks.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/07_applications/plot_01_benchmarks.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_benchmarks.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_benchmarks.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_benchmarks.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_