spmviz 1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. spmviz-1.0/.gitignore +48 -0
  2. spmviz-1.0/CHANGELOG.md +14 -0
  3. spmviz-1.0/CITATION.cff +38 -0
  4. spmviz-1.0/LICENSE +21 -0
  5. spmviz-1.0/PKG-INFO +189 -0
  6. spmviz-1.0/README.md +89 -0
  7. spmviz-1.0/examples/01_basics/README.rst +2 -0
  8. spmviz-1.0/examples/01_basics/plot_01_first_steps.py +56 -0
  9. spmviz-1.0/examples/01_basics/plot_02_daily_routines.py +50 -0
  10. spmviz-1.0/examples/01_basics/plot_03_algorithms.py +63 -0
  11. spmviz-1.0/examples/01_basics/plot_04_constraints.py +41 -0
  12. spmviz-1.0/examples/01_basics/plot_05_import_export.py +58 -0
  13. spmviz-1.0/examples/02_nbvfs/README.rst +2 -0
  14. spmviz-1.0/examples/02_nbvfs/plot_01_weighted_network.py +56 -0
  15. spmviz-1.0/examples/02_nbvfs/plot_02_confidence_mds.py +50 -0
  16. spmviz-1.0/examples/02_nbvfs/plot_03_transaction_mds.py +44 -0
  17. spmviz-1.0/examples/02_nbvfs/plot_04_alarm_log.py +44 -0
  18. spmviz-1.0/examples/02_nbvfs/plot_05_fused_similarity.py +53 -0
  19. spmviz-1.0/examples/03_trees/README.rst +2 -0
  20. spmviz-1.0/examples/03_trees/plot_01_chess_sunburst.py +43 -0
  21. spmviz-1.0/examples/03_trees/plot_02_entropy_tree.py +36 -0
  22. spmviz-1.0/examples/03_trees/plot_03_word_tree.py +32 -0
  23. spmviz-1.0/examples/03_trees/plot_04_contrast_tree.py +32 -0
  24. spmviz-1.0/examples/03_trees/plot_05_lifeflow_icicle.py +28 -0
  25. spmviz-1.0/examples/04_flows/README.rst +2 -0
  26. spmviz-1.0/examples/04_flows/plot_01_sankey.py +34 -0
  27. spmviz-1.0/examples/04_flows/plot_02_transition_graph.py +40 -0
  28. spmviz-1.0/examples/04_flows/plot_03_chord.py +26 -0
  29. spmviz-1.0/examples/04_flows/plot_04_growth_sankey.py +27 -0
  30. spmviz-1.0/examples/04_flows/plot_05_higher_order_network.py +45 -0
  31. spmviz-1.0/examples/05_maps/README.rst +2 -0
  32. spmviz-1.0/examples/05_maps/plot_01_incidence_similarity.py +30 -0
  33. spmviz-1.0/examples/05_maps/plot_02_rules_matrix.py +29 -0
  34. spmviz-1.0/examples/05_maps/plot_03_measure_scatter.py +24 -0
  35. spmviz-1.0/examples/05_maps/plot_04_landscape.py +29 -0
  36. spmviz-1.0/examples/05_maps/plot_05_lattice_upset.py +23 -0
  37. spmviz-1.0/examples/06_sequences/README.rst +2 -0
  38. spmviz-1.0/examples/06_sequences/plot_01_index_plot.py +28 -0
  39. spmviz-1.0/examples/06_sequences/plot_02_chronogram_frequency.py +23 -0
  40. spmviz-1.0/examples/06_sequences/plot_03_dotted_chart.py +27 -0
  41. spmviz-1.0/examples/06_sequences/plot_04_sequence_logo.py +27 -0
  42. spmviz-1.0/examples/06_sequences/plot_05_arc_diagram.py +29 -0
  43. spmviz-1.0/examples/06_sequences/plot_06_episodes.py +37 -0
  44. spmviz-1.0/examples/06_sequences/plot_07_mdl_summary.py +31 -0
  45. spmviz-1.0/examples/07_applications/README.rst +2 -0
  46. spmviz-1.0/examples/07_applications/plot_01_benchmarks.py +37 -0
  47. spmviz-1.0/examples/07_applications/plot_02_clickstream_story.py +41 -0
  48. spmviz-1.0/examples/07_applications/plot_03_alarm_early_warning.py +51 -0
  49. spmviz-1.0/examples/07_applications/plot_04_interactive.py +30 -0
  50. spmviz-1.0/examples/README.rst +10 -0
  51. spmviz-1.0/pyproject.toml +84 -0
  52. spmviz-1.0/src/spmviz/__init__.py +80 -0
  53. spmviz-1.0/src/spmviz/backends.py +168 -0
  54. spmviz-1.0/src/spmviz/data.py +835 -0
  55. spmviz-1.0/src/spmviz/datasets/__init__.py +54 -0
  56. spmviz-1.0/src/spmviz/datasets/_bundled.py +174 -0
  57. spmviz-1.0/src/spmviz/datasets/data/README.md +10 -0
  58. spmviz-1.0/src/spmviz/datasets/data/alarm_log.csv.gz +0 -0
  59. spmviz-1.0/src/spmviz/datasets/data/chess_openings.json +200 -0
  60. spmviz-1.0/src/spmviz/datasets/data/clickstream.csv.gz +0 -0
  61. spmviz-1.0/src/spmviz/datasets/data/melodies.json +139 -0
  62. spmviz-1.0/src/spmviz/datasets/fetch.py +130 -0
  63. spmviz-1.0/src/spmviz/datasets/generators.py +219 -0
  64. spmviz-1.0/src/spmviz/embedding.py +246 -0
  65. spmviz-1.0/src/spmviz/interactive.py +221 -0
  66. spmviz-1.0/src/spmviz/io.py +453 -0
  67. spmviz-1.0/src/spmviz/layout.py +197 -0
  68. spmviz-1.0/src/spmviz/measures.py +366 -0
  69. spmviz-1.0/src/spmviz/mining/__init__.py +27 -0
  70. spmviz-1.0/src/spmviz/mining/_common.py +62 -0
  71. spmviz-1.0/src/spmviz/mining/api.py +128 -0
  72. spmviz-1.0/src/spmviz/mining/episodes.py +268 -0
  73. spmviz-1.0/src/spmviz/mining/gsp.py +116 -0
  74. spmviz-1.0/src/spmviz/mining/postprocess.py +76 -0
  75. spmviz-1.0/src/spmviz/mining/prefixspan.py +231 -0
  76. spmviz-1.0/src/spmviz/mining/rules.py +74 -0
  77. spmviz-1.0/src/spmviz/mining/spade.py +109 -0
  78. spmviz-1.0/src/spmviz/mining/spam.py +252 -0
  79. spmviz-1.0/src/spmviz/nbvfs.py +204 -0
  80. spmviz-1.0/src/spmviz/networks.py +513 -0
  81. spmviz-1.0/src/spmviz/patterns.py +428 -0
  82. spmviz-1.0/src/spmviz/predict.py +85 -0
  83. spmviz-1.0/src/spmviz/summary.py +204 -0
  84. spmviz-1.0/src/spmviz/viz/__init__.py +93 -0
  85. spmviz-1.0/src/spmviz/viz/_style.py +154 -0
  86. spmviz-1.0/src/spmviz/viz/dashboard.py +37 -0
  87. spmviz-1.0/src/spmviz/viz/flows.py +415 -0
  88. spmviz-1.0/src/spmviz/viz/matrices.py +191 -0
  89. spmviz-1.0/src/spmviz/viz/nbvfs.py +198 -0
  90. spmviz-1.0/src/spmviz/viz/patterns.py +100 -0
  91. spmviz-1.0/src/spmviz/viz/projections.py +202 -0
  92. spmviz-1.0/src/spmviz/viz/sequences.py +435 -0
  93. spmviz-1.0/src/spmviz/viz/sets.py +139 -0
  94. spmviz-1.0/src/spmviz/viz/trees.py +442 -0
  95. spmviz-1.0/tests/conftest.py +39 -0
  96. spmviz-1.0/tests/test_data.py +123 -0
  97. spmviz-1.0/tests/test_datasets_backends.py +79 -0
  98. spmviz-1.0/tests/test_mining.py +168 -0
  99. spmviz-1.0/tests/test_nbvfs_io.py +136 -0
  100. spmviz-1.0/tests/test_networks_embedding.py +128 -0
  101. spmviz-1.0/tests/test_patterns_measures.py +83 -0
  102. spmviz-1.0/tests/test_summary_predict_viz.py +94 -0
