Sequence logos#

Borrowed from bioinformatics (Schneider & Stephens, 1990): every column stacks the events seen at a position relative to an anchor, letter heights proportional to their probability times the information content of the column (\(\log_2 K - H\)). Conserved steps are tall, variable steps are low.

import matplotlib.pyplot as plt

import spmviz as sv
from spmviz.viz import plot_sequence_logo

shop = sv.datasets.make_customer_journeys(1000, random_state=0)
plot_sequence_logo(shop, anchor="cart", before=3, after=4)
sequence logo around cart
<Axes: title={'left': 'sequence logo around cart'}, ylabel='information (bits)'>

The openings of melodies#

songs = sv.datasets.load_melodies("phrase")
plot_sequence_logo(songs, before=0, after=6, info=False, title="first notes of the phrases (probabilities)")
plt.show()
first notes of the phrases (probabilities)

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

Gallery generated by Sphinx-Gallery