From 3dc148c0f07f82cb1f717a6cf87aca1a3815c43b Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 1 Sep 2025 10:04:32 +0100 Subject: [PATCH 1/4] Add benefit cap calibration --- policyengine_uk_data/utils/loss.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/policyengine_uk_data/utils/loss.py b/policyengine_uk_data/utils/loss.py index 3c1af947a..2ed60950e 100644 --- a/policyengine_uk_data/utils/loss.py +++ b/policyengine_uk_data/utils/loss.py @@ -362,6 +362,17 @@ def pe_count(*variables): target_names.append(name) target_values.append(float(row["Total"]) * uprating) + # Benefit cap counts + + benefit_cap_reduction = sim.calculate("benefit_cap_reduction", map_to="household").values + df["dwp/benefit_capped_households"] = benefit_cap_reduction > 0 + target_names.append("dwp/benefit_capped_households") + target_values.append(115_000) # https://www.gov.uk/government/statistics/benefit-cap-number-of-households-capped-to-february-2025/benefit-cap-number-of-households-capped-to-february-2025 + + df["dwp/benefit_cap_total_reduction"] = benefit_cap_reduction + target_names.append("dwp/benefit_cap_total_reduction") + target_values.append(60 * 52 * 115_000) # same source as above, multiply avg cap amount by total capped population + combined_targets = pd.concat( [ targets, From ec262ac43ef15ced890c1514d9fa1c1646631a8d Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 1 Sep 2025 10:04:54 +0100 Subject: [PATCH 2/4] Versioning --- changelog_entry.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..e3f502579 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + added: + - Calibration to benefit cap statistics. From 54cecc302917524af21b8a9ee4e4f5933abbe557 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 1 Sep 2025 10:05:03 +0100 Subject: [PATCH 3/4] Format --- policyengine_uk_data/utils/loss.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/policyengine_uk_data/utils/loss.py b/policyengine_uk_data/utils/loss.py index 2ed60950e..b720fffcf 100644 --- a/policyengine_uk_data/utils/loss.py +++ b/policyengine_uk_data/utils/loss.py @@ -364,14 +364,20 @@ def pe_count(*variables): # Benefit cap counts - benefit_cap_reduction = sim.calculate("benefit_cap_reduction", map_to="household").values + benefit_cap_reduction = sim.calculate( + "benefit_cap_reduction", map_to="household" + ).values df["dwp/benefit_capped_households"] = benefit_cap_reduction > 0 target_names.append("dwp/benefit_capped_households") - target_values.append(115_000) # https://www.gov.uk/government/statistics/benefit-cap-number-of-households-capped-to-february-2025/benefit-cap-number-of-households-capped-to-february-2025 + target_values.append( + 115_000 + ) # https://www.gov.uk/government/statistics/benefit-cap-number-of-households-capped-to-february-2025/benefit-cap-number-of-households-capped-to-february-2025 df["dwp/benefit_cap_total_reduction"] = benefit_cap_reduction target_names.append("dwp/benefit_cap_total_reduction") - target_values.append(60 * 52 * 115_000) # same source as above, multiply avg cap amount by total capped population + target_values.append( + 60 * 52 * 115_000 + ) # same source as above, multiply avg cap amount by total capped population combined_targets = pd.concat( [ From c8cb70bb7f6632935822222b80c7b0fc9802db56 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 1 Sep 2025 10:16:11 +0100 Subject: [PATCH 4/4] Cast to float --- policyengine_uk_data/utils/loss.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/policyengine_uk_data/utils/loss.py b/policyengine_uk_data/utils/loss.py index b720fffcf..9ee89d6d5 100644 --- a/policyengine_uk_data/utils/loss.py +++ b/policyengine_uk_data/utils/loss.py @@ -367,13 +367,15 @@ def pe_count(*variables): benefit_cap_reduction = sim.calculate( "benefit_cap_reduction", map_to="household" ).values - df["dwp/benefit_capped_households"] = benefit_cap_reduction > 0 + df["dwp/benefit_capped_households"] = (benefit_cap_reduction > 0).astype( + float + ) target_names.append("dwp/benefit_capped_households") target_values.append( 115_000 ) # https://www.gov.uk/government/statistics/benefit-cap-number-of-households-capped-to-february-2025/benefit-cap-number-of-households-capped-to-february-2025 - df["dwp/benefit_cap_total_reduction"] = benefit_cap_reduction + df["dwp/benefit_cap_total_reduction"] = benefit_cap_reduction.astype(float) target_names.append("dwp/benefit_cap_total_reduction") target_values.append( 60 * 52 * 115_000