Skip to content

Conversation

@baogorek
Copy link
Collaborator

@baogorek baogorek commented Jan 15, 2026

Summary

This has really morphed into a hodge-podge of updates. Technically, the health insurance premium variable is included in the matrix builder, but this PR doesn't include any specific testing of the variable. Thus, @juaristi22 's PR #475 will go in first to cover the testing of this variable.

I'm also going to hold off on linting until #475 goes in, so that the "Files changed" doesn't increase unnecessarily.

  • Add build_calibration_matrix.py runner script for building sparse calibration matrices with combined SNAP and health insurance premium targets
  • Add test_sparse_matrix_builder.py with tests for person-level aggregation and combined target support
  • Update changelog for minor version bump

Details

The health_insurance_premiums_without_medicare_part_b variable is a person-level target that needs to be aggregated to household level. The existing sparse_matrix_builder.py already handles this through PolicyEngine's map_to="household" parameter, which automatically sums person-level values to household level while preserving totals.

Closes #472, Closes #429

Test plan

  • Run pytest policyengine_us_data/tests/test_sparse_matrix_builder.py - 3 tests pass
  • Run python build_calibration_matrix.py from the local_area_calibration directory
  • Verify entity aggregation preserves totals (person-level sum == household-level sum)

🤖 Generated with Claude Code

@baogorek baogorek changed the title Add health insurance premiums to local area calibration Add health insurance premiums to local area calibration, a matrix builder function, Modal model fitting Jan 22, 2026
@baogorek baogorek requested a review from juaristi22 January 22, 2026 03:01
baogorek and others added 14 commits January 23, 2026 16:04
- Add build_calibration_matrix.py runner for building X_sparse matrix
  with SNAP + health_insurance_premiums_without_medicare_part_b targets
- Add test_sparse_matrix_builder.py with tests for person-level
  aggregation and combined target support
- Update changelog_entry.yaml

Closes #472

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add fit_calibration_weights.py for L0-regularized weight optimization
- Add l0-python as optional dependency under [project.optional-dependencies]
- Uses SparseCalibrationWeights from l0.calibration package
- Builds calibration matrix for all 436 congressional districts
- Filters to achievable targets before fitting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace sparsity_log with calibration_log that tracks per-target
performance (estimate, target, error metrics) across epochs.
Update Modal runner to return both weights and log files.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Avoid confusion with fit_calibration_weights.py which contains the actual fitting logic.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@baogorek baogorek force-pushed the health-insurance-premiums branch from 4545c14 to ba25e3e Compare January 23, 2026 21:04
baogorek and others added 3 commits January 23, 2026 16:32
The versioning workflow bumps the version in pyproject.toml but
never updated uv.lock, causing Modal builds to fail with
"uv sync --locked" since the lockfile was stale.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…nate dense reweighting

Remove the dense optimization path from enhanced CPS (only sparse L0 weights
are needed), eliminating the mv/cp workaround in the Makefile. Remove both
TEST_LITE and LOCAL_AREA_CALIBRATION environment variable flags, generating
all datasets unconditionally in a single pass. Merge the data-local-area
target into the data target.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Close the h5 file handle and release the Microsimulation reference before
writing to the same file path. Also fix pre-existing black formatting in
3 files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
baogorek and others added 3 commits January 26, 2026 10:22
- Add "snap" to variables filter in fit_calibration_weights.py to include
  National SNAP targets (in different stratum_group_id than 4)
- Remove redundant test_sparse_matrix_builder.py (tests consolidated in
  test_matrix_national_variation.py)
- Remove redundant build_calibration_matrix.py (functionality covered by
  fit_calibration_weights.py)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@baogorek baogorek merged commit d58eac6 into main Jan 26, 2026
7 checks passed
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.

Add health insurance premiums to local area calibration Integrate L0 package for CPS household calibration

3 participants