Matrices of a pattern set#

The pattern–sequence incidence matrix \(\mathbf{T}\) (patterns in rows, supporting sequences in columns) is the data behind the transaction map. Seriated by hierarchical clustering, its blocks are groups of patterns supported by the same traces. The seriated similarity matrix with its dendrogram shows the same groups as a square heatmap.

import matplotlib.pyplot as plt

import spmviz as sv
from spmviz.viz import plot_incidence, plot_similarity_matrix

db = sv.datasets.make_alarm_cascades(600, random_state=0)
ps = sv.mine(db, 0.08, max_length=4)
plot_incidence(ps, top=40)
plot_similarity_matrix(ps, "transaction", top=40)
  • pattern–sequence incidence matrix
  • transaction similarity of 40 patterns
<Axes: title={'left': 'transaction similarity of 40 patterns'}>

Content instead of co-occurrence#

The longest-common-subsequence similarity groups patterns that look alike.

plot_similarity_matrix(ps, "content", top=40)
plt.show()
content similarity of 40 patterns

Total running time of the script: (0 minutes 0.756 seconds)

Gallery generated by Sphinx-Gallery