Skip to content

Add custom metric functions and ratio metric linearization#55

Closed
artemkuzmenko2501-del wants to merge 1 commit intomainfrom
feature/ab-test-abstraction
Closed

Add custom metric functions and ratio metric linearization#55
artemkuzmenko2501-del wants to merge 1 commit intomainfrom
feature/ab-test-abstraction

Conversation

@artemkuzmenko2501-del
Copy link
Collaborator

Summary

  • Custom metric functions in Tester: новый параметр metric_funcs: Dict[str, Callable] позволяет передавать произвольные функции вместо имён колонок. Работает для методов theory и empiric. Функции, переданные в run(), переопределяют те, что заданы в конструкторе.
  • LinearizationTransformer: трансформер для ratio-метрик (например, revenue/orders). Линеаризует метрику по формуле linearized_i = numerator_i - ratio * denominator_i, где ratio считается на референсных данных при fit().
  • Preprocessor.linearize(): интегрирует линеаризацию в существующую chain-архитектуру с поддержкой сериализации и replay.

Changes

  • ambrosia/tester/tester.pymetric_funcs в __init__ и run(), standalone test()
  • ambrosia/tester/handlers.pyTheoreticalTesterHandler поддерживает callable извлечение значений
  • ambrosia/preprocessing/transformers.py — новый LinearizationTransformer
  • ambrosia/preprocessing/preprocessor.py — метод linearize() + импорт трансформера
  • ambrosia/preprocessing/__init__.py — экспорт LinearizationTransformer
  • CLAUDE.md — документация архитектуры для будущих сессий

Test plan

  • 8 новых тестов: metric_funcs (конструктор, run, override) + linearize (формула, chain, сериализация, имя по умолчанию)
  • 1074 существующих теста прошли без изменений

🤖 Generated with Claude Code

- Tester now accepts metric_funcs dict mapping metric names to callables,
  enabling ratio and composite metrics without pre-computing columns
- LinearizationTransformer added for ratio metrics (e.g. revenue/orders):
  linearized_i = numerator_i - ratio * denominator_i, where ratio is
  estimated on reference data passed to fit()
- Preprocessor.linearize() integrates linearization into the existing
  chain pattern with full serialization/replay support
- 8 new tests covering metric_funcs constructor/run/override behaviour
  and linearize formula, chaining, serialization

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@artemkuzmenko2501-del
Copy link
Collaborator Author

Closing: need to target dev branch instead of main

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