Skip to content

Enhance quality report with CD support and diagnostics#472

Merged
donboyd5 merged 1 commit intomasterfrom
pr3-quality-report
Mar 26, 2026
Merged

Enhance quality report with CD support and diagnostics#472
donboyd5 merged 1 commit intomasterfrom
pr3-quality-report

Conversation

@donboyd5
Copy link
Copy Markdown
Collaborator

@donboyd5 donboyd5 commented Mar 26, 2026

PR: Enhance quality report with CD support and diagnostics

This is PR 3 of 4 adding congressional district (CD) weighting to TMD.
Based on PRs 1-2 (now merged). See PR #470 for the full roadmap.

Summary

Major expansion of quality_report.py with new diagnostic sections and CD scope support. No solver or target changes.

New features

  • --output flag: Save report to file (auto-generated filename in weight directory, or specify a path)
  • --scope cds: Full CD support — auto-discovers areas from log files instead of requiring a hardcoded state list
  • Scope/timestamp header: Shows scope label, generation time, cumulative and wall-clock solve time
  • Aggregate multiplier distribution table: Combined distribution across all area-record pairs
  • Weight distribution by AGI stub: National vs sum-of-areas returns and AGI per bin, with percent change
  • Diff columns: All comparison tables now show dollar differences alongside percent differences
  • Per-bin distortion analysis: Checks a curated set of 16 variables × all AGI bins, marks T (targeted) vs U (untargeted), sorted by distortion, shows top 30 out of N combinations
  • Top-N per-area detail: Shows all areas for states (<=60), top 20 by violations/wRMSE for CDs/counties
  • Human-readable labels: Converts internal target labels to readable form

Files changed (1 file, +728 / -74)

File Change
tmd/areas/quality_report.py All changes above

Test plan

make format                                                # no changes
make lint                                                  # passes clean
python -m tmd.areas.quality_report --scope states          # terminal output
python -m tmd.areas.quality_report --scope states --output # saves to file

The quality report reads existing log and weight files — no solving needed. CD scope (--scope cds) will work after PR 4 implements generation of CD weight files and the user solves for those weights.

Prepared by @donboyd5 and Claude Code

…nalysis

Major expansion of quality_report.py:
- --output flag to auto-save report to file
- Scope/timestamp header with solve time summary
- Aggregate multiplier distribution across all areas
- Weight distribution by AGI stub (national vs sum-of-areas)
- Per-bin bystander analysis (targeted vs untargeted distortion)
- Top-N per-area detail for large area sets (CDs, counties)
- Auto-discover areas from log files
- Support --scope cds

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@donboyd5 donboyd5 merged commit 959a7d0 into master Mar 26, 2026
1 check passed
@donboyd5 donboyd5 deleted the pr3-quality-report branch March 26, 2026 10:26
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