.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/03_trees/plot_01_chess_sunburst.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_03_trees_plot_01_chess_sunburst.py: A spectacular sunburst: chess openings ======================================= Two thousand games drawn from a small opening book of 33 main lines. Every game is the sequence of its first moves (plies). The sunburst stacks the moves ring by ring: the angle of a wedge is the share of games that start with that move sequence, so the familiar families — 1.e4 e5 open games, the Sicilian 1.e4 c5, the closed 1.d4 d5 and the Indian 1.d4 Nf6 systems — appear as large slices with their branches. Frequent sequences then summarize the book. .. GENERATED FROM PYTHON SOURCE LINES 12-19 .. code-block:: Python import matplotlib.pyplot as plt import spmviz as sv from spmviz.viz import plot_icicle, plot_sunburst db = sv.datasets.load_chess_openings(2000, random_state=0) plot_sunburst(db, max_depth=5, min_angle=7, title="the first five plies of 2,000 games") .. image-sg:: /auto_examples/03_trees/images/sphx_glr_plot_01_chess_sunburst_001.png :alt: the first five plies of 2,000 games :srcset: /auto_examples/03_trees/images/sphx_glr_plot_01_chess_sunburst_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 20-22 The same tree as an icicle -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 22-24 .. code-block:: Python plot_icicle(db, max_depth=6, min_count=20, title="icicle of the opening tree") .. image-sg:: /auto_examples/03_trees/images/sphx_glr_plot_01_chess_sunburst_002.png :alt: icicle of the opening tree :srcset: /auto_examples/03_trees/images/sphx_glr_plot_01_chess_sunburst_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 25-27 Frequent (contiguous) move sequences ------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 27-29 .. code-block:: Python ps = sv.mine(db, min_support=0.05, max_gap=1) print(ps.filter(min_length=4).sort("support").to_frame()[["pattern", "support", "confidence"]].head(10)) .. rst-class:: sphx-glr-script-out .. code-block:: none pattern support confidence 0 e4 → e5 → Nf3 → Nc6 468 0.924901 1 e4 → c5 → Nf3 → d6 221 0.620787 2 c5 → Nf3 → d6 → d4 194 0.877828 3 e4 → c5 → Nf3 → d6 → d4 194 0.877828 4 d4 → Nf6 → c4 → e6 190 0.567164 5 e5 → Nf3 → Nc6 → Bb5 187 0.399573 6 e4 → e5 → Nf3 → Nc6 → Bb5 187 0.399573 7 Nf3 → d6 → d4 → cxd4 156 0.804124 8 c5 → Nf3 → d6 → d4 → cxd4 156 0.804124 9 e4 → c5 → Nf3 → d6 → d4 → cxd4 156 0.804124 .. GENERATED FROM PYTHON SOURCE LINES 30-32 Parameter study: depth ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 32-37 .. code-block:: Python fig, axes = plt.subplots(1, 3, figsize=(15, 5)) for ax, d in zip(axes, (2, 4, 6)): plot_sunburst(db, ax=ax, max_depth=d, min_angle=10, title=f"depth {d}") ax.get_legend().remove() plt.show() .. image-sg:: /auto_examples/03_trees/images/sphx_glr_plot_01_chess_sunburst_003.png :alt: depth 2, depth 4, depth 6 :srcset: /auto_examples/03_trees/images/sphx_glr_plot_01_chess_sunburst_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.900 seconds) .. _sphx_glr_download_auto_examples_03_trees_plot_01_chess_sunburst.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/spmviz/main?urlpath=lab/tree/notebooks/auto_examples/03_trees/plot_01_chess_sunburst.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_chess_sunburst.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_chess_sunburst.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_chess_sunburst.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_