Note
Go to the end to download the full example code or to run this example in your browser via Binder.
Simulated users: benchmarking with a known ground truth#
A person cannot tell us how far a gallery is from what they “really” want, so
IEC algorithms have been compared with simulated users since the early days
(Takagi, 2001; Breukelaar et al., 2006). The SimulatedUser
holds a hidden target and answers every protocol through a Thurstonian (or
Bradley–Terry–Luce) choice model, with optional fatigue, lapses, position bias,
limited attention, drift of taste and satisficing.
The choice model#
Probability that the user prefers A to B as a function of the true utility difference, estimated from 400 random pairs per noise level. Thurstone’s law of comparative judgment gives \(\Phi(\Delta u / \sqrt{2}\sigma)\).
import matplotlib.pyplot as plt
import numpy as np
import easyiec as ei
from easyiec.problems import SyntheticPreference
from easyiec.strategies import InteractiveGA
from easyiec.validation import make_individuals, run_benchmark
problem = SyntheticPreference(dim=4, kind="sphere", seed=0)
rng = np.random.default_rng(1)
fig, ax = plt.subplots(figsize=(6.4, 3.6))
for k, noise in enumerate([0.02, 0.05, 0.1, 0.2]):
user = ei.SimulatedUser(problem, target="random", noise=noise, seed=2)
d, win = [], []
for _ in range(400):
a, b = make_individuals(problem.random(rng, 2))
fb = user.evaluate(ei.Query("pairs", [a, b]))
d.append(user.true_utility(a.genome) - user.true_utility(b.genome))
win.append(fb.pair_results[0][2])
d, win = np.array(d), np.array(win)
edges = np.linspace(-0.6, 0.6, 13)
mid = (edges[1:] + edges[:-1]) / 2
p = [win[(d >= lo) & (d < hi)].mean() if ((d >= lo) & (d < hi)).sum() > 5 else np.nan
for lo, hi in zip(edges[:-1], edges[1:])]
ax.plot(mid, p, "o-", ms=4, lw=1.5, label=f"σ = {noise}", color=ei.viz._style.color_for(k))
ax.axhline(0.5, color="0.8", lw=0.8)
ax.set_xlabel("true utility difference u(A) − u(B)", fontsize=8)
ax.set_ylabel("P(A preferred)", fontsize=8)
ax.legend(frameon=False, fontsize=8)
ax.set_title("Thurstonian choice probabilities of the simulated user", fontsize=9)

Text(0.5, 1.0, 'Thurstonian choice probabilities of the simulated user')
The same algorithm under six user models#
Fatigue increases the noise with the number of items seen; lapses replace answers by random ones; position bias favours the first images; limited attention means only the first few images are really looked at.
users = {
"careful": dict(noise=0.03),
"noisy": dict(noise=0.15),
"tiring": dict(noise=0.03, fatigue=1.0, fatigue_scale=60),
"lapsing 20 %": dict(noise=0.03, lapse=0.2),
"position-biased": dict(noise=0.03, position_bias=0.15),
"inattentive (4)": dict(noise=0.03, attention=4),
}
bench = run_benchmark(
problems={"sphere-5": lambda: SyntheticPreference(dim=5, kind="sphere", seed=1)},
strategies={"GA": lambda: InteractiveGA(pop_size=9)},
users={n: (lambda p, s, kw=kw: ei.SimulatedUser(p, target="random", seed=s, **kw)) for n, kw in users.items()},
seeds=range(10), generations=20)
print(bench.summary.groupby("evaluator")["best_true"].agg(["mean", "std"]).round(3))
ei.viz.plot_convergence(bench.curves, by="user", title="interactive GA, six simulated users, 10 seeds")
plt.show()

mean std
evaluator
careful 0.988 0.008
inattentive (4) 0.985 0.005
lapsing 20 % 0.964 0.021
noisy 0.866 0.270
position-biased 0.902 0.230
tiring 0.986 0.010
Total running time of the script: (0 minutes 1.298 seconds)