Repository navigation
hydra: score any target grouping; per-group error output - #199
Merged
Merged
Conversation
zzylol
force-pushed
the
hydra/target-grouping
branch
from
October 10, 2026 04:16
6c89d47 to
62ae3f0
Compare
zzylol
force-pushed
the
74-polars-tagged-subkeys
branch
from
October 11, 2026 16:35
912c3ab to
4149b7e
Compare
Every hydra-* row (lib and polars, all five variants and hydra-univmon's four statistics) takes `--group-columns J,K,...` (default `0`, today's behavior) in place of the hardcoded SCORED_LABEL_COLUMN. A subpopulation probe is now positioned (`Vec<Option<String>>`, Some at the grouped columns), so `hydra_shared::query` asks any non-empty subset of the key columns and the polars baselines look up `subset_key` with that subset's mask (`group_key`, generalizing `prefix_key`). Each grouped comparator reports its per-group error in its own metric (relative error; mean rank error for hydra-kll) and summarises it as err_mean, err_p50, err_p90, err_max, groups_scored, plus schema_width, records and fanned_mass. `--per-group-out PATH` writes the rows as `group_key,n_q,error`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
…curacy - Group keys escape `\`, `:` and `;` as polars_shared::subset_key does. - Groups that cannot be scored (zero true statistic, e.g. zero entropy) are written with an empty `error`, so n_q sums to the stream's records. - --per-group-out with no accuracy measurement is refused instead of writing an empty file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
zzylol
force-pushed
the
hydra/target-grouping
branch
from
October 11, 2026 16:36
8f73ed3 to
bc770e3
Compare
zzylol
added a commit
that referenced
this pull request
Oct 11, 2026
# Conflicts: # README.md # aqpbm-cli/src/rows/mod.rs # aqpbm-cli/src/rows/statistic.rs # aqpbm-cli/tests/hydra_grouping.rs # aqpbm-core/src/accuracy/subpopulation/frequency_vector.rs # aqpbm-core/src/accuracy/subpopulation/rank_error.rs # sketch-bench/src/wrappers/hydra_univmon/sketchlib.rs
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.
Implements PR 2 of the Hydra spec (design doc #193 §5.1): every Hydra row can be scored at any target grouping, and reports error per group, not only a mean.
What changed
--group-columns J,K,...(default0, which is today's behavior) replaces the hardcodedSCORED_LABEL_COLUMN. It applies to everyhydra-*row (lib and polars, all five variants and hydra-univmon's four statistics) and accepts any non-empty subset of the label columns. A column at or past the value column is refused by name.Vec<Option<String>>, withSomeat the grouped columns.hydra_shared::querypasses it toquery_keyas is, so{1}is asked as[None, Some(v)]rather than as column 0. The polars baselines look the group up withsubset_key(parts, mask)over the same mask (group_key, which generalizesprefix_key).err_mean,err_p50,err_p90,err_maxover the scored groups, plusgroups_scored,schema_width(d),records(N) andfanned_mass(N·(2^d−1)). Each family uses its own metric, lower is better:are_alluses (they are still listed in--per-group-out, with an emptyerror).are_all,mean_rank_err, ...) are unchanged.--per-group-out PATHwritesgroup_key,n_q,error, one row per group, heaviest group first. Unscored groups (zero true value, e.g. zero entropy) have an emptyerror, son_qsums to N and a later coverage step sees every group.group_keyis the tagged labels, e.g.label0:a;label1:x, with\,:and;escaped aspolars_shared::subset_keydoes. The flag is refused for non-Hydra rows, when no accuracy measurement is requested, and when both query and merge accuracy are requested (the file holds a single measurement).configs/datagen/hydra_*.yamlcomments now document both flags.Tests
aqpbm-cli/tests/hydra_grouping.rs: runs hydra-cms, cs, hll, kll and univmon-l1-norm, lib on a large grid and polars, at--group-columns 1and0,1. The label values overlap across columns. Polars scoreserr_max = 0and lib scores ≤ 0.01. The test also checksschema_width,recordsandfanned_mass, that the CSV'sn_qsum to N, and that the CSV keys name the asked columns. A second test refuses a group column past the labels; a third refuses--per-group-outwith no accuracy measurement and checks no file is left.entropyunit test: over both columns, three zero-entropy groups are listed with no error,n_qsums to 6,groups_scored= 1.subpopulationunit test: a label holding:,;and\renders escaped (label1:x\:y\;z\\;label2:).querycompacting theSomes to a prefix: lib err_max 0.69 at--group-columns 1, test fails.group_keyusing a prefix mask: the polars row fails the same way.l1_normunit test on a fixed 4-group case checks err_mean 0.5, p50 0.5, p90 1, max 1,groups_scored,fanned_massand the per-group rows and their order. Removing the sort fails it. A second unit test covers column 1 alone ([None, Some], keyslabel1:*).frequencyunit test: a group's error is the mean over its own pairs (err_mean 0.125 vsare_all0.5/3).cargo fmt --check,cargo clippy --workspace --all-targets -D warningsandcargo test --workspaceall pass.Evidence (release build)
N = 200000, d = 2, fanned_mass = 600000 in every row. Polars scores 0 on every field at every grouping.
At
{0,1}the groups are small against M/W, and their error is far larger than the coarser groupings' (§2.1).Round-1 review fixes: key escaping, every group listed (empty
errorwhen unscored), and refusal of--per-group-outwithout accuracy. The CSV still recomputes the per-group rows separately fromscore(not reused; it would needScoreto return them).🤖 Generated with Claude Code
https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis