easyiec 1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. easyiec-1.0/.gitignore +48 -0
  2. easyiec-1.0/CHANGELOG.md +19 -0
  3. easyiec-1.0/CITATION.cff +51 -0
  4. easyiec-1.0/LICENSE +21 -0
  5. easyiec-1.0/PKG-INFO +204 -0
  6. easyiec-1.0/README.md +120 -0
  7. easyiec-1.0/book/data/claude/README.md +18 -0
  8. easyiec-1.0/examples/01_basics/README.rst +2 -0
  9. easyiec-1.0/examples/01_basics/plot_01_first_session.py +56 -0
  10. easyiec-1.0/examples/01_basics/plot_02_protocols.py +73 -0
  11. easyiec-1.0/examples/01_basics/plot_03_problem_zoo.py +58 -0
  12. easyiec-1.0/examples/01_basics/plot_04_session_log.py +57 -0
  13. easyiec-1.0/examples/01_basics/plot_05_matlab_workflow.py +59 -0
  14. easyiec-1.0/examples/02_algorithms/README.rst +2 -0
  15. easyiec-1.0/examples/02_algorithms/plot_01_easyiec_es.py +53 -0
  16. easyiec-1.0/examples/02_algorithms/plot_02_cmaes_pso_de.py +61 -0
  17. easyiec-1.0/examples/02_algorithms/plot_03_bayesian.py +65 -0
  18. easyiec-1.0/examples/02_algorithms/plot_04_map_elites.py +45 -0
  19. easyiec-1.0/examples/02_algorithms/plot_05_nsga2_reference.py +45 -0
  20. easyiec-1.0/examples/02_algorithms/plot_06_surrogate.py +57 -0
  21. easyiec-1.0/examples/02_algorithms/plot_07_watchmaker_novelty.py +47 -0
  22. easyiec-1.0/examples/03_evaluators/README.rst +2 -0
  23. easyiec-1.0/examples/03_evaluators/plot_01_simulated_users.py +73 -0
  24. easyiec-1.0/examples/03_evaluators/plot_02_llm_judge.py +93 -0
  25. easyiec-1.0/examples/03_evaluators/plot_03_panels.py +77 -0
  26. easyiec-1.0/examples/03_evaluators/plot_04_escalation.py +90 -0
  27. easyiec-1.0/examples/03_evaluators/plot_05_verbal_steering.py +60 -0
  28. easyiec-1.0/examples/03_evaluators/plot_06_preference_models.py +116 -0
  29. easyiec-1.0/examples/04_validation/README.rst +2 -0
  30. easyiec-1.0/examples/04_validation/plot_01_judge_audit.py +63 -0
  31. easyiec-1.0/examples/04_validation/plot_02_psychometric.py +43 -0
  32. easyiec-1.0/examples/04_validation/plot_03_alt_test_ppi.py +91 -0
  33. easyiec-1.0/examples/04_validation/plot_04_benchmark.py +49 -0
  34. easyiec-1.0/examples/04_validation/plot_05_compare_evaluators.py +65 -0
  35. easyiec-1.0/examples/04_validation/plot_06_reports.py +53 -0
  36. easyiec-1.0/examples/05_engineering/README.rst +2 -0
  37. easyiec-1.0/examples/05_engineering/plot_01_pid_tuning.py +47 -0
  38. easyiec-1.0/examples/05_engineering/plot_02_cstr_control.py +49 -0
  39. easyiec-1.0/examples/05_engineering/plot_03_beer_fermentation.py +54 -0
  40. easyiec-1.0/examples/05_engineering/plot_04_fuzzy_and_paths.py +42 -0
  41. easyiec-1.0/examples/05_engineering/plot_05_segmentation.py +59 -0
  42. easyiec-1.0/examples/06_visual/README.rst +2 -0
  43. easyiec-1.0/examples/06_visual/plot_01_fractals.py +45 -0
  44. easyiec-1.0/examples/06_visual/plot_02_generative_art.py +45 -0
  45. easyiec-1.0/examples/06_visual/plot_03_artificial_life.py +37 -0
  46. easyiec-1.0/examples/06_visual/plot_04_design.py +47 -0
  47. easyiec-1.0/examples/06_visual/plot_05_photo_enhancement.py +52 -0
  48. easyiec-1.0/examples/06_visual/plot_06_music_and_text.py +46 -0
  49. easyiec-1.0/examples/07_claude/README.rst +2 -0
  50. easyiec-1.0/examples/07_claude/claude_01_judge_session.py +40 -0
  51. easyiec-1.0/examples/07_claude/claude_02_validation_study.py +41 -0
  52. easyiec-1.0/examples/07_claude/claude_03_hybrid_gallery.py +22 -0
  53. easyiec-1.0/examples/README.rst +10 -0
  54. easyiec-1.0/pyproject.toml +87 -0
  55. easyiec-1.0/src/easyiec/__init__.py +25 -0
  56. easyiec-1.0/src/easyiec/compat/__init__.py +20 -0
  57. easyiec-1.0/src/easyiec/compat/matlab.py +95 -0
  58. easyiec-1.0/src/easyiec/core/__init__.py +11 -0
  59. easyiec-1.0/src/easyiec/core/feedback.py +437 -0
  60. easyiec-1.0/src/easyiec/core/individual.py +99 -0
  61. easyiec-1.0/src/easyiec/core/log.py +228 -0
  62. easyiec-1.0/src/easyiec/core/operators.py +114 -0
  63. easyiec-1.0/src/easyiec/core/problem.py +245 -0
  64. easyiec-1.0/src/easyiec/core/session.py +295 -0
  65. easyiec-1.0/src/easyiec/core/space.py +175 -0
  66. easyiec-1.0/src/easyiec/evaluators/__init__.py +14 -0
  67. easyiec-1.0/src/easyiec/evaluators/base.py +166 -0
  68. easyiec-1.0/src/easyiec/evaluators/human.py +101 -0
  69. easyiec-1.0/src/easyiec/evaluators/hybrid.py +262 -0
  70. easyiec-1.0/src/easyiec/evaluators/llm/__init__.py +24 -0
  71. easyiec-1.0/src/easyiec/evaluators/llm/clients.py +432 -0
  72. easyiec-1.0/src/easyiec/evaluators/llm/judge.py +419 -0
  73. easyiec-1.0/src/easyiec/evaluators/llm/mock.py +141 -0
  74. easyiec-1.0/src/easyiec/evaluators/llm/parsing.py +84 -0
  75. easyiec-1.0/src/easyiec/evaluators/llm/prompts.py +110 -0
  76. easyiec-1.0/src/easyiec/evaluators/panel.py +161 -0
  77. easyiec-1.0/src/easyiec/evaluators/simulated.py +236 -0
  78. easyiec-1.0/src/easyiec/evaluators/steering.py +167 -0
  79. easyiec-1.0/src/easyiec/imaging.py +253 -0
  80. easyiec-1.0/src/easyiec/preference/__init__.py +7 -0
  81. easyiec-1.0/src/easyiec/preference/aggregation.py +162 -0
  82. easyiec-1.0/src/easyiec/preference/models.py +252 -0
  83. easyiec-1.0/src/easyiec/problems/__init__.py +73 -0
  84. easyiec-1.0/src/easyiec/problems/benchmark.py +128 -0
  85. easyiec-1.0/src/easyiec/problems/control.py +399 -0
  86. easyiec-1.0/src/easyiec/problems/design.py +380 -0
  87. easyiec-1.0/src/easyiec/problems/engineering.py +233 -0
  88. easyiec-1.0/src/easyiec/problems/fermentation.py +197 -0
  89. easyiec-1.0/src/easyiec/problems/fractals.py +353 -0
  90. easyiec-1.0/src/easyiec/problems/generative.py +425 -0
  91. easyiec-1.0/src/easyiec/problems/image.py +232 -0
  92. easyiec-1.0/src/easyiec/problems/music.py +152 -0
  93. easyiec-1.0/src/easyiec/problems/text.py +209 -0
  94. easyiec-1.0/src/easyiec/strategies/__init__.py +22 -0
  95. easyiec-1.0/src/easyiec/strategies/base.py +175 -0
  96. easyiec-1.0/src/easyiec/strategies/bayesian.py +251 -0
  97. easyiec-1.0/src/easyiec/strategies/continuous.py +302 -0
  98. easyiec-1.0/src/easyiec/strategies/diversity.py +239 -0
  99. easyiec-1.0/src/easyiec/strategies/evolutionary.py +363 -0
  100. easyiec-1.0/src/easyiec/strategies/multiobjective.py +158 -0
  101. easyiec-1.0/src/easyiec/strategies/surrogate.py +243 -0
  102. easyiec-1.0/src/easyiec/ui/__init__.py +13 -0
  103. easyiec-1.0/src/easyiec/ui/controller.py +178 -0
  104. easyiec-1.0/src/easyiec/ui/jupyter.py +275 -0
  105. easyiec-1.0/src/easyiec/ui/mpl.py +202 -0
  106. easyiec-1.0/src/easyiec/validation/__init__.py +53 -0
  107. easyiec-1.0/src/easyiec/validation/agreement.py +193 -0
  108. easyiec-1.0/src/easyiec/validation/experiments.py +210 -0
  109. easyiec-1.0/src/easyiec/validation/inference.py +175 -0
  110. easyiec-1.0/src/easyiec/validation/judges.py +360 -0
  111. easyiec-1.0/src/easyiec/validation/runs.py +128 -0
  112. easyiec-1.0/src/easyiec/validation/stats.py +108 -0
  113. easyiec-1.0/src/easyiec/viz/__init__.py +37 -0
  114. easyiec-1.0/src/easyiec/viz/_style.py +55 -0
  115. easyiec-1.0/src/easyiec/viz/evaluation.py +214 -0
  116. easyiec-1.0/src/easyiec/viz/process.py +464 -0
  117. easyiec-1.0/src/easyiec/viz/report.py +103 -0
  118. easyiec-1.0/tests/conftest.py +23 -0
  119. easyiec-1.0/tests/test_core.py +120 -0
  120. easyiec-1.0/tests/test_evaluators.py +136 -0
  121. easyiec-1.0/tests/test_llm.py +161 -0
  122. easyiec-1.0/tests/test_preference.py +47 -0
  123. easyiec-1.0/tests/test_problems.py +75 -0
  124. easyiec-1.0/tests/test_strategies.py +118 -0
  125. easyiec-1.0/tests/test_validation.py +125 -0
  126. easyiec-1.0/tests/test_viz_ui.py +126 -0
easyiec-1.0/.gitignore ADDED
@@ -0,0 +1,48 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ docs/_build/
9
+ docs/auto_examples/
10
+ docs/gen_modules/
11
+ docs/sg_execution_times.rst
12
+ book/figures/
13
+ book/*.aux
14
+ book/*.log
15
+ book/*.out
16
+ book/*.toc
17
+ book/*.bbl
18
+ book/*.bcf
19
+ book/*.blg
20
+ book/*.run.xml
21
+ book/*.idx
22
+ book/*.ilg
23
+ book/*.ind
24
+ book/*.fls
25
+ book/*.fdb_latexmk
26
+ book/*.synctex.gz
27
+ book/main.pdf
28
+ *.ipynb_checkpoints
29
+ book/_check_tmp/
30
+ book/_check.tex
31
+ docs/_build/
32
+ docs/api/generated/
33
+ docs/_build_log.txt
34
+ book/_build/
35
+ .coverage
36
+ book/_build_new/
37
+ book/_check_*.tex
38
+ book/cover/*.aux
39
+ book/cover/*.log
40
+ book/cover/*.fls
41
+ book/cover/*.fdb_latexmk
42
+ book/cover/*.pdf
43
+ book/cover/*.png
44
+ book/cover/logo.svg
45
+ *.blg
46
+ book/_build_epub/
47
+ book/_build_web/
48
+ docs/_gallery_src/
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## 1.0 (2026-11-29) — first release
4
+
5
+ * The Python successor of the EASY-IEC MATLAB toolbox (Madár, Abonyi and Szeifert, 2005): the self-adaptive interactive evolution strategy with parents and kept offspring (`EasyIEC`), direct manipulation of candidates (Lamarckian edits, draggable knots), the `popu` workflow with user functions and `ies_main` (`easyiec.compat`), and interactive particle swarm optimization (`InteractivePSO`, Madár et al., ISDA 2005).
6
+ * Seven evaluation protocols with a common feedback model (select, rank, rate, pairs, best–worst, line, edit); every answer converts to weighted pairwise preferences and utilities, so any strategy accepts any evaluator.
7
+ * Fifteen strategies: interactive GA, ES, CMA-ES, PSO, DE (pairwise duels), Blind Watchmaker, MAP-Elites, novelty-filtered IEC, reference-point NSGA-II, preferential Bayesian optimization, sequential line search, sequential gallery, surrogate-assisted screening, random search; surrogate assistance in two modes (screening a larger pool, or pre-selecting each offspring among its mutants).
8
+ * Preference learning: linear and random-feature Bradley–Terry models, GP preference learning with Laplace's method and evidence-based length-scale selection; Borda, Copeland, Kemeny, Elo and Bradley–Terry aggregation; cyclic-triad consistency.
9
+ * Evaluators: simulated users with known ground truth (Thurstone/BTL noise, fatigue, lapses, attention, position bias, rating compression, preference drift, satisficing, simulated edits); metric evaluators; LLM/VLM judges with presentation-order debiasing, structured JSON outputs, rationales and critiques; persona panels with measured disagreement; hybrid evaluation with uncertainty-based escalation under threshold, rate-control and risk-control policies with inverse-probability-weighted audits; the risk policy starts from calibration labels of an earlier session or study, can count elementary decisions (duels) as its sample size, and escalates every query when no threshold satisfies the risk bound.
10
+ * New: verbal steering — free-text comments ("much brighter, slightly less contrast") become search directions through problem-specific semantic axes and fuzzy linguistic hedges, or through an LLM that maps comments to parameter changes; LLM critiques can steer the search automatically.
11
+ * New: psychometric audits of AI judges (Weibull 2AFC psychometric functions with lapse rate and 75 % discrimination threshold, difference levels concentrated near threshold), together with the swap test, transitivity, self-consistency, calibration, the alternative annotator test and prediction-powered inference.
12
+ * API clients for Anthropic Claude (Messages API, structured outputs, effort), OpenAI-compatible endpoints, Google Gemini and Ollama, with retries, cost accounting and a reproducible disk cache; an offline mock judge with controllable noise and biases.
13
+ * 25 problems from process control and engineering, image processing, generative art, artificial life, complex systems, graphic design, data visualization, network science, music and communication.
14
+ * Front ends: Jupyter/Colab gallery (AI prefill, gene editor, comments), desktop matplotlib gallery (EASY-IEC-style columns, Next/Stop/Edit, draggable handles), console.
15
+ * Validation and benchmarking: agreement statistics, run measures (anytime curves, effort, information bits, diversity), bootstrap, A12, Holm, Friedman–Nemenyi; factorial benchmarks with simulated users (seeded, so every run repeats exactly) and evaluator-comparison studies.
16
+ * About twenty visualizations, GIF animations and self-contained HTML session reports.
17
+ * Rendered images and phenotype features are cached per problem instance (simulated users, panels and archives ask for the same genome many times).
18
+ * Example gallery (38 scripts), Sphinx documentation, a Colab notebook for the Claude validation study, a factorial benchmark script and the companion book.
19
+ * Validation study with Claude Haiku 5.5 and Sonnet 5.5 (psychometric audits, swap test, judge substitution split into clear duels and near ties, closed-loop segmentation tuning, calibrated hybrid per model); measured results, tables and interpretation are in the book's last chapter, and the cached responses make the study repeatable (about US$1.1 at list prices).
@@ -0,0 +1,51 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use easyiec, please cite it as below, together with the original publications of the methods you use."
3
+ type: software
4
+ title: "easyiec: interactive evolutionary computation with human, simulated and AI evaluators in Python"
5
+ version: "1.0"
6
+ date-released: 2026-11-29
7
+ license: MIT
8
+ repository-code: "https://github.com/ComplexSystemsIntelligence/easyiec"
9
+ url: "https://complexsystemsintelligence.github.io/easyiec"
10
+ authors:
11
+ - family-names: Abonyi
12
+ given-names: János
13
+ affiliation: "University of Pannonia, Veszprém, Hungary"
14
+ orcid: "https://orcid.org/0000-0001-8593-1493"
15
+ keywords:
16
+ - interactive evolutionary computation
17
+ - human-in-the-loop optimization
18
+ - LLM-as-a-judge
19
+ - preference learning
20
+ - evolution strategies
21
+ - evolutionary art
22
+ references:
23
+ - type: article
24
+ title: "Interactive evolutionary computation in process engineering"
25
+ authors:
26
+ - family-names: Madár
27
+ given-names: János
28
+ - family-names: Abonyi
29
+ given-names: János
30
+ - family-names: Szeifert
31
+ given-names: Ferenc
32
+ journal: "Computers & Chemical Engineering"
33
+ volume: 29
34
+ issue: 7
35
+ start: 1591
36
+ end: 1597
37
+ year: 2005
38
+ doi: 10.1016/j.compchemeng.2004.12.009
39
+ - type: conference-paper
40
+ title: "Interactive particle swarm optimization"
41
+ authors:
42
+ - family-names: Madár
43
+ given-names: János
44
+ - family-names: Abonyi
45
+ given-names: János
46
+ - family-names: Szeifert
47
+ given-names: Ferenc
48
+ collection-title: "5th International Conference on Intelligent Systems Design and Applications (ISDA'05)"
49
+ start: 314
50
+ end: 319
51
+ year: 2005
easyiec-1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 János Abonyi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
easyiec-1.0/PKG-INFO ADDED
@@ -0,0 +1,204 @@
1
+ Metadata-Version: 2.5
2
+ Name: easyiec
3
+ Version: 1.0
4
+ Summary: Interactive evolutionary computation with human, simulated and AI evaluators: interactive GA/ES/CMA-ES/PSO/DE, quality-diversity, preferential Bayesian optimization, LLM/VLM judges, panels, risk-controlled human escalation, and tools to validate, benchmark and visualize interactive optimization — the successor of the EASY-IEC MATLAB toolbox.
5
+ Project-URL: Homepage, https://github.com/ComplexSystemsIntelligence/easyiec
6
+ Project-URL: Documentation, https://complexsystemsintelligence.github.io/easyiec
7
+ Project-URL: Repository, https://github.com/ComplexSystemsIntelligence/easyiec
8
+ Project-URL: Issues, https://github.com/ComplexSystemsIntelligence/easyiec/issues
9
+ Project-URL: Changelog, https://github.com/ComplexSystemsIntelligence/easyiec/blob/main/CHANGELOG.md
10
+ Project-URL: Book (PDF), https://complexsystemsintelligence.github.io/easyiec/easyiec-book.pdf
11
+ Author-email: János Abonyi <janos@abonyilab.com>
12
+ License-Expression: MIT
13
+ License-File: LICENSE
14
+ Keywords: CMA-ES,IEC,LLM-as-a-judge,evolution strategies,evolutionary art,human-in-the-loop optimization,inter-rater agreement,interactive evolutionary computation,particle swarm,preferential Bayesian optimization,process engineering,simulated users,user fatigue,vision language models
15
+ Classifier: Development Status :: 5 - Production/Stable
16
+ Classifier: Framework :: Jupyter
17
+ Classifier: Intended Audience :: Education
18
+ Classifier: Intended Audience :: Science/Research
19
+ Classifier: License :: OSI Approved :: MIT License
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Topic :: Artistic Software
27
+ Classifier: Topic :: Scientific/Engineering
28
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
29
+ Classifier: Topic :: Scientific/Engineering :: Visualization
30
+ Requires-Python: >=3.10
31
+ Requires-Dist: matplotlib>=3.7
32
+ Requires-Dist: networkx>=3.0
33
+ Requires-Dist: numpy>=1.24
34
+ Requires-Dist: pandas>=2.0
35
+ Requires-Dist: pillow>=10.0
36
+ Requires-Dist: scipy>=1.11
37
+ Provides-Extra: all
38
+ Requires-Dist: ipywidgets>=8.0; extra == 'all'
39
+ Requires-Dist: scikit-image>=0.21; extra == 'all'
40
+ Requires-Dist: scikit-learn>=1.3; extra == 'all'
41
+ Provides-Extra: book
42
+ Requires-Dist: beautifulsoup4>=4.12; extra == 'book'
43
+ Requires-Dist: ipywidgets>=8.0; extra == 'book'
44
+ Requires-Dist: lxml; extra == 'book'
45
+ Requires-Dist: scikit-image>=0.21; extra == 'book'
46
+ Requires-Dist: scikit-learn>=1.3; extra == 'book'
47
+ Provides-Extra: dev
48
+ Requires-Dist: build; extra == 'dev'
49
+ Requires-Dist: ipywidgets>=8.0; extra == 'dev'
50
+ Requires-Dist: myst-parser; extra == 'dev'
51
+ Requires-Dist: numpydoc; extra == 'dev'
52
+ Requires-Dist: pydata-sphinx-theme; extra == 'dev'
53
+ Requires-Dist: pytest-cov; extra == 'dev'
54
+ Requires-Dist: pytest>=7; extra == 'dev'
55
+ Requires-Dist: ruff; extra == 'dev'
56
+ Requires-Dist: scikit-image>=0.21; extra == 'dev'
57
+ Requires-Dist: scikit-learn>=1.3; extra == 'dev'
58
+ Requires-Dist: sphinx-copybutton; extra == 'dev'
59
+ Requires-Dist: sphinx-design; extra == 'dev'
60
+ Requires-Dist: sphinx-gallery>=0.15; extra == 'dev'
61
+ Requires-Dist: sphinx>=7; extra == 'dev'
62
+ Requires-Dist: twine; extra == 'dev'
63
+ Provides-Extra: docs
64
+ Requires-Dist: ipywidgets>=8.0; extra == 'docs'
65
+ Requires-Dist: myst-parser; extra == 'docs'
66
+ Requires-Dist: numpydoc; extra == 'docs'
67
+ Requires-Dist: pydata-sphinx-theme; extra == 'docs'
68
+ Requires-Dist: scikit-image>=0.21; extra == 'docs'
69
+ Requires-Dist: scikit-learn>=1.3; extra == 'docs'
70
+ Requires-Dist: sphinx-copybutton; extra == 'docs'
71
+ Requires-Dist: sphinx-design; extra == 'docs'
72
+ Requires-Dist: sphinx-gallery>=0.15; extra == 'docs'
73
+ Requires-Dist: sphinx>=7; extra == 'docs'
74
+ Provides-Extra: ml
75
+ Requires-Dist: scikit-image>=0.21; extra == 'ml'
76
+ Requires-Dist: scikit-learn>=1.3; extra == 'ml'
77
+ Provides-Extra: notebook
78
+ Requires-Dist: ipywidgets>=8.0; extra == 'notebook'
79
+ Provides-Extra: test
80
+ Requires-Dist: ipywidgets>=8.0; extra == 'test'
81
+ Requires-Dist: pytest-cov; extra == 'test'
82
+ Requires-Dist: pytest>=7; extra == 'test'
83
+ Description-Content-Type: text/markdown
84
+
85
+ <p align="center"><img src="https://raw.githubusercontent.com/ComplexSystemsIntelligence/easyiec/main/docs/_static/banner.png" alt="easyiec: interactive evolutionary computation with human, simulated and AI evaluators"></p>
86
+
87
+ # easyiec: interactive evolutionary computation with human, simulated and AI evaluators
88
+
89
+ [![docs](https://img.shields.io/badge/docs-gallery%20%2B%20API-285780)](https://complexsystemsintelligence.github.io/easyiec)
90
+ [![book](https://img.shields.io/badge/book-PDF%20%C2%B7%20web-D55E00)](https://complexsystemsintelligence.github.io/easyiec/book.html)
91
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ComplexSystemsIntelligence/easyiec/blob/main/LICENSE)
92
+
93
+ **easyiec** optimizes things whose quality is judged rather than computed — a
94
+ controller response, a fermentation profile, a photo grading, a fractal, a
95
+ colour palette, a melody, a slogan. In *interactive evolutionary computation*
96
+ (IEC) the fitness function of an evolutionary algorithm is replaced by an
97
+ evaluator who looks at the candidates and chooses (Takagi, 2001). The package is
98
+ the Python successor of the EASY-IEC MATLAB toolbox (Madár, Abonyi and Szeifert,
99
+ [Comput. Chem. Eng. 29(7), 2005](https://doi.org/10.1016/j.compchemeng.2004.12.009)),
100
+ extended in three directions:
101
+
102
+ 1. **Algorithms** — interactive GA, self-adaptive ES (the EASY-IEC algorithm),
103
+ CMA-ES, interactive PSO (Madár et al., 2005), pairwise differential evolution,
104
+ the Blind Watchmaker, interactive MAP-Elites, novelty-filtered IEC,
105
+ reference-point NSGA-II, preferential Bayesian optimization, sequential line
106
+ search and sequential gallery, surrogate-assisted fatigue reduction, verbal
107
+ steering with fuzzy linguistic hedges and Lamarckian direct manipulation.
108
+ 2. **Evaluators** — people (Jupyter/Colab gallery, desktop matplotlib gallery,
109
+ console), simulated users with known ground truth (Thurstone/BTL noise,
110
+ fatigue, lapses, position bias, drift), metric evaluators, **LLM and VLM
111
+ judges** (Claude, OpenAI-compatible, Gemini, Ollama; offline mock),
112
+ persona panels and **hybrid evaluation that escalates uncertain queries to a
113
+ person under a calibrated risk-control policy**.
114
+ 3. **Evaluation science** — agreement statistics, judge diagnostics (swap test,
115
+ transitivity, self-consistency, calibration), **psychometric audits of AI
116
+ judges**, the alternative annotator test, prediction-powered inference,
117
+ factorial benchmarks with simulated users, statistical comparison and some
118
+ twenty visualizations of IEC processes, plus HTML session reports.
119
+
120
+ | Module | Contents |
121
+ |---|---|
122
+ | `easyiec.core` | `Box` search spaces, `Individual`, `Query`/`Feedback` with seven protocols (select, rank, rate, pairs, best–worst, line, edit), `Problem`, `Session` with budgets, oracles and complete logs |
123
+ | `easyiec.strategies` | `InteractiveGA`, `InteractiveES`, `EasyIEC`, `Watchmaker`, `InteractiveCMAES`, `InteractivePSO`, `InteractiveDE`, `InteractiveMAPElites`, `NoveltyIEC`, `InteractiveNSGA2`, `PreferentialBO`, `SequentialLineSearch`, `SequentialGallery`, `SurrogateAssisted`, `RandomSearch` |
124
+ | `easyiec.preference` | Bradley–Terry (linear, random-feature), GP preference learning (Laplace), Borda, Copeland, Kemeny, Elo, cyclic triads |
125
+ | `easyiec.evaluators` | `SimulatedUser`, `MetricEvaluator`, `LLMJudge`, `Panel`, `PersonaPanel`, `EscalationEvaluator`, `HumanProxy`, `ConsoleEvaluator`, `VerbalSteering`, API clients with disk cache |
126
+ | `easyiec.problems` | 25 problems: PID and CSTR (PID/DMC) tuning, beer fermentation, fuzzy partitions, path planning, photo enhancement, segmentation with ground truth, Julia sets, attractors, IFS, fractal flames, CPPN images, harmonographs, biomorphs, L-systems, cellular automata, superformula logos, palettes, chart styles, Chernoff faces, network drawings, melodies, slogans, synthetic landscapes |
127
+ | `easyiec.validation` | Kendall, Spearman, RBO, Cohen/Fleiss κ, Krippendorff α, Kendall W, ICC; position consistency and bias, self-consistency, transitivity, psychometric audit, calibration; alt-test, PPI; curves, burden, diversity; bootstrap, A12, Holm, Friedman–Nemenyi; `run_benchmark`, `compare_evaluators` |
128
+ | `easyiec.viz` | galleries, film strips, genealogies, lineages, PCA/MDS/t-SNE maps, anytime curves, gene trajectories, preference landscapes, Pareto fronts, strategy states, agreement heatmaps, psychometric curves, position bias, escalation timelines, calibration, critical-difference diagrams, GIF animations, HTML reports |
129
+ | `easyiec.ui` | `JupyterGallery` (ipywidgets, AI prefill, gene editor), `MatplotlibGallery` (EASY-IEC-style figure, draggable knots) |
130
+ | `easyiec.compat` | the MATLAB workflow: `popu_init`, user functions, `ies_main` |
131
+
132
+ ## Installation
133
+
134
+ ```bash
135
+ pip install easyiec
136
+ pip install "easyiec[all]" # + ipywidgets, scikit-learn, scikit-image
137
+ ```
138
+
139
+ Python ≥ 3.10; depends on numpy, scipy, matplotlib, pandas, networkx and Pillow.
140
+ The LLM clients use only the standard library.
141
+
142
+ ## Quick start
143
+
144
+ ```python
145
+ import easyiec as ei
146
+ from easyiec.problems import JuliaSet, BeerFermentation
147
+ from easyiec.strategies import InteractiveGA, InteractiveCMAES
148
+
149
+ # 1) you are the evaluator (Jupyter, JupyterLab, VS Code, Colab)
150
+ ei.ui.JupyterGallery(JuliaSet(), InteractiveGA(pop_size=9))
151
+
152
+ # 2) a simulated user with a hidden target: reproducible benchmarks with ground truth
153
+ p = BeerFermentation()
154
+ user = ei.SimulatedUser(p, target="default", noise=0.05, fatigue=0.5, seed=1)
155
+ res = ei.run(p, InteractiveCMAES(), user, generations=20, seed=1)
156
+ print(res.best_true, p.describe(res.best.genome))
157
+
158
+ # 3) an LLM/VLM judge (Claude), debiased by presentation-order swaps
159
+ from easyiec.evaluators import AnthropicClient, LLMJudge
160
+ judge = LLMJudge(AnthropicClient("claude-sonnet-5-5"), JuliaSet(),
161
+ goal="an intricate, glowing spiral in cool colours")
162
+ res = ei.run(JuliaSet(), InteractiveGA(), judge, generations=10)
163
+
164
+ # 4) the AI answers, people are asked only when the AI is unsure
165
+ from easyiec.evaluators import EscalationEvaluator, HumanProxy
166
+ hybrid = EscalationEvaluator(judge, HumanProxy(), policy="rate", target_rate=0.25)
167
+ # policy="risk" with calibration labels keeps the AI-only disagreement below a tolerance
168
+ ei.ui.JupyterGallery(JuliaSet(), InteractiveGA(), evaluator=hybrid)
169
+ ```
170
+
171
+ Validate a judge before trusting it:
172
+
173
+ ```python
174
+ from easyiec.validation import audit_judge, psychometric_audit
175
+ audit = audit_judge(judge, JuliaSet(), goal="Choose the more beautiful fractal.")
176
+ psy = psychometric_audit(judge, JuliaSet(), "brightness", goal="Choose the brighter image.")
177
+ ei.viz.plot_psychometric(psy)
178
+ ```
179
+
180
+ ## Documentation and book
181
+
182
+ * Documentation, example gallery and API reference: <https://complexsystemsintelligence.github.io/easyiec>
183
+ * The companion book, *Interactive Evolutionary Computation in Python: Human,
184
+ Simulated and AI Evaluators — The easyiec toolbox* (CC BY 4.0):
185
+ [PDF](https://complexsystemsintelligence.github.io/easyiec/easyiec-book.pdf),
186
+ [web edition](https://complexsystemsintelligence.github.io/easyiec/book/index.html)
187
+
188
+ ## Citing
189
+
190
+ If you use easyiec, please cite the software (see `CITATION.cff`) and the
191
+ original publications of the methods you use; the EASY-IEC method itself:
192
+
193
+ > Madár, J., Abonyi, J., Szeifert, F. (2005). Interactive evolutionary
194
+ > computation in process engineering. *Computers & Chemical Engineering*,
195
+ > 29(7), 1591–1597. https://doi.org/10.1016/j.compchemeng.2004.12.009
196
+
197
+ ## Acknowledgement
198
+
199
+ The development was supported by the National Research, Development and
200
+ Innovation Office of Hungary (NKFIH, OTKA 143482).
201
+
202
+ ## License
203
+
204
+ MIT (software); the book is CC BY 4.0.
easyiec-1.0/README.md ADDED
@@ -0,0 +1,120 @@
1
+ <p align="center"><img src="https://raw.githubusercontent.com/ComplexSystemsIntelligence/easyiec/main/docs/_static/banner.png" alt="easyiec: interactive evolutionary computation with human, simulated and AI evaluators"></p>
2
+
3
+ # easyiec: interactive evolutionary computation with human, simulated and AI evaluators
4
+
5
+ [![docs](https://img.shields.io/badge/docs-gallery%20%2B%20API-285780)](https://complexsystemsintelligence.github.io/easyiec)
6
+ [![book](https://img.shields.io/badge/book-PDF%20%C2%B7%20web-D55E00)](https://complexsystemsintelligence.github.io/easyiec/book.html)
7
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ComplexSystemsIntelligence/easyiec/blob/main/LICENSE)
8
+
9
+ **easyiec** optimizes things whose quality is judged rather than computed — a
10
+ controller response, a fermentation profile, a photo grading, a fractal, a
11
+ colour palette, a melody, a slogan. In *interactive evolutionary computation*
12
+ (IEC) the fitness function of an evolutionary algorithm is replaced by an
13
+ evaluator who looks at the candidates and chooses (Takagi, 2001). The package is
14
+ the Python successor of the EASY-IEC MATLAB toolbox (Madár, Abonyi and Szeifert,
15
+ [Comput. Chem. Eng. 29(7), 2005](https://doi.org/10.1016/j.compchemeng.2004.12.009)),
16
+ extended in three directions:
17
+
18
+ 1. **Algorithms** — interactive GA, self-adaptive ES (the EASY-IEC algorithm),
19
+ CMA-ES, interactive PSO (Madár et al., 2005), pairwise differential evolution,
20
+ the Blind Watchmaker, interactive MAP-Elites, novelty-filtered IEC,
21
+ reference-point NSGA-II, preferential Bayesian optimization, sequential line
22
+ search and sequential gallery, surrogate-assisted fatigue reduction, verbal
23
+ steering with fuzzy linguistic hedges and Lamarckian direct manipulation.
24
+ 2. **Evaluators** — people (Jupyter/Colab gallery, desktop matplotlib gallery,
25
+ console), simulated users with known ground truth (Thurstone/BTL noise,
26
+ fatigue, lapses, position bias, drift), metric evaluators, **LLM and VLM
27
+ judges** (Claude, OpenAI-compatible, Gemini, Ollama; offline mock),
28
+ persona panels and **hybrid evaluation that escalates uncertain queries to a
29
+ person under a calibrated risk-control policy**.
30
+ 3. **Evaluation science** — agreement statistics, judge diagnostics (swap test,
31
+ transitivity, self-consistency, calibration), **psychometric audits of AI
32
+ judges**, the alternative annotator test, prediction-powered inference,
33
+ factorial benchmarks with simulated users, statistical comparison and some
34
+ twenty visualizations of IEC processes, plus HTML session reports.
35
+
36
+ | Module | Contents |
37
+ |---|---|
38
+ | `easyiec.core` | `Box` search spaces, `Individual`, `Query`/`Feedback` with seven protocols (select, rank, rate, pairs, best–worst, line, edit), `Problem`, `Session` with budgets, oracles and complete logs |
39
+ | `easyiec.strategies` | `InteractiveGA`, `InteractiveES`, `EasyIEC`, `Watchmaker`, `InteractiveCMAES`, `InteractivePSO`, `InteractiveDE`, `InteractiveMAPElites`, `NoveltyIEC`, `InteractiveNSGA2`, `PreferentialBO`, `SequentialLineSearch`, `SequentialGallery`, `SurrogateAssisted`, `RandomSearch` |
40
+ | `easyiec.preference` | Bradley–Terry (linear, random-feature), GP preference learning (Laplace), Borda, Copeland, Kemeny, Elo, cyclic triads |
41
+ | `easyiec.evaluators` | `SimulatedUser`, `MetricEvaluator`, `LLMJudge`, `Panel`, `PersonaPanel`, `EscalationEvaluator`, `HumanProxy`, `ConsoleEvaluator`, `VerbalSteering`, API clients with disk cache |
42
+ | `easyiec.problems` | 25 problems: PID and CSTR (PID/DMC) tuning, beer fermentation, fuzzy partitions, path planning, photo enhancement, segmentation with ground truth, Julia sets, attractors, IFS, fractal flames, CPPN images, harmonographs, biomorphs, L-systems, cellular automata, superformula logos, palettes, chart styles, Chernoff faces, network drawings, melodies, slogans, synthetic landscapes |
43
+ | `easyiec.validation` | Kendall, Spearman, RBO, Cohen/Fleiss κ, Krippendorff α, Kendall W, ICC; position consistency and bias, self-consistency, transitivity, psychometric audit, calibration; alt-test, PPI; curves, burden, diversity; bootstrap, A12, Holm, Friedman–Nemenyi; `run_benchmark`, `compare_evaluators` |
44
+ | `easyiec.viz` | galleries, film strips, genealogies, lineages, PCA/MDS/t-SNE maps, anytime curves, gene trajectories, preference landscapes, Pareto fronts, strategy states, agreement heatmaps, psychometric curves, position bias, escalation timelines, calibration, critical-difference diagrams, GIF animations, HTML reports |
45
+ | `easyiec.ui` | `JupyterGallery` (ipywidgets, AI prefill, gene editor), `MatplotlibGallery` (EASY-IEC-style figure, draggable knots) |
46
+ | `easyiec.compat` | the MATLAB workflow: `popu_init`, user functions, `ies_main` |
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install easyiec
52
+ pip install "easyiec[all]" # + ipywidgets, scikit-learn, scikit-image
53
+ ```
54
+
55
+ Python ≥ 3.10; depends on numpy, scipy, matplotlib, pandas, networkx and Pillow.
56
+ The LLM clients use only the standard library.
57
+
58
+ ## Quick start
59
+
60
+ ```python
61
+ import easyiec as ei
62
+ from easyiec.problems import JuliaSet, BeerFermentation
63
+ from easyiec.strategies import InteractiveGA, InteractiveCMAES
64
+
65
+ # 1) you are the evaluator (Jupyter, JupyterLab, VS Code, Colab)
66
+ ei.ui.JupyterGallery(JuliaSet(), InteractiveGA(pop_size=9))
67
+
68
+ # 2) a simulated user with a hidden target: reproducible benchmarks with ground truth
69
+ p = BeerFermentation()
70
+ user = ei.SimulatedUser(p, target="default", noise=0.05, fatigue=0.5, seed=1)
71
+ res = ei.run(p, InteractiveCMAES(), user, generations=20, seed=1)
72
+ print(res.best_true, p.describe(res.best.genome))
73
+
74
+ # 3) an LLM/VLM judge (Claude), debiased by presentation-order swaps
75
+ from easyiec.evaluators import AnthropicClient, LLMJudge
76
+ judge = LLMJudge(AnthropicClient("claude-sonnet-5-5"), JuliaSet(),
77
+ goal="an intricate, glowing spiral in cool colours")
78
+ res = ei.run(JuliaSet(), InteractiveGA(), judge, generations=10)
79
+
80
+ # 4) the AI answers, people are asked only when the AI is unsure
81
+ from easyiec.evaluators import EscalationEvaluator, HumanProxy
82
+ hybrid = EscalationEvaluator(judge, HumanProxy(), policy="rate", target_rate=0.25)
83
+ # policy="risk" with calibration labels keeps the AI-only disagreement below a tolerance
84
+ ei.ui.JupyterGallery(JuliaSet(), InteractiveGA(), evaluator=hybrid)
85
+ ```
86
+
87
+ Validate a judge before trusting it:
88
+
89
+ ```python
90
+ from easyiec.validation import audit_judge, psychometric_audit
91
+ audit = audit_judge(judge, JuliaSet(), goal="Choose the more beautiful fractal.")
92
+ psy = psychometric_audit(judge, JuliaSet(), "brightness", goal="Choose the brighter image.")
93
+ ei.viz.plot_psychometric(psy)
94
+ ```
95
+
96
+ ## Documentation and book
97
+
98
+ * Documentation, example gallery and API reference: <https://complexsystemsintelligence.github.io/easyiec>
99
+ * The companion book, *Interactive Evolutionary Computation in Python: Human,
100
+ Simulated and AI Evaluators — The easyiec toolbox* (CC BY 4.0):
101
+ [PDF](https://complexsystemsintelligence.github.io/easyiec/easyiec-book.pdf),
102
+ [web edition](https://complexsystemsintelligence.github.io/easyiec/book/index.html)
103
+
104
+ ## Citing
105
+
106
+ If you use easyiec, please cite the software (see `CITATION.cff`) and the
107
+ original publications of the methods you use; the EASY-IEC method itself:
108
+
109
+ > Madár, J., Abonyi, J., Szeifert, F. (2005). Interactive evolutionary
110
+ > computation in process engineering. *Computers & Chemical Engineering*,
111
+ > 29(7), 1591–1597. https://doi.org/10.1016/j.compchemeng.2004.12.009
112
+
113
+ ## Acknowledgement
114
+
115
+ The development was supported by the National Research, Development and
116
+ Innovation Office of Hungary (NKFIH, OTKA 143482).
117
+
118
+ ## License
119
+
120
+ MIT (software); the book is CC BY 4.0.
@@ -0,0 +1,18 @@
1
+ # Claude validation study: measured data
2
+
3
+ Data behind the book's last chapter, measured on 29 November 2026 in Google Colab
4
+ with easyiec 1.0, `claude-haiku-5-5` and `claude-sonnet-5-5` (Anthropic Messages
5
+ API, low effort, structured JSON output, images of 224 × 224 pixels).
6
+
7
+ - `results_compact.json`: output of `tools/claude_validation.py` at scale 1.0
8
+ (V1–V4 and the first hybrid run), SHA-256
9
+ `f90a875d1ef5e2e05b358c236c3a7aece39a4cb204dd5f6d9385b83f7e207899`.
10
+ - `extra.json`: supplementary analyses run in the same session from the same
11
+ response cache. It holds V3 split into clear duels and near ties, V3 repeated on
12
+ plausible PID controllers, and the calibrated hybrid for both models with the
13
+ corrected risk policy. The current version of the script computes these
14
+ directly (`V3x`, `V5models`).
15
+
16
+ Cost at list prices: 440 API calls, US$1.11 (Sonnet 94 %).
17
+ `python book/build_claude.py` turns these files into the tables and figures of
18
+ the chapter.
@@ -0,0 +1,2 @@
1
+ First steps: sessions, protocols, spaces and logs
2
+ -------------------------------------------------
@@ -0,0 +1,56 @@
1
+ """
2
+ A first interactive session: evolving a Julia set
3
+ =================================================
4
+
5
+ An interactive evolutionary algorithm shows a gallery of candidates, the
6
+ evaluator picks the ones they like, and the algorithm breeds the next gallery
7
+ from the picks. Here the evaluator is a *simulated user* who secretly prefers one
8
+ particular Julia set; because its taste is known, we can measure how close each
9
+ gallery came to it — the ground truth that a real person cannot give us.
10
+ """
11
+
12
+ # %%
13
+ # Problem, strategy and evaluator
14
+ # -------------------------------
15
+ # A :class:`~easyiec.problems.JuliaSet` has ten genes: the complex constant
16
+ # in polar form, zoom, centre, four colour genes and the interior shade. The interactive GA shows nine images per
17
+ # generation and asks for the ones worth keeping (the *select* protocol).
18
+ import matplotlib.pyplot as plt
19
+
20
+ import easyiec as ei
21
+ from easyiec.problems import JuliaSet
22
+ from easyiec.strategies import InteractiveGA
23
+
24
+ # [snippet:first]
25
+ problem = JuliaSet()
26
+ user = ei.SimulatedUser(problem, target="random", noise=0.05, seed=3)
27
+ result = ei.run(problem, InteractiveGA(pop_size=9), user, generations=12, seed=3)
28
+ print(result)
29
+ print(problem.describe(result.best.genome))
30
+ # [/snippet:first]
31
+
32
+ # %%
33
+ # What the evaluator saw
34
+ # ----------------------
35
+ # The film strip shows four galleries; the chosen images carry a frame. The
36
+ # population drifts towards the hidden target within a few generations.
37
+ ei.viz.plot_history(result.log, problem, steps=[0, 3, 7, 11], max_items=9, size=0.9)
38
+
39
+ # %%
40
+ # The hidden target and the best image found
41
+ # ------------------------------------------
42
+ # The simulated user's target is an ordinary genome, so it can be drawn.
43
+ fig, axes = plt.subplots(1, 2, figsize=(5.2, 2.7))
44
+ problem.render(user.target, ax=axes[0])
45
+ axes[0].set_title("hidden target", fontsize=9)
46
+ problem.render(result.best.genome, ax=axes[1])
47
+ axes[1].set_title(f"best found (utility {problem.utility(result.best.genome, user.target):.2f})", fontsize=9)
48
+
49
+ # %%
50
+ # The anytime curve
51
+ # -----------------
52
+ # The true utility of the best individual is plotted against the number of
53
+ # images shown — the classical measure of evaluator effort in IEC.
54
+ ax = ei.viz.plot_anytime(result, label="interactive GA")
55
+ ax.set_title("best true utility vs. images shown")
56
+ plt.show()
@@ -0,0 +1,73 @@
1
+ """
2
+ Seven ways to answer: feedback protocols
3
+ ========================================
4
+
5
+ IEC systems ask very different questions. EASY-IEC asks the user to *select*
6
+ the good candidates; Picbreeder-like systems ask for one favourite; Bayesian
7
+ methods ask for *pairwise* comparisons or for the best point on a *line*;
8
+ questionnaires ask for *ratings*. easyiec supports seven protocols and converts
9
+ every answer into weighted pairwise preferences, so that every strategy and
10
+ every preference model can learn from every kind of answer.
11
+ """
12
+
13
+ # %%
14
+ # One gallery, seven questions
15
+ # ----------------------------
16
+ # Six harmonograph drawings are evaluated by the same simulated user under each
17
+ # protocol. ``Feedback.to_pairs`` turns each answer into (winner, loser, weight)
18
+ # triples; :func:`~easyiec.core.feedback.information_bits` bounds the
19
+ # information one answer can carry.
20
+ import matplotlib.pyplot as plt
21
+ import numpy as np
22
+
23
+ import easyiec as ei
24
+ from easyiec.core.feedback import information_bits
25
+ from easyiec.problems import Harmonograph
26
+ from easyiec.validation import make_individuals
27
+
28
+ problem = Harmonograph()
29
+ rng = np.random.default_rng(0)
30
+ items = make_individuals(problem.random(rng, 6))
31
+ user = ei.SimulatedUser(problem, target="random", noise=0.03, seed=5)
32
+
33
+ # [snippet:protocols]
34
+ queries = {
35
+ "select": ei.Query("select", items),
36
+ "select k=2": ei.Query("select", items, n_select=2),
37
+ "rank": ei.Query("rank", items),
38
+ "rate 1-10": ei.Query("rate", items, scale=(1, 10)),
39
+ "pairs": ei.Query("pairs", items, pairs=[(0, 1), (2, 3), (4, 5), (0, 5)]),
40
+ "best-worst": ei.Query("best_worst", items),
41
+ }
42
+ rows = []
43
+ for name, q in queries.items():
44
+ fb = user.evaluate(q)
45
+ pairs = fb.to_pairs(q)
46
+ rows.append((name, information_bits(q), q.n_decisions(), len(pairs)))
47
+ print(f"{name:11s} {fb.summary():45s} -> {len(pairs):2d} pairs")
48
+ # [/snippet:protocols]
49
+
50
+ # %%
51
+ # The gallery and the true utilities
52
+ # ----------------------------------
53
+ # The numbers under the drawings are the user's hidden utilities; the ranking
54
+ # answer should follow them up to noise.
55
+ u = [problem.utility(it.genome, user.target) for it in items]
56
+ ei.viz.plot_gallery(problem, items, labels=[f"{x:.2f}" for x in u], ncols=6, size=1.3)
57
+
58
+ # %%
59
+ # Information and effort per answer
60
+ # ---------------------------------
61
+ # A ranking carries the most information but costs the most elementary
62
+ # decisions; best–worst scaling is cheap and still yields nine pairs — one reason
63
+ # it is popular in sensory science (Louviere et al., 2015).
64
+ names, bits, dec, npairs = zip(*rows)
65
+ fig, ax = plt.subplots(figsize=(6.4, 3.0))
66
+ x = np.arange(len(names))
67
+ ax.bar(x - 0.27, bits, 0.27, label="information bound (bits)", color="#285780")
68
+ ax.bar(x, dec, 0.27, label="elementary decisions", color="#D55E00")
69
+ ax.bar(x + 0.27, npairs, 0.27, label="implied pairs", color="#009E73")
70
+ ax.set_xticks(x, names, fontsize=8)
71
+ ax.legend(frameon=False, fontsize=8)
72
+ ax.set_title("what one answer is worth")
73
+ plt.show()