spmviz-1.0/.gitignore ADDED
@@ -0,0 +1,48 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ docs/_build/
9
+ docs/auto_examples/
10
+ docs/gen_modules/
11
+ docs/sg_execution_times.rst
12
+ book/figures/
13
+ book/*.aux
14
+ book/*.log
15
+ book/*.out
16
+ book/*.toc
17
+ book/*.bbl
18
+ book/*.bcf
19
+ book/*.blg
20
+ book/*.run.xml
21
+ book/*.idx
22
+ book/*.ilg
23
+ book/*.ind
24
+ book/*.fls
25
+ book/*.fdb_latexmk
26
+ book/*.synctex.gz
27
+ book/main.pdf
28
+ *.ipynb_checkpoints
29
+ book/_check_tmp/
30
+ book/_check.tex
31
+ docs/_build/
32
+ docs/api/generated/
33
+ docs/_build_log.txt
34
+ book/_build/
35
+ .coverage
36
+ book/_build_new/
37
+ book/_check_*.tex
38
+ book/cover/*.aux
39
+ book/cover/*.log
40
+ book/cover/*.fls
41
+ book/cover/*.fdb_latexmk
42
+ book/cover/*.pdf
43
+ book/cover/*.png
44
+ book/cover/logo.svg
45
+ *.blg
46
+ book/_build_epub/
47
+ book/_build_web/
48
+ docs/_gallery_src/
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## 1.0 (2026-11-29) — first release
4
+
5
+ * The network-based visualization of frequent sequences of Bántay and Abonyi (PLOS ONE 19(5): e0301262, 2024) as an estimator, `NBVFS`: the weighted extension network (WN, radial and hierarchical layouts, confidence pruning), the confidence-based map (CM, max-product closure) and the transaction-based map (TM, Jaccard similarity), embedded by SMACOF or classical scaling with their stress. The two logs of the paper are bundled.
6
+ * New: a fused map (similarity network fusion of the confidence, transaction and content similarities), Louvain pattern communities and their sub-logs.
7
+ * Five sequential pattern miners in pure Python — PrefixSpan, SPAM, CM-SPAM, SPADE and GSP — with gap, span and time constraints, itemsets and timestamps; closed, maximal and generator patterns; top-k mining; sequential rules; WINEPI/MINEPI episodes. All miners return identical results, checked against brute-force enumeration.
8
+ * Adapters to the `prefixspan`, `seq2pat` and `gsppy` packages and to the SPMF Java library.
9
+ * Nearly forty static views (`spmviz.viz`): glyph tables, prefix and pattern trees, sunbursts, icicles, LifeFlow, double trees, Sankey diagrams, directly-follows graphs, transition matrices, MatrixWave, chord diagrams, incidence and similarity matrices, grouped rule matrices, measure scatter plots, lattices, UpSet plots, sequence index plots, chronograms, sequence frequency plots, dotted charts, sequence logos, arc diagrams, episode timelines, MDL cover plots, prediction views and an overview dashboard; interactive plotly and pyvis twins (`spmviz.interactive`).
10
+ * New views: the continuation-entropy tree, the contrast sunburst with emerging-pattern statistics, the growth Sankey of the extension tree, pattern-induced higher-order networks (BuildHON with a support-dependent KL threshold) and pattern landscapes.
11
+ * MDL summaries of contiguous patterns and next-event prediction from the longest matching frequent sequence.
12
+ * Data exchange (`spmviz.io`): pandas event logs, wide tables, strings, SPMF, XES and pm4py in; pandas, CSV, JSON, Excel, SPMF, XES out; every graph as NetworkX with export to GEXF (Gephi), GraphML, GML, Cytoscape JSON, node-link JSON, DOT, Pajek and igraph.
13
+ * Data sets: the UWV click-stream (BPI Challenge 2016) and the alkylation-plant alarm log of the paper, the PrefixSpan and Agrawal–Srikant textbook databases, melodies, chess openings, generators of daily routines, web-shop journeys, alarm cascades and planted patterns, and a downloader of nine SPMF benchmark databases.
14
+ * 36 gallery examples, Sphinx documentation and the companion book (PDF, EPUB and web edition) *Mining and Visualizing Frequent Sequences in Python*.
@@ -0,0 +1,38 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use spmviz, please cite it as below, together with the original publications of the methods you use."
3
+ type: software
4
+ title: "spmviz: mining and visualizing frequent sequences in Python"
5
+ version: "1.0"
6
+ date-released: 2026-11-29
7
+ license: MIT
8
+ repository-code: "https://github.com/ComplexSystemsIntelligence/spmviz"
9
+ url: "https://complexsystemsintelligence.github.io/spmviz"
10
+ authors:
11
+ - family-names: Abonyi
12
+ given-names: János
13
+ affiliation: "University of Pannonia, Veszprém, Hungary"
14
+ orcid: "https://orcid.org/0000-0001-8593-1493"
15
+ - family-names: Bántay
16
+ given-names: László
17
+ affiliation: "University of Pannonia, Veszprém, Hungary"
18
+ keywords:
19
+ - sequential pattern mining
20
+ - frequent sequences
21
+ - visualization
22
+ - network-based visualization
23
+ - event logs
24
+ - process mining
25
+ references:
26
+ - type: article
27
+ title: "Network-based visualisation of frequent sequences"
28
+ authors:
29
+ - family-names: Bántay
30
+ given-names: László
31
+ - family-names: Abonyi
32
+ given-names: János
33
+ journal: "PLOS ONE"
34
+ volume: 19
35
+ issue: 5
36
+ start: e0301262
37
+ year: 2024
38
+ doi: 10.1371/journal.pone.0301262
spmviz-1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 János Abonyi, László Bántay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
spmviz-1.0/PKG-INFO ADDED
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.5
2
+ Name: spmviz
3
+ Version: 1.0
4
+ Summary: Mining and visualization of frequent sequential patterns: network-based NBVFS maps, prefix trees, sunbursts, Sankey and transition diagrams, matrix views, lattices, sequence plots, MDL summaries and higher-order networks, with export to networkx, GEXF, GraphML, Cytoscape and SPMF.
5
+ Project-URL: Homepage, https://github.com/ComplexSystemsIntelligence/spmviz
6
+ Project-URL: Documentation, https://complexsystemsintelligence.github.io/spmviz
7
+ Project-URL: Repository, https://github.com/ComplexSystemsIntelligence/spmviz
8
+ Project-URL: Issues, https://github.com/ComplexSystemsIntelligence/spmviz/issues
9
+ Project-URL: Changelog, https://github.com/ComplexSystemsIntelligence/spmviz/blob/main/CHANGELOG.md
10
+ Project-URL: Book (PDF), https://complexsystemsintelligence.github.io/spmviz/spmviz-book.pdf
11
+ Author: László Bántay
12
+ Author-email: János Abonyi <janos@abonyilab.com>
13
+ License-Expression: MIT
14
+ License-File: LICENSE
15
+ Keywords: CM-SPAM,PrefixSpan,alarm management,clickstream,event sequences,frequent sequences,network visualization,process mining,sequential pattern mining,visualization
16
+ Classifier: Development Status :: 5 - Production/Stable
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Topic :: Scientific/Engineering
26
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
27
+ Classifier: Topic :: Scientific/Engineering :: Visualization
28
+ Requires-Python: >=3.10
29
+ Requires-Dist: matplotlib>=3.7
30
+ Requires-Dist: networkx>=3.0
31
+ Requires-Dist: numpy>=1.24
32
+ Requires-Dist: pandas>=2.0
33
+ Requires-Dist: scipy>=1.11
34
+ Provides-Extra: all
35
+ Requires-Dist: gsppy>=3.0; extra == 'all'
36
+ Requires-Dist: igraph>=0.11; extra == 'all'
37
+ Requires-Dist: openpyxl>=3.1; extra == 'all'
38
+ Requires-Dist: plotly>=5.15; extra == 'all'
39
+ Requires-Dist: pm4py>=2.7; extra == 'all'
40
+ Requires-Dist: prefixspan>=0.5; extra == 'all'
41
+ Requires-Dist: pyvis>=0.3; extra == 'all'
42
+ Requires-Dist: scikit-learn>=1.3; extra == 'all'
43
+ Requires-Dist: seq2pat>=1.4; extra == 'all'
44
+ Provides-Extra: backends
45
+ Requires-Dist: gsppy>=3.0; extra == 'backends'
46
+ Requires-Dist: prefixspan>=0.5; extra == 'backends'
47
+ Requires-Dist: seq2pat>=1.4; extra == 'backends'
48
+ Provides-Extra: book
49
+ Requires-Dist: beautifulsoup4>=4.12; extra == 'book'
50
+ Requires-Dist: lxml; extra == 'book'
51
+ Requires-Dist: pillow; extra == 'book'
52
+ Requires-Dist: plotly>=5.15; extra == 'book'
53
+ Provides-Extra: dev
54
+ Requires-Dist: build; extra == 'dev'
55
+ Requires-Dist: gsppy>=3.0; extra == 'dev'
56
+ Requires-Dist: igraph>=0.11; extra == 'dev'
57
+ Requires-Dist: myst-parser; extra == 'dev'
58
+ Requires-Dist: numpydoc; extra == 'dev'
59
+ Requires-Dist: openpyxl>=3.1; extra == 'dev'
60
+ Requires-Dist: plotly>=5.15; extra == 'dev'
61
+ Requires-Dist: pm4py>=2.7; extra == 'dev'
62
+ Requires-Dist: prefixspan>=0.5; extra == 'dev'
63
+ Requires-Dist: pydata-sphinx-theme; extra == 'dev'
64
+ Requires-Dist: pytest-cov; extra == 'dev'
65
+ Requires-Dist: pytest>=7; extra == 'dev'
66
+ Requires-Dist: pyvis>=0.3; extra == 'dev'
67
+ Requires-Dist: ruff; extra == 'dev'
68
+ Requires-Dist: scikit-learn>=1.3; extra == 'dev'
69
+ Requires-Dist: seq2pat>=1.4; extra == 'dev'
70
+ Requires-Dist: sphinx-copybutton; extra == 'dev'
71
+ Requires-Dist: sphinx-design; extra == 'dev'
72
+ Requires-Dist: sphinx-gallery>=0.15; extra == 'dev'
73
+ Requires-Dist: sphinx>=7; extra == 'dev'
74
+ Requires-Dist: twine; extra == 'dev'
75
+ Provides-Extra: docs
76
+ Requires-Dist: myst-parser; extra == 'docs'
77
+ Requires-Dist: numpydoc; extra == 'docs'
78
+ Requires-Dist: openpyxl>=3.1; extra == 'docs'
79
+ Requires-Dist: plotly>=5.15; extra == 'docs'
80
+ Requires-Dist: pydata-sphinx-theme; extra == 'docs'
81
+ Requires-Dist: scikit-learn>=1.3; extra == 'docs'
82
+ Requires-Dist: sphinx-copybutton; extra == 'docs'
83
+ Requires-Dist: sphinx-design; extra == 'docs'
84
+ Requires-Dist: sphinx-gallery>=0.15; extra == 'docs'
85
+ Requires-Dist: sphinx>=7; extra == 'docs'
86
+ Provides-Extra: interactive
87
+ Requires-Dist: plotly>=5.15; extra == 'interactive'
88
+ Requires-Dist: pyvis>=0.3; extra == 'interactive'
89
+ Provides-Extra: interop
90
+ Requires-Dist: igraph>=0.11; extra == 'interop'
91
+ Requires-Dist: openpyxl>=3.1; extra == 'interop'
92
+ Requires-Dist: pm4py>=2.7; extra == 'interop'
93
+ Provides-Extra: ml
94
+ Requires-Dist: scikit-learn>=1.3; extra == 'ml'
95
+ Provides-Extra: test
96
+ Requires-Dist: openpyxl>=3.1; extra == 'test'
97
+ Requires-Dist: pytest-cov; extra == 'test'
98
+ Requires-Dist: pytest>=7; extra == 'test'
99
+ Description-Content-Type: text/markdown
100
+
101
+ <p align="center"><img src="https://raw.githubusercontent.com/ComplexSystemsIntelligence/spmviz/main/docs/_static/banner.png" alt="spmviz: mining and visualizing frequent sequences in Python"></p>
102
+
103
+ # spmviz: mining and visualizing frequent sequences in Python
104
+
105
+ [![tests](https://github.com/ComplexSystemsIntelligence/spmviz/actions/workflows/ci.yml/badge.svg)](https://github.com/ComplexSystemsIntelligence/spmviz/actions/workflows/ci.yml)
106
+ [![docs](https://img.shields.io/badge/docs-gallery%20%2B%20API-285780)](https://complexsystemsintelligence.github.io/spmviz)
107
+ [![book](https://img.shields.io/badge/book-PDF%20%C2%B7%20EPUB%20%C2%B7%20web-D55E00)](https://complexsystemsintelligence.github.io/spmviz/book.html)
108
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ComplexSystemsIntelligence/spmviz/blob/main/LICENSE)
109
+
110
+ **spmviz** mines frequent sequences from event logs — clicks, alarms, operator
111
+ actions, moves, daily activities — and shows them. It implements the
112
+ *network-based visualization of frequent sequences* of Bántay and Abonyi
113
+ ([PLOS ONE 19(5): e0301262, 2024](https://doi.org/10.1371/journal.pone.0301262)):
114
+ the weighted extension network (NBVFS-WN) and the confidence- and transaction-based
115
+ maps (NBVFS-CM, NBVFS-TM). Around it the package collects nearly forty views from
116
+ data mining, visual analytics, process mining and social-science sequence analysis,
117
+ adds several new ones, and connects everything to the Python ecosystem.
118
+
119
+ | Module | Contents |
120
+ |---|---|
121
+ | `spmviz.data`, `spmviz.patterns` | `SequenceDatabase` (itemsets, timestamps, attributes, labels) and `PatternSet` (supports, supporting sequences, parents, confidences, closed/maximal/generator subsets, rules, incidence matrix) |
122
+ | `spmviz.mining` | PrefixSpan, SPAM, CM-SPAM, SPADE, GSP with gap, span and time constraints; top-k; sequential rules; WINEPI/MINEPI episodes |
123
+ | `spmviz.backends` | adapters to the `prefixspan`, `seq2pat` and `gsppy` packages and to the SPMF Java library |
124
+ | `spmviz.nbvfs` | the `NBVFS` estimator: WN, CM, TM and fused maps, with stress, NetworkX graph and file export |
125
+ | `spmviz.measures`, `spmviz.networks`, `spmviz.embedding` | interestingness measures, continuation entropy, group contrasts, similarities; extension networks, prefix trees, transition graphs, lattices, higher-order networks, pattern communities and sub-logs; SMACOF, similarity network fusion, landscapes |
126
+ | `spmviz.viz` | glyph tables, trees, sunbursts, icicles, LifeFlow, double trees, Sankey, DFG, MatrixWave, chord, growth Sankey, HON, incidence and similarity matrices, rule matrices, measure scatter, landscapes, lattices, UpSet, index plots, chronograms, dotted charts, sequence logos, arc diagrams, episodes, MDL covers, prediction, dashboard |
127
+ | `spmviz.interactive` | plotly sunbursts, icicles, treemaps, Sankey diagrams and maps; pyvis networks |
128
+ | `spmviz.summary`, `spmviz.predict` | MDL summaries; next-event prediction from the longest matching frequent sequence |
129
+ | `spmviz.io` | pandas event logs, SPMF, XES, pm4py; CSV, JSON, Excel; GEXF (Gephi), GraphML, GML, Cytoscape JSON, node-link JSON, DOT, Pajek, igraph |
130
+ | `spmviz.datasets` | the click-stream (BPI Challenge 2016) and alarm logs of the paper, textbook databases, melodies, chess openings, generators, nine SPMF benchmark databases |
131
+
132
+ ## Installation
133
+
134
+ ```bash
135
+ pip install spmviz
136
+ ```
137
+
138
+ Python ≥ 3.10; depends on numpy, scipy, networkx, pandas and matplotlib.
139
+ `pip install "spmviz[all]"` adds plotly, pyvis, igraph, openpyxl, pm4py and the
140
+ external miners.
141
+
142
+ ## Quick start
143
+
144
+ ```python
145
+ import spmviz as sv
146
+ from spmviz.viz import plot_sunburst, plot_prefix_tree
147
+
148
+ db = sv.datasets.load_clickstream() # 343 sessions, 14 services
149
+ ps = sv.mine(db, min_support=0.01, max_gap=1, max_length=10)
150
+ print(ps) # 241 frequent sequences
151
+ ps.to_frame().head() # supports, confidences, lift, ...
152
+
153
+ sv.NBVFS("wn", start_items=[2]).fit(ps).plot() # weighted extension network
154
+ sv.NBVFS("cm").fit(ps).plot() # confidence-based map
155
+ sv.NBVFS("tm").fit(ps).write("clickstream_tm.gexf") # for Gephi
156
+
157
+ plot_sunburst(db) # how the sessions begin
158
+ plot_prefix_tree(db, color_by="entropy") # where the next step is uncertain
159
+ sv.predict_next(ps, [0, 1]) # what comes next
160
+ ```
161
+
162
+ ## Documentation and book
163
+
164
+ * Documentation, gallery of 36 runnable examples and API reference:
165
+ <https://complexsystemsintelligence.github.io/spmviz>
166
+ * The companion book, *Mining and Visualizing Frequent Sequences in Python: The
167
+ spmviz toolbox* (CC BY 4.0): [PDF](https://complexsystemsintelligence.github.io/spmviz/spmviz-book.pdf),
168
+ [EPUB](https://complexsystemsintelligence.github.io/spmviz/spmviz-book.epub),
169
+ [web edition](https://complexsystemsintelligence.github.io/spmviz/book/index.html)
170
+
171
+ ## Citing
172
+
173
+ Please cite the toolbox and the original NBVFS paper (see `CITATION.cff`):
174
+
175
+ > J. Abonyi, L. Bántay, *spmviz: mining and visualizing frequent sequences in Python*, version 1.0, 2026.
176
+ >
177
+ > L. Bántay, J. Abonyi, Network-based visualisation of frequent sequences, *PLOS ONE* 19(5) (2024) e0301262, doi:10.1371/journal.pone.0301262.
178
+
179
+ ## Acknowledgments
180
+
181
+ Developed at the University of Pannonia, Veszprém, by the
182
+ [Complex Systems Intelligence](https://complexsystemsintelligence.github.io) group
183
+ ([abonyilab.com](https://www.abonyilab.com)). The research was supported by the
184
+ National Research, Development and Innovation Office of Hungary (NKFIH) through the
185
+ OTKA 143482 project.
186
+
187
+ ## License
188
+
189
+ MIT for the software; CC BY 4.0 for the book.
spmviz-1.0/README.md ADDED
@@ -0,0 +1,89 @@
1
+ <p align="center"><img src="https://raw.githubusercontent.com/ComplexSystemsIntelligence/spmviz/main/docs/_static/banner.png" alt="spmviz: mining and visualizing frequent sequences in Python"></p>
2
+
3
+ # spmviz: mining and visualizing frequent sequences in Python
4
+
5
+ [![tests](https://github.com/ComplexSystemsIntelligence/spmviz/actions/workflows/ci.yml/badge.svg)](https://github.com/ComplexSystemsIntelligence/spmviz/actions/workflows/ci.yml)
6
+ [![docs](https://img.shields.io/badge/docs-gallery%20%2B%20API-285780)](https://complexsystemsintelligence.github.io/spmviz)
7
+ [![book](https://img.shields.io/badge/book-PDF%20%C2%B7%20EPUB%20%C2%B7%20web-D55E00)](https://complexsystemsintelligence.github.io/spmviz/book.html)
8
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ComplexSystemsIntelligence/spmviz/blob/main/LICENSE)
9
+
10
+ **spmviz** mines frequent sequences from event logs — clicks, alarms, operator
11
+ actions, moves, daily activities — and shows them. It implements the
12
+ *network-based visualization of frequent sequences* of Bántay and Abonyi
13
+ ([PLOS ONE 19(5): e0301262, 2024](https://doi.org/10.1371/journal.pone.0301262)):
14
+ the weighted extension network (NBVFS-WN) and the confidence- and transaction-based
15
+ maps (NBVFS-CM, NBVFS-TM). Around it the package collects nearly forty views from
16
+ data mining, visual analytics, process mining and social-science sequence analysis,
17
+ adds several new ones, and connects everything to the Python ecosystem.
18
+
19
+ | Module | Contents |
20
+ |---|---|
21
+ | `spmviz.data`, `spmviz.patterns` | `SequenceDatabase` (itemsets, timestamps, attributes, labels) and `PatternSet` (supports, supporting sequences, parents, confidences, closed/maximal/generator subsets, rules, incidence matrix) |
22
+ | `spmviz.mining` | PrefixSpan, SPAM, CM-SPAM, SPADE, GSP with gap, span and time constraints; top-k; sequential rules; WINEPI/MINEPI episodes |
23
+ | `spmviz.backends` | adapters to the `prefixspan`, `seq2pat` and `gsppy` packages and to the SPMF Java library |
24
+ | `spmviz.nbvfs` | the `NBVFS` estimator: WN, CM, TM and fused maps, with stress, NetworkX graph and file export |
25
+ | `spmviz.measures`, `spmviz.networks`, `spmviz.embedding` | interestingness measures, continuation entropy, group contrasts, similarities; extension networks, prefix trees, transition graphs, lattices, higher-order networks, pattern communities and sub-logs; SMACOF, similarity network fusion, landscapes |
26
+ | `spmviz.viz` | glyph tables, trees, sunbursts, icicles, LifeFlow, double trees, Sankey, DFG, MatrixWave, chord, growth Sankey, HON, incidence and similarity matrices, rule matrices, measure scatter, landscapes, lattices, UpSet, index plots, chronograms, dotted charts, sequence logos, arc diagrams, episodes, MDL covers, prediction, dashboard |
27
+ | `spmviz.interactive` | plotly sunbursts, icicles, treemaps, Sankey diagrams and maps; pyvis networks |
28
+ | `spmviz.summary`, `spmviz.predict` | MDL summaries; next-event prediction from the longest matching frequent sequence |
29
+ | `spmviz.io` | pandas event logs, SPMF, XES, pm4py; CSV, JSON, Excel; GEXF (Gephi), GraphML, GML, Cytoscape JSON, node-link JSON, DOT, Pajek, igraph |
30
+ | `spmviz.datasets` | the click-stream (BPI Challenge 2016) and alarm logs of the paper, textbook databases, melodies, chess openings, generators, nine SPMF benchmark databases |
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install spmviz
36
+ ```
37
+
38
+ Python ≥ 3.10; depends on numpy, scipy, networkx, pandas and matplotlib.
39
+ `pip install "spmviz[all]"` adds plotly, pyvis, igraph, openpyxl, pm4py and the
40
+ external miners.
41
+
42
+ ## Quick start
43
+
44
+ ```python
45
+ import spmviz as sv
46
+ from spmviz.viz import plot_sunburst, plot_prefix_tree
47
+
48
+ db = sv.datasets.load_clickstream() # 343 sessions, 14 services
49
+ ps = sv.mine(db, min_support=0.01, max_gap=1, max_length=10)
50
+ print(ps) # 241 frequent sequences
51
+ ps.to_frame().head() # supports, confidences, lift, ...
52
+
53
+ sv.NBVFS("wn", start_items=[2]).fit(ps).plot() # weighted extension network
54
+ sv.NBVFS("cm").fit(ps).plot() # confidence-based map
55
+ sv.NBVFS("tm").fit(ps).write("clickstream_tm.gexf") # for Gephi
56
+
57
+ plot_sunburst(db) # how the sessions begin
58
+ plot_prefix_tree(db, color_by="entropy") # where the next step is uncertain
59
+ sv.predict_next(ps, [0, 1]) # what comes next
60
+ ```
61
+
62
+ ## Documentation and book
63
+
64
+ * Documentation, gallery of 36 runnable examples and API reference:
65
+ <https://complexsystemsintelligence.github.io/spmviz>
66
+ * The companion book, *Mining and Visualizing Frequent Sequences in Python: The
67
+ spmviz toolbox* (CC BY 4.0): [PDF](https://complexsystemsintelligence.github.io/spmviz/spmviz-book.pdf),
68
+ [EPUB](https://complexsystemsintelligence.github.io/spmviz/spmviz-book.epub),
69
+ [web edition](https://complexsystemsintelligence.github.io/spmviz/book/index.html)
70
+
71
+ ## Citing
72
+
73
+ Please cite the toolbox and the original NBVFS paper (see `CITATION.cff`):
74
+
75
+ > J. Abonyi, L. Bántay, *spmviz: mining and visualizing frequent sequences in Python*, version 1.0, 2026.
76
+ >
77
+ > L. Bántay, J. Abonyi, Network-based visualisation of frequent sequences, *PLOS ONE* 19(5) (2024) e0301262, doi:10.1371/journal.pone.0301262.
78
+
79
+ ## Acknowledgments
80
+
81
+ Developed at the University of Pannonia, Veszprém, by the
82
+ [Complex Systems Intelligence](https://complexsystemsintelligence.github.io) group
83
+ ([abonyilab.com](https://www.abonyilab.com)). The research was supported by the
84
+ National Research, Development and Innovation Office of Hungary (NKFIH) through the
85
+ OTKA 143482 project.
86
+
87
+ ## License
88
+
89
+ MIT for the software; CC BY 4.0 for the book.
@@ -0,0 +1,2 @@
1
+ First steps: data, mining, constraints, files
2
+ ---------------------------------------------
@@ -0,0 +1,56 @@
1
+ """
2
+ First steps: four sequences of the PrefixSpan paper
3
+ ====================================================
4
+
5
+ The database of Pei et al. (2001) has four customers; each bought itemsets
6
+ (several items at once) in a sequence. A *sequential pattern* is a sequence of
7
+ itemsets contained, in order, in at least ``min_support`` customers. We mine the
8
+ patterns contained in at least half of the customers and show them as a glyph
9
+ table: events as colored tiles, simultaneous items stacked, the support and the
10
+ confidence of the last extension as bars.
11
+ """
12
+
13
+ # %%
14
+ # The data and the patterns
15
+ # -------------------------
16
+ import matplotlib.pyplot as plt
17
+
18
+ import spmviz as sv
19
+ from spmviz.viz import plot_patterns
20
+
21
+ # [snippet:first]
22
+ db = sv.datasets.load_prefixspan_example()
23
+ for sid, s in zip(db.ids, db):
24
+ print(sid, sv.format_pattern(s, "angle"))
25
+
26
+ ps = sv.mine(db, min_support=0.5) # in at least 2 of the 4 sequences
27
+ print(len(ps), "frequent sequential patterns")
28
+ print(ps.to_frame().head(12)[["pattern", "support", "confidence"]])
29
+ # [/snippet:first]
30
+
31
+ # %%
32
+ # A glyph table of the longest patterns
33
+ # -------------------------------------
34
+ # Long patterns are the interesting ones; ``sort("length")`` puts them first.
35
+ plot_patterns(ps.filter(min_length=3), top=12, by="length")
36
+
37
+ # %%
38
+ # Closed and maximal patterns
39
+ # ---------------------------
40
+ # Many of the 53 patterns repeat each other: a pattern is *closed* if no longer
41
+ # pattern has the same support, *maximal* if no longer pattern is frequent at
42
+ # all. The lossless closed set and the compact maximal set are what we usually draw.
43
+ # [snippet:closed]
44
+ print(len(ps.closed()), "closed,", len(ps.maximal()), "maximal")
45
+ print(ps.maximal().labels("angle"))
46
+ # [/snippet:closed]
47
+
48
+ # %%
49
+ # Parameter study: the minimum support
50
+ # ------------------------------------
51
+ # Lowering the threshold makes the number of patterns explode; the closed and the
52
+ # maximal sets grow much more slowly.
53
+ counts = sv.measures.pattern_counts(db, [1.0, 0.75, 0.5, 0.25])
54
+ print(counts)
55
+ sv.viz.plot_explosion(counts)
56
+ plt.show()
@@ -0,0 +1,50 @@
1
+ """
2
+ An everyday example: daily routines
3
+ ===================================
4
+
5
+ Three hundred days of three kinds of people — early birds, commuters and remote
6
+ workers — each a sequence of activities from waking up to going to sleep. The
7
+ raw sequences are summarized by a *sunburst* (rings = steps, angle = number of
8
+ days), the frequent sequences by a *prefix tree*, and the most typical patterns
9
+ by a glyph table. Patterns may skip activities (``max_gap=2`` allows one
10
+ activity in between).
11
+ """
12
+
13
+ # %%
14
+ # Look at the data first
15
+ # ----------------------
16
+ import matplotlib.pyplot as plt
17
+
18
+ import spmviz as sv
19
+ from spmviz.viz import plot_patterns, plot_prefix_tree, plot_sunburst
20
+
21
+ # [snippet:routines]
22
+ db = sv.datasets.make_daily_routines(300, random_state=0)
23
+ print(db.stats())
24
+ print(sv.format_pattern(db[0]))
25
+ plot_sunburst(db, max_depth=4, title="how the days begin")
26
+ # [/snippet:routines]
27
+
28
+ # %%
29
+ # Frequent sequences with a small gap
30
+ # -----------------------------------
31
+ # [snippet:mine]
32
+ ps = sv.mine(db, min_support=0.3, max_gap=2, max_length=6)
33
+ print(ps)
34
+ plot_prefix_tree(ps, max_depth=4, max_children=3, title="frequent sequences as a tree (three most frequent continuations per node)")
35
+ # [/snippet:mine]
36
+
37
+ # %%
38
+ # The ten best patterns of length at least three
39
+ # ----------------------------------------------
40
+ plot_patterns(ps.filter(min_length=3), top=10)
41
+
42
+ # %%
43
+ # Parameter study: the gap
44
+ # ------------------------
45
+ # Without a gap constraint, patterns may join activities hours apart and their
46
+ # number grows; with ``max_gap=1`` only directly consecutive activities count.
47
+ for gap in (1, 2, 3, None):
48
+ n = len(sv.mine(db, 0.3, max_gap=gap, max_length=6))
49
+ print(f"max_gap={gap}: {n} patterns")
50
+ plt.show()
@@ -0,0 +1,63 @@
1
+ """
2
+ Five algorithms, one answer
3
+ ===========================
4
+
5
+ The package implements PrefixSpan (pattern growth), SPAM and CM-SPAM (vertical
6
+ bitmaps, the algorithm used by Bántay & Abonyi, 2024), SPADE (vertical id-lists)
7
+ and GSP (level-wise). They differ in speed, never in the result: the same
8
+ patterns with the same supports and supporting sequences. External miners
9
+ (the ``prefixspan`` package, ``seq2pat``, ``gsppy``, SPMF) return the same
10
+ :class:`~spmviz.PatternSet` and can be compared in the same way.
11
+ """
12
+
13
+ import time
14
+
15
+ import matplotlib.pyplot as plt
16
+ import numpy as np
17
+
18
+ import spmviz as sv
19
+
20
+ db = sv.datasets.make_customer_journeys(1000, random_state=1)
21
+
22
+ # %%
23
+ # Run all built-in miners
24
+ # -----------------------
25
+ # [snippet:algorithms]
26
+ results, times = {}, {}
27
+ for alg in ["prefixspan", "cmspam", "spam", "spade", "gsp"]:
28
+ t0 = time.perf_counter()
29
+ results[alg] = sv.mine(db, min_support=0.03, algorithm=alg, max_length=6)
30
+ times[alg] = time.perf_counter() - t0
31
+ ref = results["prefixspan"]
32
+ for alg, ps in results.items():
33
+ same = ps.patterns == ref.patterns and np.array_equal(ps.support, ref.support)
34
+ print(f"{alg:10s} {len(ps):5d} patterns {times[alg]:6.3f} s identical={same}")
35
+ # [/snippet:algorithms]
36
+
37
+ # %%
38
+ # An external back end
39
+ # --------------------
40
+ # The ``prefixspan`` package (PyPI) is used when installed.
41
+ try:
42
+ ext = sv.mine(db, 0.03, algorithm="prefixspan-py", max_length=6)
43
+ print("prefixspan-py:", len(ext), "patterns, identical:", dict(zip(ext.patterns, ext.support)) == dict(zip(ref.patterns, ref.support)))
44
+ except ImportError:
45
+ print("the prefixspan package is not installed")
46
+
47
+ # %%
48
+ # Run times
49
+ # ---------
50
+ fig, ax = plt.subplots(figsize=(6, 3))
51
+ ax.barh(list(times), list(times.values()), color="#285780")
52
+ ax.set_xlabel("seconds")
53
+ ax.set_title("same patterns, different algorithms", loc="left", fontsize=10)
54
+ for s in ("top", "right"):
55
+ ax.spines[s].set_visible(False)
56
+
57
+ # %%
58
+ # Parameter study: top-k instead of a threshold
59
+ # ---------------------------------------------
60
+ # When no sensible threshold is known, ask for the k most frequent patterns.
61
+ top = sv.topk(db, k=10, max_length=6)
62
+ print(top.to_frame()[["pattern", "support"]])
63
+ plt.show()
@@ -0,0 +1,41 @@
1
+ """
2
+ Gaps, spans and time windows
3
+ ============================
4
+
5
+ A pattern ⟨wake up, coffee⟩ is contained in a day even if hours pass between the
6
+ two. Constraints restrict which occurrences count: ``max_gap`` bounds the
7
+ distance of consecutive matched elements (``max_gap=1`` = directly
8
+ consecutive), ``max_span`` the length of the whole occurrence, and with
9
+ ``gap_unit="time"`` both are measured on the timestamps (here hours).
10
+ """
11
+
12
+ import matplotlib.pyplot as plt
13
+
14
+ import spmviz as sv
15
+ from spmviz.viz import plot_sequence_index
16
+
17
+ db = sv.datasets.make_daily_routines(300, random_state=0)
18
+
19
+ # %%
20
+ # The same pattern under different constraints
21
+ # --------------------------------------------
22
+ # [snippet:constraints]
23
+ p = "wake up -> coffee" # arrows separate the elements; items may contain spaces
24
+ for kw in [{}, {"max_gap": 1}, {"max_gap": 0.5, "gap_unit": "time"}, {"max_span": 2.0, "gap_unit": "time"}]:
25
+ print(f"{str(kw):45s} support = {db.support(p, **kw)}")
26
+ # [/snippet:constraints]
27
+
28
+ # %%
29
+ # Where the occurrences are
30
+ # -------------------------
31
+ plot_sequence_index(db, max_sequences=60, sort="pattern", highlight=["wake up -> coffee", "commute -> work"], max_length=16)
32
+
33
+ # %%
34
+ # Parameter study: a time window on the whole pattern
35
+ # ---------------------------------------------------
36
+ # How many sequences contain "lunch → … → dinner" within w hours?
37
+ for w in (4, 6, 8, 10):
38
+ print(f"max_span={w:2d} h: {db.support('lunch dinner', max_span=w, gap_unit='time')} days")
39
+ ps = sv.mine(db, 0.25, max_span=3.0, gap_unit="time", max_length=5)
40
+ print(len(ps), "patterns that happen within three hours")
41
+ plt.show()