Skip to content

Случайные политики, известная логирующая политика, смесь версий модели и честный выбор лучшего - #47

Merged
Yurashku merged 2 commits into
mainfrom
random-and-competition
Oct 29, 2026

Conversation

@Yurashku

Copy link
Copy Markdown
Owner

Зачем

Два сценария, которые раньше не поддерживались:

  1. Сравнение существующей скоринговой политики со случайной выдачей.
  2. Корректное соревнование нескольких таргетирующих моделей с выбором лучшей, при любой логирующей политике, в том числе при ежемесячно обновляемой детерминированной модели.

Что добавлено

Политики

  • ps.uniform() — равномерная случайная выдача.
  • ps.random_like(source, by=...) — случайная выдача с балансом действий наблюдаемой политики или любой другой. Параметр by сохраняет баланс внутри групп, например по месяцам.
  • ps.mixture(...) — смесь политик.

Логи без пропенсити, но с известной политикой

  • logging_policy= вместо колонки пропенсити: пропенсити считаются точно. Детерминированная A честно блокируется.
  • Логи нескольких версий модели: logging_policy={метка: политика}, logger=. Пропенсити — смесь версий (balanced IPS, Agarwal et al., 2017), так что даже детерминированные версии вместе дают исследование. Предпосылка проверяется находками:
    • logger_shift — состав клиентов в периодах;
    • logger_drift — сезонность отклика на клиентах, которым все версии рекомендуют одно и то же.

Соревнование кандидатов (compare, Leaderboard.best)

  • Одновременные интервалы Δ: честны и для лидера, выбранного по данным.
  • Попарные сравнения кандидатов между собой (board.pairwise).
  • Набор лучших с гарантией 1 − α.
  • Ограничители по другим метрикам.

Туториалы

  • examples/tutorial.ipynb — новые разделы: сравнение со случайной политикой, соревнование трёх разных моделей, логи нескольких версий. Добавлено объяснение, почему случайность нужна в логах, а не в оцениваемой политике, и как быть с «обвязкой» из менеджеров.
  • examples/monthly_versions.ipynb — отдельный разбор для ежемесячных версий:
    • лучшая версия против наивного помесячного сравнения (интервалы примерно вдвое уже);
    • почему случайную выдачу нельзя оценить без случайного среза и как её оценить с 10% среза;
    • детекция сезонности.

Проверено

  • Новые медленные статистические тесты:
    • одновременные интервалы накрыли все Δ сразу в 93.5% из 200 симуляций, обычные — в 84%;
    • истинно лучший попал в набор лучших в 99.5% случаев;
    • смесь двух детерминированных версий: смещение −0.001, покрытие 0.97.
  • В обоих туториалах все результаты сверены с истиной, все интервалы её накрывают.
  • flake8, быстрые и медленные тесты. Оба туториала исполняются, второй добавлен в CI.

🤖 Generated with Claude Code

Yurashku and others added 2 commits October 29, 2026 12:34
Policies
- ps.uniform(), ps.random_like(source, by=...) and ps.mixture(...):
  random assignment with the observed (or any policy's) mix of actions,
  overall or within groups such as months, and mixtures of policies.

Logging policy instead of a propensity column
- logging_policy= computes propensities exactly from a known rule A;
  a deterministic A is blocked as before.
- Several loggers (logging_policy={label: policy}, logger=): balanced
  IPS mixture propensities (Agarwal et al., 2017), so even deterministic
  model versions used in different months provide exploration where
  they disagree. New findings check the assumption: logger_shift (period
  predictable from client features) and logger_drift (response differs
  across periods on rows where all versions choose the same action).

Competition
- compare() adds simultaneous intervals for every candidate's delta,
  pairwise differences with simultaneous intervals and Romano-Wolf
  p-values, and Leaderboard.best(metric, guardrails): leader, the set of
  candidates not significantly beaten (contains the true best w.p. at
  least 1 - alpha), and non-inferiority guardrails on other metrics.
- Slow tests: simultaneous coverage 0.935 vs 0.84 marginal, true best in
  the set 0.995 (200 runs); two deterministic loggers: bias -0.001,
  coverage 0.97 (100 runs).

Simulator: OfferSimulator.versions() for regularly retrained models and
simulate(shift=) for seasonal response.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tutorial.ipynb: comparison with random assignment (overall and with
  the candidate's mix), a competition of three different targeting
  models with board.best and guardrails, logs of several model versions,
  and why randomness is needed in the logs rather than in the evaluated
  policy (including human "wrapping" of model recommendations).
- monthly_versions.ipynb: a separate end-to-end pipeline for a scoring
  model retrained monthly: best version on all clients (intervals about
  half as wide as naive per-month means), why random assignment cannot
  be evaluated without an exploration slice and how a 10% slice fixes
  it, and seasonality detection. Executed in CI.
- README, methodology (estimator selection by competition, logging
  policies and mixtures, new finding codes, assumptions), CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yurashku
Yurashku merged commit 5aa74bd into main Oct 29, 2026
8 checks passed
@Yurashku
Yurashku deleted the random-and-competition branch October 29, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant