spmviz.nbvfs.NBVFS#

class spmviz.nbvfs.NBVFS(method='wn', layout='circle', weight='confidence', mds='smacof', similarity_weights=None, start_items=None, min_confidence=0.0, random_state=0)[source]#

Bases: object

Network-based visualisation of frequent sequences (WN, CM, TM and fused maps).

Parameters:
method{“wn”, “cm”, “tm”, “fused”}
layout{“circle”, “hierarchical”, “spring”}

Layout of the weighted network (method="wn").

weight{“confidence”, “cumulative”}

Edge weight: extension confidence (paper) or cumulative confidence of the child (reference implementation).

mds{“smacof”, “classical”, “sklearn”, “umap”, “tsne”}

Projection of the CM, TM and fused maps.

similarity_weightstuple of 3 floats, optional

Weights of the confidence, transaction and content similarities of the fused map (None: similarity network fusion).

start_itemsitem or list, optional

Restrict the pattern set to sequences starting with these events before fitting.

min_confidencefloat

WN: drop extensions (and their subtrees) with lower confidence.

random_stateint
Attributes:
patterns_PatternSet
graph_networkx.DiGraph

Extension network with node coordinates x, y.

coordinates_numpy.ndarray of shape (n_patterns, 2)

Map coordinates in the order of patterns_ (NaN for nodes removed by min_confidence).

similarity_numpy.ndarray or None

The similarity that was projected (CM, TM, fused).

stress_float or None

Normalized stress of the MDS projection.

Examples

>>> import spmviz as sv
>>> db = sv.SequenceDatabase(["abcd", "abce", "abd", "acd", "bcd"])
>>> ps = sv.mine(db, 0.4)
>>> wn = NBVFS("wn").fit(ps)
>>> wn.graph_.number_of_edges() == len(ps) - len(ps.roots())
True
>>> tm = NBVFS("tm").fit(ps)
>>> tm.coordinates_.shape
(14, 2)
fit(ps)[source]#

Build the network and its coordinates.

plot(ax=None, **kw)[source]#

Draw the map (see spmviz.viz.plot_nbvfs() for the options).

property positions_#

Node label → (x, y).

to_frame()[source]#

Pattern table with the map coordinates.

to_html(path=None, engine='plotly', **kw)[source]#

Interactive version (plotly figure, or a pyvis page with engine="pyvis").

write(path, **kw)[source]#

Write the network with coordinates and visual attributes (GEXF, GraphML, JSON, …).