"""A one-page overview of a pattern set."""
from __future__ import annotations
from matplotlib import pyplot as plt
from ._style import INK
__all__ = ["plot_overview"]
[docs]
def plot_overview(ps, figsize=(16, 10), title: str | None = None):
"""Six linked views of one mining run: sunburst of the raw sequences, NBVFS-WN,
NBVFS-TM, transition graph, sequence index plot with the top pattern, and the
support/confidence plane. Returns the figure.
"""
from ..nbvfs import NBVFS
from .flows import plot_transition_graph
from .nbvfs import plot_nbvfs
from .projections import plot_pattern_scatter
from .sequences import plot_sequence_index
from .trees import plot_sunburst
db = ps.db
fig, axes = plt.subplots(2, 3, figsize=figsize, constrained_layout=True)
plot_sunburst(db, ax=axes[0, 0], max_depth=3, title="sequences sunburst")
plot_nbvfs(NBVFS("wn").fit(ps), ax=axes[0, 1], legend=False, labels=15, title="NBVFS-WN")
plot_nbvfs(NBVFS("tm").fit(ps), ax=axes[0, 2], legend=False, labels=12, title="NBVFS-TM")
plot_transition_graph(db, ax=axes[1, 0], top_edges=30, labels=None, title="transition graph")
best = ps.filter(min_length=2).top(1)
plot_sequence_index(db, ax=axes[1, 1], max_sequences=60, sort="pattern",
highlight=best.patterns[0] if len(best) else None, title="sequence index plot")
axes[1, 1].get_legend().remove() if axes[1, 1].get_legend() else None
plot_pattern_scatter(ps, ax=axes[1, 2], labels=8, title="support and confidence")
fig.suptitle(title or f"overview of {len(ps)} frequent sequences in {len(db)} sequences", x=0.01, ha="left",
fontsize=13, color=INK)
return fig