Skip to content

Основной сценарий на реальных данных: auto-оценщик, интервалы V, согласие оценщиков, подбор C пропенсити - #45

Merged
Yurashku merged 5 commits into
mainfrom
main-scenario
Oct 28, 2026

Conversation

@Yurashku

Copy link
Copy Markdown
Owner

Зачем

Проверить основной сценарий на открытых реальных данных с известной истиной и доработать библиотеку там, где он оказался не готов. Сценарий:

  • логи без пропенсити;
  • сравнение двух политик;
  • автоматический выбор оценщика;
  • V(A), V(B) и Δ с интервалами;
  • вердикт доверия и согласие оценщиков.

Что показала проверка (docs/real_data.md)

Hillstrom — рандомизированная email-рассылка, 64 тыс. клиентов, 3 действия. Логи прод-политики без пропенсити строятся отбором с отказом, истина — IPS на отложенной рандомизированной половине.

  • На 10 разбиениях интервалы Δ накрыли истину во всех прогонах.
  • visit: вывод «хуже» в 10 из 10, при истине −1.49 ± 0.31 п.п.
  • Оценщики согласованы во всех 20 парах «прогон × метрика».

Open Bandit Dataset (ZOZOTOWN), 34 товара. A — случайная политика, пропенсити из логов убраны; B — Thompson Sampling, истина — её CTR в параллельном A/B-тесте (4 млн показов).

  • Без пропенсити: «BTS лучше Random», V(BTS) = 0.70% [0.58; 0.81] при истине 0.674%, Δ = +0.20 п.п. [+0.10; +0.31] при истине +0.16.
  • Это совпадает с оценкой по логированным пропенсити.

Что изменено в библиотеке

  • estimator="auto" по умолчанию. Основной оценщик выбирается по тому, залогированы ли пропенсити (сейчас это DR), и отчёт объясняет выбор. Выбора по самому узкому интервалу намеренно нет.
  • V(A) и V(B) с интервалами в главной таблице, summary() и compare().
  • Итог согласия оценщиков: «согласованы / расходятся / проверка неполная», плюс разброс Δ по пяти оценщикам. Причина уровня доверия — в первой строке отчёта.
  • Подбор C модели пропенсити по out-of-fold log-loss. Главная находка OBD: с C = 1 модель переобучалась на разреженных признаках, и DR давал 0.51% и «разница не обнаружена».
  • Модель исхода:
    • бинарные логистические регрессии на узкой матрице решаются методом Ньютона: обучение в 4–5 раз быстрее и точнее;
    • прогноз строится по одному действию, иначе на OBD требовалось около 6 ГБ;
    • блок x×a отключается, только если не помещается в память, и об этом сообщает находка outcome_without_interactions.
  • Прогноз длительности bootstrap откалиброван на реальных прогонах: раньше занижал время втрое.
  • Новые файлы. examples/real_data.py воспроизводит проверку и сам скачивает данные. Раздел 5 туториала — основной сценарий в сравнении с истиной.

Отвергнутая идея — выбирать дизайн модели исхода по out-of-fold ошибке: на Hillstrom DM потерял весь эффект. Описано в docs/methodology.md.

Проверено локально

  • flake8 и быстрые тесты.
  • Медленные статистические тесты.
  • validate.py --runs 30 --clients 2000 --n-boot 60 --strict: результаты совпали с прежними до 3–4 знака.
  • Туториал исполняется.
  • build и twine check --strict.

🤖 Generated with Claude Code

Yurashku and others added 5 commits October 27, 2026 23:58
- Binary logistic regressions on designs up to 300 columns use the
  newton-cholesky solver: 4-5x faster than lbfgs on Hillstrom and closer
  to the optimum (lbfgs at default tolerance stops early). Validation
  results are unchanged to the fourth significant digit.
- Predictions are built one action at a time instead of stacking k
  copies of the design (6 GB on 50k OBD rows with 34 actions).
- The x*a interaction block is dropped only when the design would exceed
  3e7 cells; the decision is made once on the full sample and pinned for
  bootstrap replicates. Choosing the design by out-of-fold error was
  tried and rejected: it does not see errors in action contrasts and on
  Hillstrom removed the heterogeneity DM needs (-0.05 vs -1.33 pp).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- estimator="auto" (default) picks the primary estimator from whether
  propensities are logged (DR in both cases today) and the report says
  why; selection by the narrowest interval is deliberately not used.
- The main table and summary() show V(A) and V(B) with intervals next
  to delta; compare() shows them too.
- Each metric gets an agreement verdict from the DR-IPS and DR-DM checks
  (agree / disagree / unclear) and the spread of delta across all five
  estimators in units of the primary SE.
- The headline names the findings behind a caution/unreliable verdict.
- New info finding outcome_without_interactions when x*a is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-loss

On the Open Bandit Dataset (uniform logging, 34 actions, 66 mostly
sparse features) LogisticRegression with C=1 overfit: estimated
propensities ranged 0..0.98 instead of 1/34 and DR put V(BTS) at 0.51%
against a truth of 0.67%. C is now chosen on the full sample by OOF
log-loss over 10..1e-6, walking from weak to strong regularization and
stopping after two consecutive increases (the strong-regularization end
is a flat plateau whose noise would stop a walk from that side too
early). With C=1e-5 DR gives 0.70%, the same as with logged
propensities. The chosen C is pinned for bootstrap replicates and the
tuning time is excluded from the bootstrap ETA. Custom propensity
models are used as given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The ETA assumed a 4x speedup on 8 cores; real runs on Hillstrom and
  the Open Bandit Dataset show about 2x (replicates compete for memory
  bandwidth and core frequency), so OBD was promised 10 minutes and took
  28. The speedup is now jobs/4.
- Trust reasons lowercased the first letter of every finding title,
  turning "IPS и DR расходятся" into "iPS ...".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- examples/real_data.py downloads Hillstrom (randomized e-mail campaign)
  and the Open Bandit Dataset and runs the main scenario against an
  independent truth: logs without propensities, two policies, automatic
  estimator, intervals for V(A), V(B) and delta, trust and agreement.
- docs/real_data.md: Hillstrom over 10 splits (all delta intervals cover
  the truth; visit "worse" 10/10, estimators agree in 20/20) and OBD
  (without propensities BTS is "better", V(BTS) 0.70% [0.58; 0.81]
  against a truth of 0.674%, same as with logged propensities), plus the
  library changes these checks led to.
- README: main scenario section, auto estimator, value intervals and
  agreement verdict, realistic timings. Methodology: estimator choice,
  outcome design rule, propensity C tuning, agreement verdict, new
  finding code. Tutorial section 5 is now the main scenario, compared
  with the analytic truth, and re-executed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yurashku
Yurashku merged commit 0e022e9 into main Oct 28, 2026
8 checks passed
@Yurashku
Yurashku deleted the main-scenario branch October 28, 2026 14:47
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