.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/03_evaluators/plot_05_verbal_steering.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_evaluators_plot_05_verbal_steering.py: Verbal steering: "much brighter, slightly less saturated" ========================================================= People comment while they choose. easyiec turns comments into search directions: each problem names *semantic axes* (``brighter``, ``more contrast``, ``warmer`` ...) and linguistic hedges scale the step in the manner of Zadeh's (1972) hedges as operators on fuzzy sets — *very* and *much* concentrate (stronger move), *slightly* and *a bit* dilate, *less* and *not* negate. With a language model connected, free comments outside the vocabulary are mapped to parameter changes as well. .. GENERATED FROM PYTHON SOURCE LINES 15-17 Parsing comments ---------------- .. GENERATED FROM PYTHON SOURCE LINES 17-32 .. code-block:: Python import matplotlib.pyplot as plt import easyiec as ei from easyiec.evaluators import VerbalSteering from easyiec.evaluators.steering import parse_hedged_phrases from easyiec.problems import ImageEnhancement from easyiec.strategies import InteractiveGA problem = ImageEnhancement() print(sorted(problem.semantic_axes)) for c in ["much brighter, but slightly less contrast", "a bit warmer and not so saturated", "lift the shadows a lot"]: print(f"{c!r:45s} -> {parse_hedged_phrases(c, problem.semantic_axes)}") vs = VerbalSteering(problem, step=0.12) d = vs.direction("much brighter, but slightly less contrast") print({k: round(float(v), 3) for k, v in zip(problem.space.names, d) if v != 0}) .. rst-class:: sphx-glr-script-out .. code-block:: none ['brighter', 'cooler', 'darker', 'flatter', 'lift the shadows', 'more contrast', 'more muted', 'more saturated', 'more vignette', 'more vivid', 'recover highlights', 'sharper', 'softer', 'warmer'] 'much brighter, but slightly less contrast' -> [('brighter', 2.0), ('more contrast', -0.4)] 'a bit warmer and not so saturated' -> [('warmer', 0.5), ('more saturated', -1.0)] 'lift the shadows a lot' -> [('lift the shadows', 2.0)] {'exposure': 0.24, 'contrast': -0.048} .. GENERATED FROM PYTHON SOURCE LINES 33-40 A user who comments ------------------- The simulated user compares the chosen image with its target and says what should change ("much warmer", "lift the shadows a lot"). The same sessions with the comments ignored (``steering=False``) are the baseline. With small galleries of four images, where each selection carries little information, the comments speed up the search noticeably (eight seeds). .. GENERATED FROM PYTHON SOURCE LINES 40-50 .. code-block:: Python from easyiec.validation import curve_frame # noqa: E402 results, labels = [], [] for seed in range(8): for name, steer in [("selections + comments", None), ("selections only", False)]: user = ei.SimulatedUser(problem, target="random", noise=0.04, comments=1.0, seed=seed) results.append(ei.run(problem, InteractiveGA(pop_size=4), user, generations=10, seed=seed, steering=steer)) labels.append(name) print([r.feedback.comment for r in results[0].log.records if r.feedback.comment][:6]) ei.viz.plot_convergence(curve_frame(results, labels=labels), title="photo enhancement, galleries of four") .. image-sg:: /auto_examples/03_evaluators/images/sphx_glr_plot_05_verbal_steering_001.png :alt: photo enhancement, galleries of four :srcset: /auto_examples/03_evaluators/images/sphx_glr_plot_05_verbal_steering_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none ['much cooler', 'much cooler', 'lift the shadows a lot', 'much sharper', 'much sharper', 'much softer'] .. GENERATED FROM PYTHON SOURCE LINES 51-53 What the commenting user saw ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 53-55 .. code-block:: Python ei.viz.plot_history(results[0].log, problem, steps=[0, 3, 6, 9], max_items=4, size=1.1) plt.show() .. image-sg:: /auto_examples/03_evaluators/images/sphx_glr_plot_05_verbal_steering_002.png :alt: plot 05 verbal steering :srcset: /auto_examples/03_evaluators/images/sphx_glr_plot_05_verbal_steering_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 17.233 seconds) .. _sphx_glr_download_auto_examples_03_evaluators_plot_05_verbal_steering.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/03_evaluators/plot_05_verbal_steering.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_05_verbal_steering.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_05_verbal_steering.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_05_verbal_steering.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_