.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/01_basics/plot_02_protocols.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_02_protocols.py: Seven ways to answer: feedback protocols ======================================== IEC systems ask very different questions. EASY-IEC asks the user to *select* the good candidates; Picbreeder-like systems ask for one favourite; Bayesian methods ask for *pairwise* comparisons or for the best point on a *line*; questionnaires ask for *ratings*. easyiec supports seven protocols and converts every answer into weighted pairwise preferences, so that every strategy and every preference model can learn from every kind of answer. .. GENERATED FROM PYTHON SOURCE LINES 14-20 One gallery, seven questions ---------------------------- Six harmonograph drawings are evaluated by the same simulated user under each protocol. ``Feedback.to_pairs`` turns each answer into (winner, loser, weight) triples; :func:`~easyiec.core.feedback.information_bits` bounds the information one answer can carry. .. GENERATED FROM PYTHON SOURCE LINES 20-46 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import easyiec as ei from easyiec.core.feedback import information_bits from easyiec.problems import Harmonograph from easyiec.validation import make_individuals problem = Harmonograph() rng = np.random.default_rng(0) items = make_individuals(problem.random(rng, 6)) user = ei.SimulatedUser(problem, target="random", noise=0.03, seed=5) queries = { "select": ei.Query("select", items), "select k=2": ei.Query("select", items, n_select=2), "rank": ei.Query("rank", items), "rate 1-10": ei.Query("rate", items, scale=(1, 10)), "pairs": ei.Query("pairs", items, pairs=[(0, 1), (2, 3), (4, 5), (0, 5)]), "best-worst": ei.Query("best_worst", items), } rows = [] for name, q in queries.items(): fb = user.evaluate(q) pairs = fb.to_pairs(q) rows.append((name, information_bits(q), q.n_decisions(), len(pairs))) print(f"{name:11s} {fb.summary():45s} -> {len(pairs):2d} pairs") .. rst-class:: sphx-glr-script-out .. code-block:: none select select by simulated-user, selected=[10000004, 10000000] -> 8 pairs select k=2 select by simulated-user, selected=[10000004, 10000000] -> 8 pairs rank rank by simulated-user, ranking=[10000004, 10000000, 10000002, 10000001, 10000003, 10000005] -> 15 pairs rate 1-10 rate by simulated-user, ratings={10000000: 5, 10000001: 3, 10000002: 4, 10000003: 3, 10000004: 7, 10000005: 2} -> 14 pairs pairs pairs by simulated-user, 4 pairs -> 4 pairs best-worst best_worst by simulated-user, best=10000004 worst=10000003 -> 9 pairs .. GENERATED FROM PYTHON SOURCE LINES 47-51 The gallery and the true utilities ---------------------------------- The numbers under the drawings are the user's hidden utilities; the ranking answer should follow them up to noise. .. GENERATED FROM PYTHON SOURCE LINES 51-54 .. code-block:: Python u = [problem.utility(it.genome, user.target) for it in items] ei.viz.plot_gallery(problem, items, labels=[f"{x:.2f}" for x in u], ncols=6, size=1.3) .. image-sg:: /auto_examples/01_basics/images/sphx_glr_plot_02_protocols_001.png :alt: 0.41, 0.27, 0.32, 0.17, 0.66, 0.15 :srcset: /auto_examples/01_basics/images/sphx_glr_plot_02_protocols_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 55-60 Information and effort per answer --------------------------------- A ranking carries the most information but costs the most elementary decisions; best–worst scaling is cheap and still yields nine pairs — one reason it is popular in sensory science (Louviere et al., 2015). .. GENERATED FROM PYTHON SOURCE LINES 60-70 .. code-block:: Python names, bits, dec, npairs = zip(*rows) fig, ax = plt.subplots(figsize=(6.4, 3.0)) x = np.arange(len(names)) ax.bar(x - 0.27, bits, 0.27, label="information bound (bits)", color="#285780") ax.bar(x, dec, 0.27, label="elementary decisions", color="#D55E00") ax.bar(x + 0.27, npairs, 0.27, label="implied pairs", color="#009E73") ax.set_xticks(x, names, fontsize=8) ax.legend(frameon=False, fontsize=8) ax.set_title("what one answer is worth") plt.show() .. image-sg:: /auto_examples/01_basics/images/sphx_glr_plot_02_protocols_002.png :alt: what one answer is worth :srcset: /auto_examples/01_basics/images/sphx_glr_plot_02_protocols_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.462 seconds) .. _sphx_glr_download_auto_examples_01_basics_plot_02_protocols.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_02_protocols.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_protocols.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_protocols.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_protocols.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_