Note
Go to the end to download the full example code or to run this example in your browser via Binder.
Preferential Bayesian optimization, line search and gallery#
When every answer is expensive, a statistical model of the evaluator’s preferences pays off. A Gaussian process is fitted to pairwise answers with the probit likelihood of Chu and Ghahramani (2005); the next comparison is chosen by an acquisition function (González et al., 2017). Sequential line search (Koyama et al., 2017) asks for the best point on a slider through the incumbent, and the sequential gallery (Koyama et al., 2020) for the best cell of a 2-D grid — far more information per question than a single pair.
Three model-based strategies on a two-dimensional landscape#
import matplotlib.pyplot as plt
import numpy as np
import easyiec as ei
from easyiec.problems import SyntheticPreference
from easyiec.strategies import PreferentialBO, SequentialGallery, SequentialLineSearch
problem = SyntheticPreference(dim=2, kind="ellipsoid", seed=4)
runs = {}
for name, strategy in {"PBO (pairs)": PreferentialBO(), "line search (slider)": SequentialLineSearch(n_samples=7),
"gallery (3×3 grid)": SequentialGallery(grid=3)}.items():
user = ei.SimulatedUser(problem, target="random", noise=0.03, seed=8)
runs[name] = (strategy, user, ei.run(problem, strategy, user, generations=15, seed=8))
print(f"{name:22s} best utility {runs[name][2].best_true:.3f} after {runs[name][2].summary()['queries']} questions")
PBO (pairs) best utility 0.900 after 15 questions
line search (slider) best utility 0.710 after 15 questions
gallery (3×3 grid) best utility 0.990 after 15 questions
Utility per question#
A line or gallery answer carries several pairwise preferences at once.
fig, ax = plt.subplots(figsize=(6.4, 3.4))
for k, (name, (_, _, res)) in enumerate(runs.items()):
ei.viz.plot_anytime(res, ax=ax, x="n_queries", label=name, color=["#285780", "#D55E00", "#009E73"][k],
show_shown=False)
ax.legend(frameon=False, fontsize=8)
ax.set_title("best utility vs. number of questions", fontsize=9)
plt.show()

Total running time of the script: (0 minutes 0.792 seconds)
