Add custom metric functions and ratio metric linearization#56
Open
artemkuzmenko2501-del wants to merge 3 commits intodevfrom
Open
Add custom metric functions and ratio metric linearization#56artemkuzmenko2501-del wants to merge 3 commits intodevfrom
artemkuzmenko2501-del wants to merge 3 commits intodevfrom
Conversation
- 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>
- Remove Python 3.7 from CI matrix (GitHub Actions dropped it, EOL) - Replace Python 3.10 with 3.11/3.12 (nmslib has unfixable C++ build failures on modern gcc; 3.11+ already passes in scheduled runs) - Make nmslib an optional dependency so missing it doesn't break install - Lazy-import nmslib in knn.py with a clear ImportError message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Extend python constraint to >=3.8, <3.13 to support 3.11/3.12 in CI - Restrict nmslib optional dep to python <3.11 (build fails on newer gcc) - Regenerate poetry.lock to fix 'Extra [knn] is not specified' error Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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.py—metric_funcsв__init__иrun(), standalonetest()ambrosia/tester/handlers.py—TheoreticalTesterHandlerподдерживает callable извлечение значенийambrosia/preprocessing/transformers.py— новыйLinearizationTransformerambrosia/preprocessing/preprocessor.py— методlinearize()+ импорт трансформераambrosia/preprocessing/__init__.py— экспортLinearizationTransformerCLAUDE.md— документация архитектуры для будущих сессийTest plan
metric_funcs(конструктор, run, override) +linearize(формула, chain, сериализация, имя по умолчанию)