spmviz: mining and visualizing frequent sequences in Python

spmviz mines frequent sequences from event logs — clicks, alarms, operator
actions, moves, daily activities — and shows them. It implements the
network-based visualization of frequent sequences of Bántay and Abonyi
(PLOS ONE 19(5): e0301262, 2024):
the weighted extension network (NBVFS-WN) and the confidence- and transaction-based
maps (NBVFS-CM, NBVFS-TM). Around it the package collects nearly forty views from
data mining, visual analytics, process mining and social-science sequence analysis,
adds several new ones, and connects everything to the Python ecosystem.
| Module |
Contents |
spmviz.data, spmviz.patterns |
SequenceDatabase (itemsets, timestamps, attributes, labels) and PatternSet (supports, supporting sequences, parents, confidences, closed/maximal/generator subsets, rules, incidence matrix) |
spmviz.mining |
PrefixSpan, SPAM, CM-SPAM, SPADE, GSP with gap, span and time constraints; top-k; sequential rules; WINEPI/MINEPI episodes |
spmviz.backends |
adapters to the prefixspan, seq2pat and gsppy packages and to the SPMF Java library |
spmviz.nbvfs |
the NBVFS estimator: WN, CM, TM and fused maps, with stress, NetworkX graph and file export |
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 |
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 |
spmviz.interactive |
plotly sunbursts, icicles, treemaps, Sankey diagrams and maps; pyvis networks |
spmviz.summary, spmviz.predict |
MDL summaries; next-event prediction from the longest matching frequent sequence |
spmviz.io |
pandas event logs, SPMF, XES, pm4py; CSV, JSON, Excel; GEXF (Gephi), GraphML, GML, Cytoscape JSON, node-link JSON, DOT, Pajek, igraph |
spmviz.datasets |
the click-stream (BPI Challenge 2016) and alarm logs of the paper, textbook databases, melodies, chess openings, generators, nine SPMF benchmark databases |
Installation
pip install spmviz
Python ≥ 3.10; depends on numpy, scipy, networkx, pandas and matplotlib.
pip install "spmviz[all]" adds plotly, pyvis, igraph, openpyxl, pm4py and the
external miners.
Quick start
import spmviz as sv
from spmviz.viz import plot_sunburst, plot_prefix_tree
db = sv.datasets.load_clickstream() # 343 sessions, 14 services
ps = sv.mine(db, min_support=0.01, max_gap=1, max_length=10)
print(ps) # 241 frequent sequences
ps.to_frame().head() # supports, confidences, lift, ...
sv.NBVFS("wn", start_items=[2]).fit(ps).plot() # weighted extension network
sv.NBVFS("cm").fit(ps).plot() # confidence-based map
sv.NBVFS("tm").fit(ps).write("clickstream_tm.gexf") # for Gephi
plot_sunburst(db) # how the sessions begin
plot_prefix_tree(db, color_by="entropy") # where the next step is uncertain
sv.predict_next(ps, [0, 1]) # what comes next
Documentation and book
Citing
Please cite the toolbox and the original NBVFS paper (see CITATION.cff):
J. Abonyi, L. Bántay, spmviz: mining and visualizing frequent sequences in Python, version 1.0, 2026.
L. Bántay, J. Abonyi, Network-based visualisation of frequent sequences, PLOS ONE 19(5) (2024) e0301262, doi:10.1371/journal.pone.0301262.
Acknowledgments
Developed at the University of Pannonia, Veszprém, by the
Complex Systems Intelligence group
(abonyilab.com). The research was supported by the
National Research, Development and Innovation Office of Hungary (NKFIH) through the
OTKA 143482 project.
License
MIT for the software; CC BY 4.0 for the book.