Skip to content

Feature: bring proxy-hint detection (chi-squared) to the web profiler #738

Closed

Description

@yakew7

Where: assets/profiler-engine.js, profiler.html (dropzone hint text), faircode/proxy.py, faircode/SPEC.md section 3.

Current gap: faircode profile/compare --proxy-hints (CLI-only) flags column pairs strongly associated via chi-squared + Cramér's V - "this column may be a proxy for that protected attribute." SPEC.md explicitly says this is "intentionally NOT part of the JS engine" because it's opt-in/informational and never affects the score, and profiler.html's own dropzone hint tells web users to go use the CLI for it: "Proxy-hint detection: use faircode profile/compare --proxy-hints from the CLI." A web-only user with no Python/CLI access currently cannot get proxy-hint analysis at all, even though the JS engine already computes crosstabs for intersections.

Repro:

$ grep -n "Proxy-hint detection" profiler.html
178-179: Proxy-hint detection: use faircode profile/compare --proxy-hints from the CLI.
$ grep -n "intentionally NOT part of the JS engine" faircode/SPEC.md
(matches, section 3)

Suggested approach: port the chi-squared test to JS as a separate, explicitly-informational module (mirroring the "opt-in, never touches score, not parity-tested" contract already established for the Python side) - a JS chi-square CDF only needs a regularized incomplete gamma function, a well-known ~20-line implementation. Surface it in the web UI as an opt-in "Check for proxy columns" button/toggle inside the results section, reusing the existing labelize-by-kind logic already in profiler-engine.js. Since SPEC.md's parity contract only covers profile()/compare(), adding this as a separate, clearly-labeled module keeps the bit-for-bit parity test unaffected.

Activity

  1. yakew7 commented on Sep 30, 2026

    @yakew7
    OwnerAuthor

    Fixed in 9d79f73: ported the chi-squared proxy-hint test to a new FairCodeProfiler.proxyHints() in assets/profiler-engine.js (Numerical Recipes gammp/gammq for the p-value, no scipy needed in-browser), wired up as an opt-in "Check for proxy columns" button below a profile's results. Verified the JS math against scipy.stats.chi2_contingency on both a correlated pair and an unrelated pair (including the 2x2 Yates-correction path) - exact chi2/Cramer's V match, p-value agreeing to 1e-6. Stays out of profile()/compare() per SPEC.md's existing parity contract, so the bit-for-bit parity test is unaffected. Full suite (517 passed), ruff, em-dash check, broken-links check all clean.

  2. added a commit that references this issue on Sep 30, 2026
    9d79f73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions