.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/04_validation/plot_02_psychometric.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_04_validation_plot_02_psychometric.py: Psychometric audit: how small a difference can the judge see? ============================================================= Psychophysics measures a sensory system by its *psychometric function*: the probability of a correct answer in a two-alternative forced choice as a function of the stimulus difference. easyiec applies the method to evaluators. Pairs of candidates are drawn so that a controlled attribute (here the brightness of a Julia set image) differs by graded amounts; the evaluator is asked which candidate has more of it, and a logistic function with lapse rate is fitted (Wichmann and Hill, 2001). The *threshold* — the difference at which the judge is right 75 % of the time — is the judge's just-noticeable difference; the lapse rate measures its careless errors. .. GENERATED FROM PYTHON SOURCE LINES 17-22 Three judges of brightness -------------------------- Mock judges that score the actual image brightness with three noise levels. With Claude, the same call measures the brightness discrimination of the model (see the last section of the gallery and the case study of the book). .. GENERATED FROM PYTHON SOURCE LINES 22-42 .. code-block:: Python import matplotlib.pyplot as plt import easyiec as ei from easyiec.evaluators import LLMJudge, MockJudgeClient from easyiec.imaging import image_features from easyiec.problems import JuliaSet from easyiec.validation import psychometric_audit problem = JuliaSet() brightness = lambda img: float(image_features(img)[0]) # noqa: E731 the mock scores the rendered image results = [] for noise in [0.01, 0.03, 0.08]: judge = LLMJudge(MockJudgeClient(brightness, score_on="image", noise=noise, seed=1), problem, image_size=96, debias="none") res = psychometric_audit(judge, problem, "brightness", goal="Choose the brighter image.", n_levels=6, per_level=12, name=f"judge noise {noise}") results.append(res) print(f"{res.attribute}: threshold {res.threshold75:.3f}, lapse {res.lapse:.2f}, accuracy {res.accuracy:.2f}") ei.viz.plot_psychometric(results) plt.show() .. image-sg:: /auto_examples/04_validation/images/sphx_glr_plot_02_psychometric_001.png :alt: plot 02 psychometric :srcset: /auto_examples/04_validation/images/sphx_glr_plot_02_psychometric_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none judge noise 0.01: threshold 0.009, lapse 0.00, accuracy 0.79 judge noise 0.03: threshold 0.014, lapse 0.03, accuracy 0.71 judge noise 0.08: threshold 0.037, lapse 0.01, accuracy 0.65 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 17.287 seconds) .. _sphx_glr_download_auto_examples_04_validation_plot_02_psychometric.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/04_validation/plot_02_psychometric.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_psychometric.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_psychometric.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_psychometric.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_