Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

budget.households is the sum of squared household weights

オープン
#766 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@PavelMakarchuk がすでに取り組んでいます。

2026年10月12日 から。

  • #767 @PavelMakarchuk による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
20/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python

調査の方向性

Start in simulation_output_budget.build_budgetary_impact and inspect how _sum_output_variable handles the household MicroDataFrame and its household_weight column. The existing test test_builder_budgetary_impact_uses_materialized_columns_and_uk_state_tax_zero uses plain DataFrames; add coverage with a real MicroDataFrame and verify the household count is 3 for weights [1, 2]. An open linked pull request (#767) is already addressing this issue.

索引モデルが issue の本文から書いたものです。

説明

Problem

The economy comparison's budget.households is the sum of squared household weights, not the household count. It is about 10⁴ times too high on every run, national and state:

Run (/us/economy/{reform}/over/2) budget.households Actual households
region=state/ny, 2026 135,597,233,840 ~7.5 million
region=state/ca, 2026 197,620,236,261 ~13.5 million
region=state/va, 2027 44,192,009,994 ~3.3 million

Cause

simulation_output_budget.build_budgetary_impact sets households=_sum_output_variable(baseline, "household_weight", entity="household").

_sum_output_variable returns float(data[variable].sum()). Here data is the household MicroDataFrame, which policyengine weights by household_weight. So data["household_weight"] is a weighted MicroSeries, and its .sum() is Σ w × w.

Weights [1, 2] give 5.0 instead of 3.0. The existing test (test_builder_budgetary_impact_uses_materialized_columns_and_uk_state_tax_zero) uses plain pd.DataFrames, so it never caught this.

This came in with 36d3be0 ("adapt simulation worker to PolicyEngine v4 outputs").

The other budget fields are correct. They are meant to be weighted sums.

Impact

Clients divide by this field. For example, policyengine-app-v2 computes the headline average change per household as -budget.budgetary_impact / budget.households. That number is therefore about 10⁴ times too small on every report.

Fix

Count entities with a plain sum of their weight column, and test it on a real MicroDataFrame.

主要言語
Python
スター
1
フォーク
1
平均マージ
1日 4時間
マージ済み PR(30日)
26

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PolicyEngine/policyengine-sim-api のほかの issue

PolicyEngine/policyengine-sim-api の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。