Interoperability#

Three kinds of objects carry an analysis: a SequenceDatabase, a PatternSet and NetworkX graphs. Every reader produces one of them and every view consumes them, so spmviz combines with the rest of the Python ecosystem and with Gephi, Cytoscape, R and spreadsheets.

Data in#

import spmviz as sv

db = sv.SequenceDatabase.from_event_log(df, case="case", activity="activity", timestamp="time")
db = sv.SequenceDatabase.from_spmf("sequences.txt")      # SPMF input format
db = sv.io.read_xes("log.xes")                           # IEEE XES (process mining)
db = sv.SequenceDatabase.from_pm4py(log)                 # pm4py event log or data frame
db = sv.SequenceDatabase.from_strings(["a b c", "a c"])  # one sequence per string
db.to_event_log()                                        # back to a long table

Patterns can be written as "a (b c) d", in the arrow notation "wake up -> coffee -> (tv, read)" (items may contain spaces) or in the SPMF format "1 -1 2 3 -1"; db.pattern(...) resolves item labels.

Other miners#

sv.mine(db, ..., algorithm=name) runs the built-in miners ("prefixspan", "cmspam", "spam", "spade", "gsp") and external ones ("prefixspan-py", "seq2pat", "gsppy", "spmf"); every result is a PatternSet with supporting sequences, so every view works on it. sv.backends.available() lists the installed back ends.

Results out#

Call

Result

ps.to_frame()

pandas data frame with all measures

ps.write("p.txt")

SPMF output with #SUP and #SID

ps.write("p.csv"), .json,

tables and JSON; sv.io.read_patterns reads

.xlsx

them back

ps.to_networkx(kind)

extension network, lattice or similarity graph

sv.NBVFS(view).fit(ps).graph_

NetworkX graph with positions and attributes

sv.io.write_graph(G, "g.gexf")

Gephi with positions, colors and sizes

.graphml, .gml, .cyjs,

GraphML, GML, Cytoscape JSON, node-link JSON,

.json, .dot, .net

Graphviz, Pajek

sv.io.to_igraph(G)

igraph

sv.interactive.*

plotly figures; to_pyvis for pyvis