Skip to content

Findings: methodology review (rebased into research/) + measured bias-gate finding - #32

Merged
ahmed-khalil-hafsi merged 2 commits into
mainfrom
findings/methodology-review
Sep 10, 2026
Merged

ahmed-khalil-hafsi merged 2 commits into
mainfrom
findings/methodology-review

Conversation

@ahmed-khalil-hafsi

@ahmed-khalil-hafsi ahmed-khalil-hafsi commented Jul 8, 2026 •

Copy link
Copy Markdown
Owner

Rebases the July methodology audit onto current main, moves it into research/, and adds a measured follow-on finding. No core changes.

Why this sat for two months

It bundles four findings, so merging it meant accepting a four-item agenda. Two have since been re-derived independently, which is evidence the bundle was too big to act on — not that the findings were wrong. This PR splits the bundle apart instead.

What changed in this update

  • Rebased onto main and moved all three files into research/ — the PR still targeted analysis/, which 429ee7c renamed away. Merging as-is would have resurrected the dead folder.
  • Added a Status header to methodology_review.md so nothing dangles:
Finding Status
1. Retransformation bias Superseded by log_retransformation_bias.md
2. Bias gate flunks good models Open, sharpened by the new doc below
3. Split hygiene / raw-holdout reporting Open, narrower than ranked — only bites --feature-outliers drop; default warn unaffected. Sub-item "wire find_leaky_features into the CLI" partly landed (it's in the MCP server, not the CLI).
4. Group-aware splits Open — no GroupShuffleSplit/GroupKFold in src/
Tier-2/3: silent OOD predictions Worked up as out_of_domain_flag.md, merged in #36

The new finding: the gate measures n, not bias

assess_model() calls a model biased when residual_bias_p <= 0.05 — a t-test on price-space residuals (quality.py:333). A p-value answers "could this be noise?", which depends on sample size. It does not answer "is this big enough to matter?", which is what the verdict claims to report.

Measured by holding the model and its bias fixed and varying only the holdout size — 200 random draws per row, heavy-equipment model, R² 0.737:

n holdout median mean-residual median bias p % flagged unreliable
50 −5.4% 3.2e-01 10%
250 −6.1% 6.4e-02 47%
1,000 −5.7% 9.2e-05 96%
16,000 −5.8% 9.8e-55 100%

The bias column is flat. The verdict column goes 10% → 100%.

It fails in both directions, because unbiased = p > 0.05 reads failure to reject as proof of no bias:

  • Large holdout → guaranteed unreliable. Both flagship case studies earn it today despite median residuals of +1.7% — the user with the best price history is likeliest to be told their model can't be trusted.
  • Small holdout → free pass. The battery-management-IC model carries a −7.5% mean residual on 30 parts and is stamped trustworthy. This over-trust direction is the one the July review explicitly ruled out ("failure direction is under-trust").
Dataset R² mean resid median resid p verdict today
used cars (n=16,000) 0.735 −27.2% +1.7% 4.4e-71 unreliable
heavy equipment (n=16,000) 0.737 −5.8% +1.7% 9.8e-55 unreliable
battery mgmt ICs (n=30) 0.606 −7.5% −0.8% 5.9e-01 trustworthy

One correction to the July review

It reported both case-study models flipping to trustworthy/usable when tested in log space. An independent refit reproduces this for heavy equipment (p 9.8e-55 → 0.585) but not for used cars (4.4e-71 → 0.034, still failing) — its −27.2% mean residual is larger than a retransformation artifact can explain. So testing in log space is not on its own a sufficient fix, and a verdict hinging on 0.034 vs 0.585 is itself the argument for a materiality floor.

Reproduce

python research/bias_gate_materiality.py
python research/benchmark_methodology_gaps.py [fasteners|cars]

Statistics/ML audit of the modeling core, with the top findings quantified
on the fasteners and used-cars case studies:

- Retransformation bias: log-target back-transform via plain exp() runs
  7.9% low in mean terms on used-cars; Duan smearing fixes the mean
  (residual -$1,419 -> +$2) but is median-hostile on heavy tails
  (fasteners S=4.05).
- Residual-bias gate tests price-space residuals: both case-study models
  flip from 'unreliable' to trustworthy/usable when tested in log space;
  gate also lacks a materiality threshold.
- Pre-split outlier/selection leakage: negligible per se, but drop-policy
  cleaned holdouts flatter reported R^2 by +0.06-0.10 at full scale.

Adds analysis/methodology_review.md (ranked findings + proposed follow-up
PR order) and case-studies/benchmark_methodology_gaps.py (reproducible
measurements, results checked in).
…-gate finding

Rebases the July methodology audit onto current main and moves all three files
into research/ (the folder analysis/ was renamed to in 429ee7c), so the finding
sits with its script and results per the research/README hygiene rule.

Adds a Status header to methodology_review.md marking what has moved since July:
finding 1 superseded by log_retransformation_bias.md, finding 2 sharpened here,
the Tier-2/3 out-of-distribution bullet shipped as #36; findings 3 and 4 still
open and unaddressed in core (verified: no GroupShuffleSplit/GroupKFold in src/;
find_leaky_features is wired into the MCP server but not the CLI).

Adds bias_gate_materiality.{md,py,json}. assess_model() calls a model biased
when a t-test on price-space residuals reaches p <= 0.05 — a question whose
answer depends on sample size, not on whether the bias is big enough to matter.
Measured by holding the model and its bias fixed and varying only the holdout
size (200 draws per size, heavy-equipment model, R2 0.737): median mean-residual
stays flat at -5.4% to -6.1% while the share of draws flagged 'unreliable' goes
10% (n=50) -> 47% (n=250) -> 96% (n=1,000) -> 100% (n=16,000). Same model, same
bias, opposite verdict.

The gate fails in both directions, because `unbiased = p > 0.05` reads failure
to reject as proof of no bias. Large holdout: any offset eventually flags, so
the user with the best price history is likeliest to be told the model can't be
trusted — both flagship case studies currently earn 'unreliable' despite median
residuals of +1.7%. Small holdout: the battery-management-IC model carries a
-7.5% mean residual on 30 parts and is stamped 'trustworthy'. That over-trust
direction is the one the July review explicitly ruled out.

Also corrects the July review on one point: it reported both case-study models
flipping to trustworthy/usable when tested in log space. An independent refit
reproduces this for heavy equipment (p 9.8e-55 -> 0.585) but not for used cars
(4.4e-71 -> 0.034, still failing), whose -27.2% mean residual is larger than a
retransformation artifact. Testing in log space is therefore not on its own a
sufficient fix.

No core changes.
@ahmed-khalil-hafsi
ahmed-khalil-hafsi force-pushed the findings/methodology-review branch from 1f763be to ff4c3ce Compare September 10, 2026 09:35
@ahmed-khalil-hafsi ahmed-khalil-hafsi changed the title Findings: methodology review — measured Tier-1 gaps (no core changes) Findings: methodology review (rebased into research/) + measured bias-gate finding Sep 10, 2026
@ahmed-khalil-hafsi
ahmed-khalil-hafsi merged commit 93a0d43 into main Sep 10, 2026
13 checks passed
@ahmed-khalil-hafsi
ahmed-khalil-hafsi deleted the findings/methodology-review branch September 10, 2026 09:44
ahmed-khalil-hafsi added a commit that referenced this pull request Sep 15, 2026
…-gate finding (#32)

* Findings: methodology review with measured Tier-1 gaps (no core changes)

Statistics/ML audit of the modeling core, with the top findings quantified
on the fasteners and used-cars case studies:

- Retransformation bias: log-target back-transform via plain exp() runs
  7.9% low in mean terms on used-cars; Duan smearing fixes the mean
  (residual -$1,419 -> +$2) but is median-hostile on heavy tails
  (fasteners S=4.05).
- Residual-bias gate tests price-space residuals: both case-study models
  flip from 'unreliable' to trustworthy/usable when tested in log space;
  gate also lacks a materiality threshold.
- Pre-split outlier/selection leakage: negligible per se, but drop-policy
  cleaned holdouts flatter reported R^2 by +0.06-0.10 at full scale.

Adds analysis/methodology_review.md (ranked findings + proposed follow-up
PR order) and case-studies/benchmark_methodology_gaps.py (reproducible
measurements, results checked in).

* Findings: rebase methodology review into research/, add measured bias-gate finding

Rebases the July methodology audit onto current main and moves all three files
into research/ (the folder analysis/ was renamed to in 429ee7c), so the finding
sits with its script and results per the research/README hygiene rule.

Adds a Status header to methodology_review.md marking what has moved since July:
finding 1 superseded by log_retransformation_bias.md, finding 2 sharpened here,
the Tier-2/3 out-of-distribution bullet shipped as #36; findings 3 and 4 still
open and unaddressed in core (verified: no GroupShuffleSplit/GroupKFold in src/;
find_leaky_features is wired into the MCP server but not the CLI).

Adds bias_gate_materiality.{md,py,json}. assess_model() calls a model biased
when a t-test on price-space residuals reaches p <= 0.05 — a question whose
answer depends on sample size, not on whether the bias is big enough to matter.
Measured by holding the model and its bias fixed and varying only the holdout
size (200 draws per size, heavy-equipment model, R2 0.737): median mean-residual
stays flat at -5.4% to -6.1% while the share of draws flagged 'unreliable' goes
10% (n=50) -> 47% (n=250) -> 96% (n=1,000) -> 100% (n=16,000). Same model, same
bias, opposite verdict.

The gate fails in both directions, because `unbiased = p > 0.05` reads failure
to reject as proof of no bias. Large holdout: any offset eventually flags, so
the user with the best price history is likeliest to be told the model can't be
trusted — both flagship case studies currently earn 'unreliable' despite median
residuals of +1.7%. Small holdout: the battery-management-IC model carries a
-7.5% mean residual on 30 parts and is stamped 'trustworthy'. That over-trust
direction is the one the July review explicitly ruled out.

Also corrects the July review on one point: it reported both case-study models
flipping to trustworthy/usable when tested in log space. An independent refit
reproduces this for heavy equipment (p 9.8e-55 -> 0.585) but not for used cars
(4.4e-71 -> 0.034, still failing), whose -27.2% mean residual is larger than a
retransformation artifact. Testing in log space is therefore not on its own a
sufficient fix.

No core changes.

---------

Co-authored-by: Ahmed K. Hafsi <25119333+ahmed-hafsi@users.noreply.github.com>
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