spmviz: mining and visualizing frequent sequences#

spmviz

spmviz mines frequent sequences from event logs and shows them. It implements the network-based visualization of frequent sequences of Bántay and Abonyi (PLOS ONE, 2024) — the weighted extension network and the confidence- and transaction-based maps — and places it among nearly forty other views from data mining, visual analytics, process mining and sequence analysis. Five sequential pattern miners in pure Python, adapters to SPMF and other libraries, and export of every result to pandas, NetworkX, Gephi and Cytoscape make it a complete toolbox for event data.

Mining

PrefixSpan, SPAM, CM-SPAM, SPADE and GSP with gap, span and time constraints; closed, maximal and generator patterns; top-k; rules; episodes.

Mining algorithms
NBVFS maps

The weighted extension network (WN), the confidence (CM) and transaction (TM) maps of the 2024 paper, a fused map and pattern communities.

NBVFS maps
Trees

Prefix and pattern trees, sunbursts, icicles, LifeFlow, word and double trees, continuation-entropy and contrast trees.

Trees: prefix trees, sunbursts, icicles, word trees
Flows

Sankey diagrams, directly-follows graphs, MatrixWave, chord diagrams, growth Sankey, pattern-induced higher-order networks.

Flows: Sankey diagrams, transition graphs, higher-order networks
Matrices, maps, sets

Seriated incidence and similarity matrices, grouped rule matrices, measure scatter plots, pattern landscapes, lattices, UpSet plots.

Maps and matrices of pattern sets
Sequence views

Index plots, chronograms, dotted charts, sequence logos, arc diagrams, episode timelines and MDL summaries.

Sequences: index plots, logos, arcs, episodes, summaries
Import and export

pandas event logs, SPMF, XES, pm4py; NetworkX, GEXF (Gephi), GraphML, Cytoscape, igraph; plotly and pyvis figures.

Interoperability
Data sets

The click-stream and alarm logs of the paper, textbook and everyday examples, generators, and the SPMF benchmark databases.

Data sets
The book

Mining and Visualizing Frequent Sequences in Python: methods, algorithms and every example of the gallery.

The book

Quick start#

import spmviz as sv

db = sv.datasets.load_clickstream()                    # 343 sessions, 14 services
ps = sv.mine(db, min_support=0.01, max_gap=1, max_length=10)
ps.to_frame().head()                                   # patterns, supports, confidences

sv.NBVFS("wn", start_items=[2]).fit(ps).plot()         # weighted extension network
sv.NBVFS("tm").fit(ps).plot()                          # transaction-based map
sv.viz.plot_sunburst(db)                               # how the sessions begin
sv.predict_next(ps, [0, 1])                            # what comes next