Sequence index plots with pattern occurrences#

The index plot of social-science sequence analysis (Brzinsky-Fay, 2014) draws every sequence as a row of colored cells. Combined with the mined patterns it answers where a frequent sequence occurs: the earliest occurrence of each highlighted pattern is marked, and sorting by the patterns brings the supporting sequences to the top.

import matplotlib.pyplot as plt

import spmviz as sv
from spmviz.viz import plot_sequence_index

db = sv.datasets.make_alarm_cascades(400, random_state=0)
plot_sequence_index(db, max_sequences=80, sort="pattern",
                    highlight=["P-LOWFLOW P-TRIP OP-PUMPSTART", "C-HITEMP C-VALVE"], max_length=14)
sequence index plot — marked: P-LOWFLOW → P-TRIP → OP-PUMPSTART; C-HITEMP → C-VALVE
<Axes: title={'left': 'sequence index plot — marked: P-LOWFLOW → P-TRIP → OP-PUMPSTART; C-HITEMP → C-VALVE'}, xlabel='position', ylabel='80 sequences'>

Sorted by length#

plot_sequence_index(db, max_sequences=80, sort="length", max_length=14)
plt.show()
sequence index plot

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

Gallery generated by Sphinx-Gallery