.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/01_basics/plot_04_session_log.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_01_basics_plot_04_session_log.py: Everything is logged: genealogy, lineage and the map of a session ================================================================= A :class:`~easyiec.Session` records every individual ever created (shown or not), every query and every answer with cumulative counters of items, decisions, human answers and API cost. The log is the raw material of every analysis and plot in the package and can be saved to JSON and reloaded. .. GENERATED FROM PYTHON SOURCE LINES 12-17 A logged session with the EASY-IEC algorithm -------------------------------------------- The superformula of Gielis (2003) draws logos with 13 genes. The EASY-IEC strategy keeps the evaluator's *selected* individuals as parents and copies the ones marked *keep* unchanged (Madár et al., 2005). .. GENERATED FROM PYTHON SOURCE LINES 17-33 .. code-block:: Python import matplotlib.pyplot as plt import easyiec as ei from easyiec.problems import SuperShape from easyiec.strategies import EasyIEC problem = SuperShape() user = ei.SimulatedUser(problem, target="random", noise=0.04, seed=11) session = ei.Session(problem, EasyIEC(pop_size=9), user, seed=11) result = session.run(15) log = result.log print(len(log.individuals), "individuals created,", len(log.shown_ids()), "shown") print(log.to_frame()[["step", "n_items_cum", "n_decisions_cum", "best_true"]].tail(4)) session.save("supershape_session.json") again = ei.core.log.SessionLog.load("supershape_session.json") print(len(again.records), "records restored") .. rst-class:: sphx-glr-script-out .. code-block:: none 135 individuals created, 135 shown step n_items_cum n_decisions_cum best_true 11 11 108 108 0.984593 12 12 117 117 0.984593 13 13 126 126 0.984593 14 14 135 135 0.984593 15 records restored .. GENERATED FROM PYTHON SOURCE LINES 34-39 The genealogy ------------- Each dot is a shown individual, placed by generation; lines lead to parents. Chosen individuals are filled; the line of descent of the best one is drawn thick. .. GENERATED FROM PYTHON SOURCE LINES 39-41 .. code-block:: Python ei.viz.plot_genealogy(log) .. image-sg:: /auto_examples/01_basics/images/sphx_glr_plot_04_session_log_001.png :alt: plot 04 session log :srcset: /auto_examples/01_basics/images/sphx_glr_plot_04_session_log_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 42-45 The line of descent of the best individual ------------------------------------------ A lineage follows the first parent back to the initial population. .. GENERATED FROM PYTHON SOURCE LINES 45-47 .. code-block:: Python ei.viz.plot_lineage(log, problem, size=1.0) .. image-sg:: /auto_examples/01_basics/images/sphx_glr_plot_04_session_log_002.png :alt: g0 init, g1 recombination, g2 recombination, g3 recombination, g4 recombination, g5 recombination, g6 recombination, g7 recombination, g8 recombination, g9 recombination, g10 recombination, g11 recombination, g12 recombination, g14 recombination :srcset: /auto_examples/01_basics/images/sphx_glr_plot_04_session_log_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 48-53 The map of the session ---------------------- Classical multidimensional scaling places the shown genomes in the plane; colour codes the generation. The population contracts towards the region the evaluator liked. .. GENERATED FROM PYTHON SOURCE LINES 53-55 .. code-block:: Python ei.viz.plot_embedding(log, problem, method="mds", color="generation") plt.show() .. image-sg:: /auto_examples/01_basics/images/sphx_glr_plot_04_session_log_003.png :alt: MDS map of the genome space :srcset: /auto_examples/01_basics/images/sphx_glr_plot_04_session_log_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.665 seconds) .. _sphx_glr_download_auto_examples_01_basics_plot_04_session_log.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/easyiec/main?urlpath=lab/tree/notebooks/auto_examples/01_basics/plot_04_session_log.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_04_session_log.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_04_session_log.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_04_session_log.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_