From a4030501548042bb6690d5276abc0ddef2a9998a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Thu, 5 Nov 2026 00:46:15 +0000 Subject: [PATCH 01/20] Count every UK floor in true source households (#931) Every UK floor now counts the survey household each copy and clone keeps in source_household_id, through one country-neutral reader: microcosm.build.source_lineage.record_sources reads any entity's true source through household membership on a declared copy lineage, and the UK declares its lineage once (household_lineage.UK_COPY_LINEAGE). receipt_counts.SOURCE_HOUSEHOLD_COLUMN is the shared source_household_id, not household_source_id, the support channel's immediate parent, which a copy made from a clone sets to the clone. The reader refuses a frame without the column and a null source; the stages before the SPI support channel say so, and their households are their own sources. The receipts of stages 10 to 12 and 15, the SPI pay floor and pension coherence, company cars, SPI benefit coherence, UC take-up's pools, the legacy closure, salary sacrifice and its bonus donor floor, Carer's Allowance, the trading allowance, the support floor, the sampled-rung private-rent region floor and the single-year age, dataset-size, council-tax, BRMA, weighted-integrity, benefit-cap and UC-relationship reports count through it. The five finite stages that declared household_source_id declare source_household_id, and UC take-up's pooling text and two notes name it. A static test refuses a distinct count of household_id, person_household_id or household_source_id in the UK runtime and tools outside two named structural checks, and the counting modules are bound into every stage hash that imports them. The two columns agree on every household row of today's spine, so no spine output moves. uk_spine.json and the coverage manifest are regenerated. Co-Authored-By: Claude Opus 5.5 --- ...31-uk-floors-count-true-sources.changed.md | 1 + .../src/microcosm/build/source_lineage.py | 169 +++++++++++++ .../uk/calibration_measure_exclusions.json | 2 +- .../src/microcosm/build/uk/source_stages.json | 4 +- .../src/microcosm/build/uk/spec/sources.yaml | 4 +- .../uk_runtime/carers_allowance_take_up.py | 11 +- .../build/uk_runtime/company_cars.py | 11 +- .../build/uk_runtime/frs_annual_income.py | 40 ++- .../build/uk_runtime/frs_person_draws.py | 33 ++- .../microcosm/build/uk_runtime/frs_take_up.py | 36 +-- .../src/microcosm/build/uk_runtime/graph.py | 10 +- .../build/uk_runtime/graph_kernels.py | 38 ++- .../build/uk_runtime/graph_population.py | 3 +- .../build/uk_runtime/household_lineage.py | 37 +++ .../uk_runtime/legacy_closure_take_up.py | 10 +- .../uk_runtime/private_rent_localisation.py | 31 ++- .../build/uk_runtime/receipt_counts.py | 83 +++++-- .../build/uk_runtime/salary_sacrifice.py | 15 +- .../build/uk_runtime/single_year_ages.py | 34 +-- .../build/uk_runtime/size_evaluation.py | 29 ++- .../build/uk_runtime/spi_benefit_coherence.py | 15 +- .../microcosm/build/uk_runtime/spi_income.py | 22 +- .../build/uk_runtime/support_floor.py | 28 ++- .../uk_runtime/trading_allowance_receipts.py | 17 +- .../microcosm/build/uk_runtime/uc_take_up.py | 15 +- .../uk/test_uk_carers_allowance_take_up.py | 2 +- .../tests/engine/uk/test_uk_company_cars.py | 2 +- .../uk/test_uk_council_tax_liability_tool.py | 4 +- .../engine_free/shared/test_source_lineage.py | 141 +++++++++++ .../uk/test_uk_carers_allowance_take_up.py | 12 +- .../engine_free/uk/test_uk_company_cars.py | 4 +- .../uk/test_uk_council_tax_liability_tool.py | 2 +- .../uk/test_uk_frs_annual_income.py | 14 +- .../tests/engine_free/uk/test_uk_graph.py | 72 +++++- .../uk/test_uk_legacy_closure_take_up.py | 10 +- .../uk/test_uk_pension_coherence.py | 2 +- .../uk/test_uk_private_rent_localisation.py | 6 + .../uk/test_uk_property_purchases.py | 12 +- .../engine_free/uk/test_uk_receipt_counts.py | 230 ++++++++++++++++++ .../uk/test_uk_regional_home_values.py | 10 +- .../uk/test_uk_salary_sacrifice.py | 2 + .../uk/test_uk_spi_benefit_coherence.py | 1 + .../engine_free/uk/test_uk_spi_income.py | 1 + .../uk/test_uk_stochastic_tools.py | 2 + .../engine_free/uk/test_uk_support_floor.py | 16 +- .../uk/test_uk_trading_allowance_receipts.py | 2 +- .../engine_free/uk/test_uk_uc_take_up.py | 2 +- .../test_uk_weighted_integrity_measurement.py | 26 +- tools/compare_uk_council_tax_liability.py | 15 +- tools/diagnose_uk_benefit_cap.py | 8 +- tools/diagnose_uk_uc_relationships.py | 6 +- tools/emit_uk_brma_distribution.py | 26 +- ...measure_uk_weighted_integrity_baselines.py | 30 ++- 53 files changed, 1118 insertions(+), 240 deletions(-) create mode 100644 changelog.d/931-uk-floors-count-true-sources.changed.md create mode 100644 packages/microcosm-build/src/microcosm/build/source_lineage.py create mode 100644 packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py diff --git a/changelog.d/931-uk-floors-count-true-sources.changed.md b/changelog.d/931-uk-floors-count-true-sources.changed.md new file mode 100644 index 0000000000..2617489db2 --- /dev/null +++ b/changelog.d/931-uk-floors-count-true-sources.changed.md @@ -0,0 +1 @@ +Every UK floor now counts true source households, the survey household each copy and clone keeps in `source_household_id`, through one reader (#931). The reader is the new country-neutral `microcosm.build.source_lineage.record_sources`: a country declares its copy lineage once (the entity copies are made of, its source column and each copying step's marker and ordinal columns), and every record of any entity reads its source through household membership. `receipt_counts.record_source_households` is the UK's entry on `household_lineage.UK_COPY_LINEAGE`, and `receipt_counts.SOURCE_HOUSEHOLD_COLUMN` is the shared `source_household_id`, no longer `household_source_id`, the support channel's immediate parent. The reader refuses a frame without the source column, and a null source; a stage that runs before the SPI support channel says so (`before_copies`), and its households are then their own sources unless the frame already carries copy lineage. The take-up signal receipts, the apprentice receipt and the annual income receipts (stages 10 to 12 and 15), the SPI pay floor and pension coherence (which read `household_source_id` without the null refusal), company cars, the SPI benefit coherence, UC take-up's pools, the legacy closure, salary sacrifice's receipt and bonus donor floor, Carer's Allowance, the trading allowance, the support floor, the single-year age report, the dataset-size evaluation, the sampled-rung private-rent region floor, and the council-tax, BRMA-distribution, weighted-integrity, benefit-cap and UC-relationship tools count through it. The two columns agree on every household row of today's spine and pool, so no spine output moves. The single-year age report and the dataset-size evaluation now count a zero-weight row as carrying nothing and a household's copies once, so their support counts can fall; the weighted-integrity tool's carriers are now distinct sources, not rows. The five finite stages that declared `household_source_id` declare `source_household_id`, UC take-up's pooling text and the Carer's Allowance and support-floor notes name it, and a static test refuses any distinct count of `household_id`, `person_household_id` or `household_source_id` in the UK runtime and tools outside two named structural checks. The receipts' counting modules (`receipt_counts`, `household_lineage`, `source_lineage`) are bound into the implementation hash of every stage whose module or helpers import one of them; eight stages that counted through `receipt_counts` did not bind it, so an edit to it alone left their cache keys in place. diff --git a/packages/microcosm-build/src/microcosm/build/source_lineage.py b/packages/microcosm-build/src/microcosm/build/source_lineage.py new file mode 100644 index 0000000000..9baba045ab --- /dev/null +++ b/packages/microcosm-build/src/microcosm/build/source_lineage.py @@ -0,0 +1,169 @@ +"""Each record's true source, read the same way in every country. + +A build copies survey records: support copies of a household, the arms of a +split, and clones that each take an area of their own. Every copy keeps the +survey household it was made from in ``source_household_id`` +(:data:`~microcosm.frame.concepts.SOURCE_HOUSEHOLD_ID_COLUMN`), its true +source, and each copying step marks its copies on the household table with a +marker column, an ordinal column, or both (:class:`CopyBranch`). A country +declares its copy lineage once (:class:`CopyLineage`) and passes it in; this +module names no country's columns. + +:func:`record_sources` gives every record of any entity its true source, +through household membership: the key a disclosure floor counts distinct +sources by, so that a household's copies and clones count once +(microcosm#931). A frame without the source column is refused, since its +copies would count as sources of their own, unless the caller runs before the +first copying step and says so (``before_copies``): each household is then its +own source, and its id serves, as long as the frame carries no declared copy +column either. +""" + +from __future__ import annotations + +from collections.abc import Mapping +from dataclasses import dataclass + +import numpy as np +import pandas as pd + +from microcosm.frame import EntitySchema +from microcosm.frame.concepts import SOURCE_HOUSEHOLD_ID_COLUMN + +__all__ = [ + "CopyBranch", + "CopyLineage", + "record_sources", +] + + +@dataclass(frozen=True) +class CopyBranch: + """One copying step: a branch of every copy's path, in path order. + + ``index`` names the copy's ordinal column, zero on an original, and + ``marker`` the column marking the step's copies: ``copy`` is its value on + a copy and ``original`` its value on an original. A step declares either + column or both; with both, a row is a copy exactly when its ordinal is + nonzero, and a marker-only step's copy takes ordinal one. + """ + + name: str + index: str | None = None + marker: str | None = None + copy: object = True + original: object = False + + def __post_init__(self) -> None: + if not isinstance(self.name, str) or not self.name: + raise ValueError("A copy branch needs a name.") + if self.index is None and self.marker is None: + raise ValueError(f"Copy branch {self.name!r} declares no column.") + if self.copy == self.original: + raise ValueError( + f"Copy branch {self.name!r} marks copies and originals alike." + ) + + @property + def columns(self) -> tuple[str, ...]: + """The household columns the step writes.""" + return tuple(c for c in (self.index, self.marker) if c is not None) + + +@dataclass(frozen=True) +class CopyLineage: + """How a country's copies record where they come from. + + ``entity`` is the group entity copies are made of (a household), whose + table carries the true-source column ``source`` and every branch's + columns; ``branches`` are the copying steps in path order. + """ + + entity: str + branches: tuple[CopyBranch, ...] + source: str = SOURCE_HOUSEHOLD_ID_COLUMN + + def __post_init__(self) -> None: + names = [branch.name for branch in self.branches] + if len(set(names)) != len(names): + raise ValueError("Copy branches need distinct names.") + columns = self.copy_columns + if len(set(columns)) != len(columns) or self.source in columns: + raise ValueError("Copy branches need distinct columns of their own.") + + @property + def copy_columns(self) -> tuple[str, ...]: + """Every column a copying step writes, in path order.""" + return tuple(c for branch in self.branches for c in branch.columns) + + +def record_sources( + tables: Mapping[str, pd.DataFrame], + schema: EntitySchema, + entity: str, + lineage: CopyLineage, + *, + before_copies: bool = False, +) -> np.ndarray: + """Every ``entity`` record's true source, in the table's row order. + + A household reads its own source; a person reads its household's, through + ``schema.membership_column``; any other group reads the household its + members share, and a unit with no members or members in several + households is refused. A null source, or a person whose household is + absent, is refused: it would drop out of a distinct count, so a cell would + read fewer sources than it rests on. Without the source column the frame + is refused, unless ``before_copies`` says the caller runs before the first + copying step and the frame carries none of the declared copy columns. + """ + + household = tables[lineage.entity] + household_ids = household[schema.id_column(lineage.entity)] + if lineage.source in household.columns: + sources = household[lineage.source] + if sources.isna().any(): + raise ValueError( + f"{lineage.entity}.{lineage.source} is null on some rows: every " + "record needs its true source." + ) + else: + copied = [c for c in lineage.copy_columns if c in household.columns] + if copied: + raise ValueError( + f"The {lineage.entity} table carries copy lineage {copied} " + f"without {lineage.source!r}, so its copies have no true source." + ) + if not before_copies: + raise ValueError( + f"The {lineage.entity} table lacks {lineage.source!r}, the true " + "source every record is counted by." + ) + sources = household_ids + if entity == lineage.entity: + return sources.to_numpy() + by_household = pd.Series(sources.to_numpy(), index=household_ids.to_numpy()) + person = tables[schema.person_entity] + members = person[schema.membership_column(lineage.entity)] + if not members.isin(by_household.index).all(): + raise ValueError( + f"Every {schema.person_entity} needs a {lineage.entity} on the frame." + ) + if entity == schema.person_entity: + return members.map(by_household).to_numpy() + units = pd.DataFrame( + { + "unit": person[schema.membership_column(entity)].to_numpy(), + "household": members.to_numpy(), + } + ).drop_duplicates() + if units["unit"].duplicated().any(): + raise ValueError( + f"A {entity} with members in several {lineage.entity}s has no source." + ) + unit_households = pd.Series( + units["household"].to_numpy(), index=units["unit"].to_numpy() + ) + unit_ids = tables[entity][schema.id_column(entity)] + if not unit_ids.isin(unit_households.index).all(): + raise ValueError(f"A {entity} without members has no source.") + return unit_ids.map(unit_households).map(by_household).to_numpy() diff --git a/packages/microcosm-build/src/microcosm/build/uk/calibration_measure_exclusions.json b/packages/microcosm-build/src/microcosm/build/uk/calibration_measure_exclusions.json index c5a50d6f25..3f2139ce0d 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/calibration_measure_exclusions.json +++ b/packages/microcosm-build/src/microcosm/build/uk/calibration_measure_exclusions.json @@ -74,7 +74,7 @@ "max_dropped_published_share": 0.1 } ], - "reason": "Zero-support floor: a row in one of the floor's scopes (the UC payment-distribution and benefit-cap amount bands, the HMRC SPI income bands by total income and SPI Table 3.10's self-employment income bands, and the band-H council-tax rows by English region) whose compiled matrix row reaches no source household (household_source_id) with a positive prior weight cannot be fitted by any weights (the solver's initialiser refuses a nonzero target with no support), so it is dropped from the solve, not pooled. A row that some households carry stays bound however few they are; when one or two distinct source households carry it, its model figures are withheld from every written surface (CD171's absolute floor of three, receipt_counts.UK_DISCLOSURE_FLOOR, to which María's ruling of 2026-10-29 moved the floor of ten). Each scope holds one unit, because its share ceiling sums published values. The floor's receipt reports each target's dropped published total and each scope's dropped share, and the run refuses when a scope's drops pass either of its ceilings or when a per-row exclusion names a row the floor drops.", + "reason": "Zero-support floor: a row in one of the floor's scopes (the UC payment-distribution and benefit-cap amount bands, the HMRC SPI income bands by total income and SPI Table 3.10's self-employment income bands, and the band-H council-tax rows by English region) whose compiled matrix row reaches no source household (source_household_id) with a positive prior weight cannot be fitted by any weights (the solver's initialiser refuses a nonzero target with no support), so it is dropped from the solve, not pooled. A row that some households carry stays bound however few they are; when one or two distinct source households carry it, its model figures are withheld from every written surface (CD171's absolute floor of three, receipt_counts.UK_DISCLOSURE_FLOOR, to which María's ruling of 2026-10-29 moved the floor of ten). Each scope holds one unit, because its share ceiling sums published values. The floor's receipt reports each target's dropped published total and each scope's dropped share, and the run refuses when a scope's drops pass either of its ceilings or when a per-row exclusion names a row the floor drops.", "tracking": "microcosm#1095", "approved_by": "juaristi22", "adjudication": "microcosm#1095 U3, ruled 2026-10-16 with the fifth ports PR (floor 10) and revised 2026-10-21 with #1333: a cell that rests on fewer than 10 records is no reason to leave a row out, only a measured distortion of the calibration is. The floor drops only rows no household carries, the benefit-cap amount bands join its scope and their per-row entries retire, and the figures of rows under 10 source households are withheld, as the BRMA rows' are (under three since María's ruling of 2026-10-29). The thirteen entries it retired (the eleven benefit-cap amount bands and the two HMRC £500k to £1m cells) and the A/B that retired them: experiments/1095-uk-thin-row-binding-receipts.md. Extended on 2026-10-22 (María's ruling on the next policyengine-uk bump) to the HMRC SPI income-band families and the band-H council-tax rows by region, in scopes of one unit each with their own ceilings. On #1333's policyengine-uk 2.145.0 spine every HMRC £1m-and-over cell and every band-H region cell has carriers. The three band-H region entries retire and their rows bind, with their figures withheld where fewer than 10 source households carry them (fewer than three since María's ruling of 2026-10-29, receipt_counts.UK_DISCLOSURE_FLOOR); the ten HMRC £1m-and-over cells, bound on arm 1, distorted their neighbours and stay held on that measurement, so the HMRC scopes cover the bands below them. Extended on 2026-10-29 in microcosm#1420, in answer to the independent review's finding 7 and pending María's confirmation, to the SPI families microcosm#1418 binds, Table 3.7's other income by total-income band and Table 3.10's self-employment bands from GBP 1 to GBP 10,000: a row of theirs that no household carries is dropped and receipted as its siblings' rows are, not refused. The ceilings are unchanged, so the HMRC amounts scope's 2-row cap, signed for seven families, now covers nine, and the counts scope's, signed for seven, now covers eight; María confirms or re-sizes them (the re-reviews of microcosm#1420, H and 4). Extended on 2026-11-01 in microcosm#1428, in answer to its independent review's finding 11, to Table 3.10's employment-income counts by self-employment band, which #1428 binds over the same bands: a row of theirs no household carries is dropped and receipted, not refused. The counts scope's 2-row cap now covers nine families.", diff --git a/packages/microcosm-build/src/microcosm/build/uk/source_stages.json b/packages/microcosm-build/src/microcosm/build/uk/source_stages.json index afa12a1670..36586bd836 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/source_stages.json +++ b/packages/microcosm-build/src/microcosm/build/uk/source_stages.json @@ -7038,7 +7038,7 @@ "family_type": "two FRS claimant or partner roles make a couple; children are UC children or qualifying young people and other non-claimants under 20 (the calibration measure's uc_calibration_family_type)", "award_bands": "GBP 1,200 a year (DWP's GBP 100 a month), (1,200 i, 1,200 (i + 1)] in whole pence for i < 25, and above GBP 30,000", "targets": "DWP Stat-Xplore Households on Universal Credit by family type and monthly award band, mean of April to December 2025", - "pooling": "adjacent bands within a family type, lowest first, until the drawn units rest on minimum_pool_sources distinct household_source_id values; a short last pool joins the one before it. Then, lowest first, a pool that cannot meet DWP's count (its undrawn entitled units' expected claims exceed the count, or the count exceeds them plus the weight of every drawn unit) is held at the nearer of those ends and passes its gap to the other pools, nearest first, the one with more room first at equal distance and the lower on a tie, each taking what its room allows; a gap no pool can take leaves the family type unreachable. With the fits, a passed shortfall's room is the pool's undrawn claims plus the weight of its drawn units with neither a young claimant or partner nor the LCWRA element, less its count (age_fit, lcwra_fit)", + "pooling": "adjacent bands within a family type, lowest first, until the drawn units rest on minimum_pool_sources distinct source_household_id values; a short last pool joins the one before it. Then, lowest first, a pool that cannot meet DWP's count (its undrawn entitled units' expected claims exceed the count, or the count exceeds them plus the weight of every drawn unit) is held at the nearer of those ends and passes its gap to the other pools, nearest first, the one with more room first at equal distance and the lower on a tie, each taking what its room allows; a gap no pool can take leaves the family type unreachable. With the fits, a passed shortfall's room is the pool's undrawn claims plus the weight of its drawn units with neither a young claimant or partner nor the LCWRA element, less its count (age_fit, lcwra_fit)", "minimum_pool_sources": 30, "drawn_units": "entitled, non-reporting units of the population that the engine does not move off their legacy benefits (legacy_benefits_closed) and that report none, since a legacy benefit the engine leaves in place ends once the unit claims UC", "undrawn_claims": "a reporter at 1, a moved unit at the claim probability uc_legacy_closure_take_up's rule gives it (dwp_move_to_uc_facts.json), a unit keeping income-related ESA at 0, any other at its stored flag", @@ -8172,7 +8172,7 @@ "rewrites": [ "would_claim_carers_allowance" ], - "notes": "Runs after the SPI income chain, UC capital coherence, the Pension Credit and Child Benefit redraws and salary_sacrifice, so the earnings test reads the pay salary sacrifice converts (microcosm#1095 B5); a CGT copy draws as the member it copies, placed with it as one record of their joint weight, so every clone carries its source's draw (microcosm#1319). frs_spine sets would_claim_carers_allowance from reported receipt and the SPI income chain re-derives it from the refilled receipt on the rows it redraws, so that care_hours qualifies a carer for the Universal Credit carer element without paying the allowance to every carer (#882). A carer above the earnings limit cannot report the allowance, so no reform that widens it reached a carer who would claim once entitled: the April 2025 rise of the limit from £151 to £196 a week brought an estimated 61,000 more people into eligibility (Independent Review of Carer's Allowance Overpayments, July 2025, chapter 7). One temporary engine materialization at the survey year, on the frame's own values, gives each person's is_gainfully_employed_for_carers_allowance and carers_allowance_earnings (consumed only); the engine reads a year's parameters at 30 April, so the limit is 2024-25's £151. The allowance is paid only for caring for a severely disabled person (SSCBA 1992 s. 70(2)), which the care hours do not record (microcosm#1418), and policyengine-uk reads it from cares_for_severely_disabled_person (2.177.3, pe-uk#2860) wherever care_hours reach the minimum. frs_disability writes that input from the FRS care tab and the benefits of the people each carer gives their largest band of care, and hmrc_spi_income_spine takes it again on the SPI channel's households; a carer of someone outside the household with no qualifying member is drawn at the share of the in-household carers who report no allowance and care for a qualifying member, the rule this stage drew its own pool by until it read the input (María's decision (a) of 2026-10-28; A3 of the November event-data plan's PR3, microcosm#1095, María's choices of 2026-11-10; she signed these notes on 2026-11-11). The pool is the carers at the hours whom the input holds caring for a severely disabled person. A person in that pool whose care_hours reach the engine's gov.dwp.carers_allowance.min_hours (35), who reports no allowance and whom the earnings test holds gainfully employed claims at the take-up contract's carers_allowance_newly_entitled rate (0.6, María's ruling of 2026-10-20, sensitivity 0.45 to 0.75) on the person's identity-keyed uniform (seed 0, salt would_claim_carers_allowance), placed by weight within strata and rotated by a start drawn per stratum, so that each stratum claims the rate of its eligible weight to within one record and each eligible carer with probability equal to the rate (weight_balanced_uniforms, policyengine-uk's stratified_uniform with a random start; microcosm#1418 and the independent review of microcosm#1420): the route (whether the carer's largest in-household band, frs_care_hours_in_household, reaches the hours), whether the benefit unit reports a means-tested benefit at the survey year, and the survey-year weekly earnings band, one weekly rate wide above the limit and open above three. would_claim = reported OR (eligible AND position < rate). A reporter stays true; a carer under the limit who reports no allowance stays false, as the survey records them entitled and not claiming. Scotland is drawn too (María's ruling of 2026-10-23): there the flag is Carer Support Payment's, which policyengine-uk pays only under its own earnings limit from 2.146.1 (PolicyEngine/policyengine-uk#2473), and the receipt reports Scotland apart. The earnings test is read before salary_sacrifice moves some contributors' pension amounts out of their pay, so a drawn carer whom that conversion takes under the survey year's limit keeps the flag although the file then shows them entitled and not reporting. The stage rebuilds the flag from reported receipt and refuses a frame whose flag no longer follows it. Its receipt bands support on distinct source households (household_source_id), and gives a weighted total only where three or more carry it and a share only where neither of its sides rests on one or two; it lists each stratum's realised share against its target, and the stage refuses a take-up stratum whose drawn weight misses its share by more than its heaviest record, the most the rotated placement allows, so the balance holds on every build (Anthony's reviews of microcosm#1420). The stage has no health gate." + "notes": "Runs after the SPI income chain, UC capital coherence, the Pension Credit and Child Benefit redraws and salary_sacrifice, so the earnings test reads the pay salary sacrifice converts (microcosm#1095 B5); a CGT copy draws as the member it copies, placed with it as one record of their joint weight, so every clone carries its source's draw (microcosm#1319). frs_spine sets would_claim_carers_allowance from reported receipt and the SPI income chain re-derives it from the refilled receipt on the rows it redraws, so that care_hours qualifies a carer for the Universal Credit carer element without paying the allowance to every carer (#882). A carer above the earnings limit cannot report the allowance, so no reform that widens it reached a carer who would claim once entitled: the April 2025 rise of the limit from £151 to £196 a week brought an estimated 61,000 more people into eligibility (Independent Review of Carer's Allowance Overpayments, July 2025, chapter 7). One temporary engine materialization at the survey year, on the frame's own values, gives each person's is_gainfully_employed_for_carers_allowance and carers_allowance_earnings (consumed only); the engine reads a year's parameters at 30 April, so the limit is 2024-25's £151. The allowance is paid only for caring for a severely disabled person (SSCBA 1992 s. 70(2)), which the care hours do not record (microcosm#1418), and policyengine-uk reads it from cares_for_severely_disabled_person (2.177.3, pe-uk#2860) wherever care_hours reach the minimum. frs_disability writes that input from the FRS care tab and the benefits of the people each carer gives their largest band of care, and hmrc_spi_income_spine takes it again on the SPI channel's households; a carer of someone outside the household with no qualifying member is drawn at the share of the in-household carers who report no allowance and care for a qualifying member, the rule this stage drew its own pool by until it read the input (María's decision (a) of 2026-10-28; A3 of the November event-data plan's PR3, microcosm#1095, María's choices of 2026-11-10; she signed these notes on 2026-11-11). The pool is the carers at the hours whom the input holds caring for a severely disabled person. A person in that pool whose care_hours reach the engine's gov.dwp.carers_allowance.min_hours (35), who reports no allowance and whom the earnings test holds gainfully employed claims at the take-up contract's carers_allowance_newly_entitled rate (0.6, María's ruling of 2026-10-20, sensitivity 0.45 to 0.75) on the person's identity-keyed uniform (seed 0, salt would_claim_carers_allowance), placed by weight within strata and rotated by a start drawn per stratum, so that each stratum claims the rate of its eligible weight to within one record and each eligible carer with probability equal to the rate (weight_balanced_uniforms, policyengine-uk's stratified_uniform with a random start; microcosm#1418 and the independent review of microcosm#1420): the route (whether the carer's largest in-household band, frs_care_hours_in_household, reaches the hours), whether the benefit unit reports a means-tested benefit at the survey year, and the survey-year weekly earnings band, one weekly rate wide above the limit and open above three. would_claim = reported OR (eligible AND position < rate). A reporter stays true; a carer under the limit who reports no allowance stays false, as the survey records them entitled and not claiming. Scotland is drawn too (María's ruling of 2026-10-23): there the flag is Carer Support Payment's, which policyengine-uk pays only under its own earnings limit from 2.146.1 (PolicyEngine/policyengine-uk#2473), and the receipt reports Scotland apart. The earnings test is read before salary_sacrifice moves some contributors' pension amounts out of their pay, so a drawn carer whom that conversion takes under the survey year's limit keeps the flag although the file then shows them entitled and not reporting. The stage rebuilds the flag from reported receipt and refuses a frame whose flag no longer follows it. Its receipt bands support on distinct source households (source_household_id), and gives a weighted total only where three or more carry it and a share only where neither of its sides rests on one or two; it lists each stratum's realised share against its target, and the stage refuses a take-up stratum whose drawn weight misses its share by more than its heaviest record, the most the rotated placement allows, so the balance holds on every build (Anthony's reviews of microcosm#1420). The stage has no health gate." }, { "stage": "student_loans", diff --git a/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml b/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml index cff1814232..c6b2716a93 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml +++ b/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml @@ -5680,7 +5680,7 @@ stages: family_type: two FRS claimant or partner roles make a couple; children are UC children or qualifying young people and other non-claimants under 20 (the calibration measure's uc_calibration_family_type) award_bands: GBP 1,200 a year (DWP's GBP 100 a month), (1,200 i, 1,200 (i + 1)] in whole pence for i < 25, and above GBP 30,000 targets: DWP Stat-Xplore Households on Universal Credit by family type and monthly award band, mean of April to December 2025 - pooling: 'adjacent bands within a family type, lowest first, until the drawn units rest on minimum_pool_sources distinct household_source_id values; a short last pool joins the one before it. Then, lowest first, a pool that cannot meet DWP''s count (its undrawn entitled units'' expected claims exceed the count, or the count exceeds them plus the weight of every drawn unit) is held at the nearer of those ends and passes its gap to the other pools, nearest first, the one with more room first at equal distance and the lower on a tie, each taking what its room allows; a gap no pool can take leaves the family type unreachable. With the fits, a passed shortfall''s room is the pool''s undrawn claims plus the weight of its drawn units with neither a young claimant or partner nor the LCWRA element, less its count (age_fit, lcwra_fit)' + pooling: 'adjacent bands within a family type, lowest first, until the drawn units rest on minimum_pool_sources distinct source_household_id values; a short last pool joins the one before it. Then, lowest first, a pool that cannot meet DWP''s count (its undrawn entitled units'' expected claims exceed the count, or the count exceeds them plus the weight of every drawn unit) is held at the nearer of those ends and passes its gap to the other pools, nearest first, the one with more room first at equal distance and the lower on a tie, each taking what its room allows; a gap no pool can take leaves the family type unreachable. With the fits, a passed shortfall''s room is the pool''s undrawn claims plus the weight of its drawn units with neither a young claimant or partner nor the LCWRA element, less its count (age_fit, lcwra_fit)' minimum_pool_sources: 30 drawn_units: entitled, non-reporting units of the population that the engine does not move off their legacy benefits (legacy_benefits_closed) and that report none, since a legacy benefit the engine leaves in place ends once the unit claims UC undrawn_claims: a reporter at 1, a moved unit at the claim probability uc_legacy_closure_take_up's rule gives it (dwp_move_to_uc_facts.json), a unit keeping income-related ESA at 0, any other at its stored flag @@ -6581,7 +6581,7 @@ stages: outputs: [] rewrites: - would_claim_carers_allowance - notes: 'Runs after the SPI income chain, UC capital coherence, the Pension Credit and Child Benefit redraws and salary_sacrifice, so the earnings test reads the pay salary sacrifice converts (microcosm#1095 B5); a CGT copy draws as the member it copies, placed with it as one record of their joint weight, so every clone carries its source''s draw (microcosm#1319). frs_spine sets would_claim_carers_allowance from reported receipt and the SPI income chain re-derives it from the refilled receipt on the rows it redraws, so that care_hours qualifies a carer for the Universal Credit carer element without paying the allowance to every carer (#882). A carer above the earnings limit cannot report the allowance, so no reform that widens it reached a carer who would claim once entitled: the April 2025 rise of the limit from £151 to £196 a week brought an estimated 61,000 more people into eligibility (Independent Review of Carer''s Allowance Overpayments, July 2025, chapter 7). One temporary engine materialization at the survey year, on the frame''s own values, gives each person''s is_gainfully_employed_for_carers_allowance and carers_allowance_earnings (consumed only); the engine reads a year''s parameters at 30 April, so the limit is 2024-25''s £151. The allowance is paid only for caring for a severely disabled person (SSCBA 1992 s. 70(2)), which the care hours do not record (microcosm#1418), and policyengine-uk reads it from cares_for_severely_disabled_person (2.177.3, pe-uk#2860) wherever care_hours reach the minimum. frs_disability writes that input from the FRS care tab and the benefits of the people each carer gives their largest band of care, and hmrc_spi_income_spine takes it again on the SPI channel''s households; a carer of someone outside the household with no qualifying member is drawn at the share of the in-household carers who report no allowance and care for a qualifying member, the rule this stage drew its own pool by until it read the input (María''s decision (a) of 2026-10-28; A3 of the November event-data plan''s PR3, microcosm#1095, María''s choices of 2026-11-10; she signed these notes on 2026-11-11). The pool is the carers at the hours whom the input holds caring for a severely disabled person. A person in that pool whose care_hours reach the engine''s gov.dwp.carers_allowance.min_hours (35), who reports no allowance and whom the earnings test holds gainfully employed claims at the take-up contract''s carers_allowance_newly_entitled rate (0.6, María''s ruling of 2026-10-20, sensitivity 0.45 to 0.75) on the person''s identity-keyed uniform (seed 0, salt would_claim_carers_allowance), placed by weight within strata and rotated by a start drawn per stratum, so that each stratum claims the rate of its eligible weight to within one record and each eligible carer with probability equal to the rate (weight_balanced_uniforms, policyengine-uk''s stratified_uniform with a random start; microcosm#1418 and the independent review of microcosm#1420): the route (whether the carer''s largest in-household band, frs_care_hours_in_household, reaches the hours), whether the benefit unit reports a means-tested benefit at the survey year, and the survey-year weekly earnings band, one weekly rate wide above the limit and open above three. would_claim = reported OR (eligible AND position < rate). A reporter stays true; a carer under the limit who reports no allowance stays false, as the survey records them entitled and not claiming. Scotland is drawn too (María''s ruling of 2026-10-23): there the flag is Carer Support Payment''s, which policyengine-uk pays only under its own earnings limit from 2.146.1 (PolicyEngine/policyengine-uk#2473), and the receipt reports Scotland apart. The earnings test is read before salary_sacrifice moves some contributors'' pension amounts out of their pay, so a drawn carer whom that conversion takes under the survey year''s limit keeps the flag although the file then shows them entitled and not reporting. The stage rebuilds the flag from reported receipt and refuses a frame whose flag no longer follows it. Its receipt bands support on distinct source households (household_source_id), and gives a weighted total only where three or more carry it and a share only where neither of its sides rests on one or two; it lists each stratum''s realised share against its target, and the stage refuses a take-up stratum whose drawn weight misses its share by more than its heaviest record, the most the rotated placement allows, so the balance holds on every build (Anthony''s reviews of microcosm#1420). The stage has no health gate.' + notes: 'Runs after the SPI income chain, UC capital coherence, the Pension Credit and Child Benefit redraws and salary_sacrifice, so the earnings test reads the pay salary sacrifice converts (microcosm#1095 B5); a CGT copy draws as the member it copies, placed with it as one record of their joint weight, so every clone carries its source''s draw (microcosm#1319). frs_spine sets would_claim_carers_allowance from reported receipt and the SPI income chain re-derives it from the refilled receipt on the rows it redraws, so that care_hours qualifies a carer for the Universal Credit carer element without paying the allowance to every carer (#882). A carer above the earnings limit cannot report the allowance, so no reform that widens it reached a carer who would claim once entitled: the April 2025 rise of the limit from £151 to £196 a week brought an estimated 61,000 more people into eligibility (Independent Review of Carer''s Allowance Overpayments, July 2025, chapter 7). One temporary engine materialization at the survey year, on the frame''s own values, gives each person''s is_gainfully_employed_for_carers_allowance and carers_allowance_earnings (consumed only); the engine reads a year''s parameters at 30 April, so the limit is 2024-25''s £151. The allowance is paid only for caring for a severely disabled person (SSCBA 1992 s. 70(2)), which the care hours do not record (microcosm#1418), and policyengine-uk reads it from cares_for_severely_disabled_person (2.177.3, pe-uk#2860) wherever care_hours reach the minimum. frs_disability writes that input from the FRS care tab and the benefits of the people each carer gives their largest band of care, and hmrc_spi_income_spine takes it again on the SPI channel''s households; a carer of someone outside the household with no qualifying member is drawn at the share of the in-household carers who report no allowance and care for a qualifying member, the rule this stage drew its own pool by until it read the input (María''s decision (a) of 2026-10-28; A3 of the November event-data plan''s PR3, microcosm#1095, María''s choices of 2026-11-10; she signed these notes on 2026-11-11). The pool is the carers at the hours whom the input holds caring for a severely disabled person. A person in that pool whose care_hours reach the engine''s gov.dwp.carers_allowance.min_hours (35), who reports no allowance and whom the earnings test holds gainfully employed claims at the take-up contract''s carers_allowance_newly_entitled rate (0.6, María''s ruling of 2026-10-20, sensitivity 0.45 to 0.75) on the person''s identity-keyed uniform (seed 0, salt would_claim_carers_allowance), placed by weight within strata and rotated by a start drawn per stratum, so that each stratum claims the rate of its eligible weight to within one record and each eligible carer with probability equal to the rate (weight_balanced_uniforms, policyengine-uk''s stratified_uniform with a random start; microcosm#1418 and the independent review of microcosm#1420): the route (whether the carer''s largest in-household band, frs_care_hours_in_household, reaches the hours), whether the benefit unit reports a means-tested benefit at the survey year, and the survey-year weekly earnings band, one weekly rate wide above the limit and open above three. would_claim = reported OR (eligible AND position < rate). A reporter stays true; a carer under the limit who reports no allowance stays false, as the survey records them entitled and not claiming. Scotland is drawn too (María''s ruling of 2026-10-23): there the flag is Carer Support Payment''s, which policyengine-uk pays only under its own earnings limit from 2.146.1 (PolicyEngine/policyengine-uk#2473), and the receipt reports Scotland apart. The earnings test is read before salary_sacrifice moves some contributors'' pension amounts out of their pay, so a drawn carer whom that conversion takes under the survey year''s limit keeps the flag although the file then shows them entitled and not reporting. The stage rebuilds the flag from reported receipt and refuses a frame whose flag no longer follows it. Its receipt bands support on distinct source households (source_household_id), and gives a weighted total only where three or more carry it and a share only where neither of its sides rests on one or two; it lists each stratum''s realised share against its target, and the stage refuses a take-up stratum whose drawn weight misses its share by more than its heaviest record, the most the rotated placement allows, so the balance holds on every build (Anthony''s reviews of microcosm#1420). The stage has no health gate.' - stage: student_loans survey: Family Resources Survey 2024-25 and Student Loans Company borrower forecasts for England source: Explore Education Statistics Table 6a, Higher education total diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/carers_allowance_take_up.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/carers_allowance_take_up.py index db04a4a73c..6262a5688e 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/carers_allowance_take_up.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/carers_allowance_take_up.py @@ -107,8 +107,8 @@ UK_DISCLOSURE_FLOOR, UK_WITHHELD, distinct_count, + record_source_households, small_cell_share, - source_household_ids, support_band, ) from microcosm.build.uk_runtime.take_up_contract import ( @@ -675,9 +675,10 @@ def redraw_carers_allowance_take_up( ) # The graph node is an open surface, so the lineage arrives with every # other live cell; the receipt counts support by it. - household_sources = pd.Series( - source_household_ids(household, stage="The Carer's Allowance take-up stage"), - index=household["household_id"].to_numpy(), + source_ids = record_source_households( + {"person": person, "household": household}, + "person", + stage="The Carer's Allowance take-up stage", ) reported = ( pd.to_numeric(person[CARERS_ALLOWANCE_REPORTED], errors="coerce") @@ -794,8 +795,6 @@ def redraw_carers_allowance_take_up( ) validate_uk_national_frame(result) - source_ids = person_households.map(household_sources).to_numpy() - # Weighted aggregates only; a figure one or two source households carry # is "<3" (UKDS disclosure control). def sources(mask: np.ndarray) -> int: diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/company_cars.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/company_cars.py index 28700104d4..4c2e6b4ac2 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/company_cars.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/company_cars.py @@ -115,9 +115,9 @@ UK_DISCLOSURE_FLOOR, distinct_count, extreme_count, + record_source_households, rounded_count, small_cell_share, - source_household_ids, support_band, ) from microcosm.build.uk_runtime.spi_income import ( @@ -596,9 +596,10 @@ def holder_table(frame: Frame) -> pd.DataFrame: np.asarray(frame.weights_for("household").values, dtype=float), index=household["household_id"].to_numpy(), ) - sources = pd.Series( - source_household_ids(household, stage=UK_COMPANY_CARS_STAGE_NAME), - index=household["household_id"].to_numpy(), + sources = record_source_households( + {"person": person, "household": household}, + "person", + stage=UK_COMPANY_CARS_STAGE_NAME, ) household_ids = person["person_household_id"].to_numpy() channel_column = support_channel_column("person") @@ -649,7 +650,7 @@ def _number(column: str) -> np.ndarray: { "person_id": person["person_id"].to_numpy(), "household_id": household_ids, - "source_household": sources.reindex(household_ids).to_numpy(), + "source_household": sources, "weight": weights.reindex(household_ids).to_numpy(float), "spi": spi, "tape": tape, diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_annual_income.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_annual_income.py index 0bde5a55da..51c8f2a375 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_annual_income.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_annual_income.py @@ -145,6 +145,8 @@ UK_WITHHELD, distinct_carriers, extreme_count, + own_source_households, + record_source_households, small_cell_share, support_band, ) @@ -412,6 +414,9 @@ def add_frs_annual_income_spells( job=tables["job"], interview=interview, earnings_growth=load_earnings_growth(), + person_sources=record_source_households( + frame, "person", stage=FRS_ANNUAL_INCOME_STAGE_NAME, before_copies=True + ), ) output = person.copy() for column in FRS_ANNUAL_INCOME_OUTPUT_COLUMNS: @@ -455,6 +460,7 @@ def derive_frs_annual_income_spells( job: pd.DataFrame, interview: pd.Series, earnings_growth: float, + person_sources: np.ndarray | None = None, ) -> tuple[pd.DataFrame, dict[str, object]]: """Person-aligned descriptors and their aggregate receipt. @@ -462,7 +468,11 @@ def derive_frs_annual_income_spells( (``person_id`` = sernum * 1000 + person). ``adult`` and ``job`` are the pinned tabs after :func:`normalize_ids`; ``interview`` is the interview date by ``household_id``. ``person_weights`` are the household weights each - person row carries. + person row carries, and ``person_sources`` each person's true source + household, which the receipt counts support by + (``receipt_counts.record_source_households``); without them each person's + household is its own source, as every household is before the SPI support + channel. """ person_ids = person["person_id"].to_numpy() @@ -470,6 +480,13 @@ def derive_frs_annual_income_spells( weights = np.asarray(person_weights, dtype=float) if weights.shape != (rows,): raise ValueError("person weights must align with the person table.") + household_sources = ( + own_source_households(person) + if person_sources is None + else np.asarray(person_sources) + ) + if household_sources.shape != (rows,): + raise ValueError("person sources must align with the person table.") raw = adult.drop_duplicates("person_id").set_index("person_id") if len(raw) != len(adult): raise ValueError("FRS adult.tab carries a person twice.") @@ -623,7 +640,9 @@ def derive_frs_annual_income_spells( ) / WINDOW_MONTHS ) - ratio, ratio_support = pay_concept_ratio(person_ids, weights, job, working) + ratio, ratio_support = pay_concept_ratio( + person_ids, weights, job, working, household_sources=household_sources + ) usual = _numeric(main, "ugross") observed = employee_leaver & np.isfinite(usual) & (usual > 0) weekly_rate = np.zeros(rows) @@ -752,6 +771,7 @@ def derive_frs_annual_income_spells( receipt = _receipt( person, weights=weights, + household_sources=household_sources, descriptors=descriptors, current=current, se_current=se_current, @@ -773,16 +793,21 @@ def pay_concept_ratio( weights: np.ndarray, job: pd.DataFrame, working: np.ndarray, + *, + household_sources: np.ndarray, ) -> tuple[float, int]: """Weighted UGRSPAY / UGROSS on current employee main jobs reporting both. UGRSPAY is the DV pay the spine's ``employment_income`` sums; UGROSS is the usual gross pay the survey asks of a current job whose last pay was not usual and of a recent leaver's last job. Measured job by job on one job per - person, so a second job's pay never enters it. + person, so a second job's pay never enters it. Its support is counted in + the true source households of the jobs' holders (``household_sources``, + one per person). """ weight_by_person = pd.Series(weights, index=person_ids) + source_by_person = pd.Series(household_sources, index=person_ids) working_by_person = pd.Series(np.asarray(working, dtype=bool), index=person_ids) jobs = job.loc[ (_numeric(job, "jobtype") == 1) @@ -800,7 +825,9 @@ def pay_concept_ratio( ) usual = _numeric(jobs, "ugross") dv = _numeric(jobs, "ugrspay") - support = distinct_carriers(jobs["household_id"].to_numpy(), job_weights) + support = distinct_carriers( + source_by_person.reindex(jobs["person_id"].to_numpy()).to_numpy(), job_weights + ) denominator = float(np.nansum(job_weights * usual)) # Fewer than three reporting households only flags: the receipt prints the # ratio "<3" and the gate reads it unmeasured, since a small-cell rule @@ -898,6 +925,7 @@ def _receipt( person: pd.DataFrame, *, weights: np.ndarray, + household_sources: np.ndarray, descriptors: pd.DataFrame, current: np.ndarray, se_current: np.ndarray, @@ -911,10 +939,8 @@ def _receipt( earnings_growth: float, employment_share: np.ndarray, ) -> dict[str, object]: - households = person["person_household_id"].to_numpy() - def carriers(mask: np.ndarray) -> int: - return distinct_carriers(households[mask], weights[mask]) + return distinct_carriers(household_sources[mask], weights[mask]) def weighted(values: np.ndarray, mask: np.ndarray) -> float | str: return small_cell_share(float((weights * values)[mask].sum()), carriers(mask)) diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_person_draws.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_person_draws.py index 79e072ae6a..8ca52c54c1 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_person_draws.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_person_draws.py @@ -63,6 +63,8 @@ UK_DISCLOSURE_FLOOR, UK_WITHHELD, distinct_count, + own_source_households, + record_source_households, support_band, ) from microcosm.build.uk_runtime.take_up_contract import UKTakeUpContract @@ -182,6 +184,9 @@ def add_frs_person_draws_with_receipt( contract=contract, person_weights=uk_person_household_weights(frame), relief_schedule=schedule, + person_sources=record_source_households( + frame, "person", stage="frs_person_draws", before_copies=True + ), ) for column in FRS_PERSON_DRAW_OUTPUT_COLUMNS: person[column] = derived[column].to_numpy() @@ -204,11 +209,13 @@ def derive_frs_person_draws( contract: UKTakeUpContract, person_weights: np.ndarray, relief_schedule: Mapping[str, float] | None = None, + person_sources: np.ndarray | None = None, ) -> pd.DataFrame: """Return the stage's person draws. ``person_weights`` are each person's household weight, which set - ``is_apprentice``'s target. + ``is_apprentice``'s target; ``person_sources`` are each person's true + source household, which its receipt counts support by. """ return derive_frs_person_draws_with_receipt( @@ -216,6 +223,7 @@ def derive_frs_person_draws( contract=contract, person_weights=person_weights, relief_schedule=relief_schedule, + person_sources=person_sources, )[0] @@ -225,6 +233,7 @@ def derive_frs_person_draws_with_receipt( contract: UKTakeUpContract, person_weights: np.ndarray, relief_schedule: Mapping[str, float] | None = None, + person_sources: np.ndarray | None = None, ) -> tuple[pd.DataFrame, Mapping[str, object]]: """The stage's person draws and the receipt of its ``is_apprentice`` draw.""" @@ -257,6 +266,7 @@ def derive_frs_person_draws_with_receipt( rate=contract.rate(APPRENTICE_RATE_KEY, contract.build_year), person_weights=person_weights, relief_schedule=relief_schedule, + person_sources=person_sources, ) values[APPRENTICE_OUTPUT] = apprentices.flags return values, {"build_year": contract.build_year, **apprentices.receipt} @@ -276,6 +286,7 @@ def derive_is_apprentice( rate: float, person_weights: np.ndarray | None = None, relief_schedule: Mapping[str, float] | None = None, + person_sources: np.ndarray | None = None, ) -> UKApprenticeDraw: """Draw ``is_apprentice`` for employees aged 21 to 24 outside full-time education. @@ -293,6 +304,11 @@ def derive_is_apprentice( records the relief the flags imply: the rate on each flagged employee's pay between the two thresholds, weighted. Pay stands in for NIC earnings, so it is an estimate of the s.9B relief, not the engine's figure. + + The receipt counts support in ``person_sources``, each person's true + source household (``receipt_counts.record_source_households``). Without + them each person's household is its own source, as every household is + before the SPI support channel. """ if "employment_status" not in person.columns: @@ -335,11 +351,16 @@ def derive_is_apprentice( ) flags = eligible & (draws < threshold) realized = float(weights[flags].sum()) - # Before the support channels every household is its own source household. - households = person["person_household_id"].to_numpy() - population_support = distinct_count(households, in_ages, weights) - eligible_support = distinct_count(households, eligible, weights) - flagged_support = distinct_count(households, flags, weights) + sources = ( + own_source_households(person) + if person_sources is None + else np.asarray(person_sources) + ) + if sources.shape != (len(person),): + raise ValueError("person_sources must hold one source per person.") + population_support = distinct_count(sources, in_ages, weights) + eligible_support = distinct_count(sources, eligible, weights) + flagged_support = distinct_count(sources, flags, weights) receipt: dict[str, object] = { "output": APPRENTICE_OUTPUT, "rate_key": APPRENTICE_RATE_KEY, diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_take_up.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_take_up.py index 13a02e8da8..b62cbd78f7 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_take_up.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_take_up.py @@ -28,6 +28,7 @@ from microcosm.build.uk_runtime.receipt_counts import ( distinct_count, extreme_count, + record_source_households, small_cell_share, support_band, ) @@ -831,7 +832,11 @@ def uk_take_up_signal_receipt( flags.append(row) continue if entity not in sources: - sources[entity] = _row_source_households(frame, entity) + # Before the SPI support channel each household is its own source, + # so its id serves until ``source_household_id`` exists. + sources[entity] = record_source_households( + frame, entity, stage="The take-up signal receipt", before_copies=True + ) support = distinct_count(sources[entity], measured.population, measured.weights) row["population_support"] = support_band(support) row["target"] = small_cell_share(measured.target, support) @@ -848,35 +853,6 @@ def uk_take_up_signal_receipt( } -def _row_source_households(frame: Frame, entity: str) -> np.ndarray: - """Each row's source household, the key a receipt counts support by. - - Before the SPI support channel each household row is its own FRS source - household, so its id serves until ``household_source_id`` exists. - """ - - household = frame.table("household") - column = ( - "household_source_id" - if "household_source_id" in household.columns - else "household_id" - ) - by_household = pd.Series( - household[column].to_numpy(), index=household["household_id"].to_numpy() - ) - if entity == "household": - return by_household.to_numpy() - person = frame.table("person") - person_sources = person["person_household_id"].map(by_household) - if entity == "person": - return person_sources.to_numpy() - by_benunit = pd.Series( - person_sources.to_numpy(), index=person["person_benunit_id"].to_numpy() - ) - by_benunit = by_benunit[~by_benunit.index.duplicated()] - return frame.table("benunit")["benunit_id"].map(by_benunit).to_numpy() - - def _target_share( table: pd.DataFrame, key: str, diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py index 004f8a26d4..1305bf730b 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py @@ -363,7 +363,7 @@ ("household", "main_residence_value"), ("household", "property_wealth"), ("household", "household_is_high_value_support_copy"), - ("household", "household_source_id"), + ("household", "source_household_id"), } ), # Engine-free: each kind's stock, the region that marks where SDLT @@ -374,7 +374,7 @@ ("household", "region"), ("household", "other_residential_property_value"), ("household", "non_residential_property_value"), - ("household", "household_source_id"), + ("household", "source_household_id"), } ), # The NTS band model materializes an engine predictor (household gross @@ -528,7 +528,7 @@ ) ), # The receipt counts support by source household. - ("household", "household_source_id"), + ("household", "source_household_id"), ("benunit", "benunit_support_channel"), ("benunit", "would_claim_uc"), } @@ -575,7 +575,7 @@ ("person", "jsa_income_reported"), ("person", "universal_credit_reported"), ("benunit", "would_claim_uc"), - ("household", "household_source_id"), + ("household", "source_household_id"), } ), "uc_deduction_attributes": frozenset({("household", "region")}), @@ -727,7 +727,7 @@ "trading_allowance_receipts": frozenset( { ("person", "self_employment_income"), - ("household", "household_source_id"), + ("household", "source_household_id"), ("household", "household_is_spi_synthetic"), } ), diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py index 595717579f..578f17b1a4 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py @@ -47,7 +47,7 @@ ) from microcosm.graph.population import dtype_for_token -from .. import stage_evidence, stochastic_assignment +from .. import source_lineage, stage_evidence, stochastic_assignment from . import ( bus_use_incidence, cgt_imputation, @@ -304,6 +304,41 @@ ), } +# The receipts' counting rules and the shared lineage they read: every floor +# counts true source households through receipt_counts, which reads them +# through source_lineage on household_lineage's declaration (microcosm#931). +# An edit to any of the three moves the hash of every stage whose module or +# helpers import one of them; test_uk_graph derives this set from the imports. +_COUNTING_MODULES = (receipt_counts, household_lineage, source_lineage) +_COUNTING_STAGES = frozenset( + { + "frs_take_up", + "frs_person_draws", + "frs_household_draws", + "frs_annual_income_spells", + "hmrc_spi_income_spine", + "company_cars", + "high_value_home_support", + "regional_home_values", + "property_components", + "property_purchases", + "nts_bus_travel", + "lcfs_consumption", + "etb_vat", + "spi_benefit_coherence", + "uc_capital_coherence", + "uc_take_up", + "uc_legacy_closure_take_up", + "pension_credit_take_up", + "child_benefit_take_up", + "salary_sacrifice", + "carers_allowance_take_up", + "childcare_copy_take_up", + "isa_subscriptions", + "trading_allowance_receipts", + } +) + _COMPUTE = Capabilities( determinism=Determinism.DETERMINISTIC, numeric=Numeric.BITWISE, @@ -357,6 +392,7 @@ def _implementation_hash(kernel: object, stage: str, transform: object | None) - _mass_log_payload, _stage_module(stage), *_STAGE_HELPER_MODULES.get(stage, ()), + *(_COUNTING_MODULES if stage in _COUNTING_STAGES else ()), *(dependencies() if callable(dependencies) else ()), ) diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_population.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_population.py index 6de89bcd1b..8c354334b1 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_population.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_population.py @@ -77,7 +77,7 @@ verify_local_authority_engine_domain, ) from .national_frame import UK_NATIONAL_SCHEMA -from .receipt_counts import rounded_count +from .receipt_counts import rounded_count, source_household_ids from .rowwise_dataset import expand_uk_geographic_pool, ladder_clone_index_column POPULATION_RECEIPT_TYPE = ArtifactType("microcosm.uk.population-receipt", 1) @@ -835,6 +835,7 @@ def run(self, context: KernelContext) -> KernelResult: ) new_rent, details = private_rent_localisation.localise_rents( spine_key=keys, + source=source_household_ids(household, stage="uk.full.private_rent"), region=household["region"].to_numpy(), tenure_type=household["tenure_type"].to_numpy(), rent=household["rent"].to_numpy(), diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py index ac9a0ec8ec..46d6afb24e 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py @@ -15,12 +15,14 @@ import numpy as np import pandas as pd +from microcosm.build.source_lineage import CopyBranch, CopyLineage from microcosm.build.uk_runtime.rowwise_dataset import ladder_clone_index_column __all__ = [ "GEOGRAPHIC_SUPPORT_BRANCH", "HIGH_VALUE_SUPPORT_COPY_COLUMN", "HIGH_VALUE_SUPPORT_INDEX_COLUMN", + "UK_COPY_LINEAGE", "UK_HOUSEHOLD_LINEAGE_COLUMNS", "uk_household_clone_paths", ] @@ -52,6 +54,41 @@ GEOGRAPHIC_SUPPORT_BRANCH = "geographic_support" _BASE_SUPPORT_CHANNEL = "frs" _SPI_SUPPORT_CHANNEL = "spi" +#: The UK's copy lineage for the shared readers in +#: ``microcosm.build.source_lineage``: every copy's true source is +#: ``source_household_id``, and its copying steps are the clone path's +#: branches below, in path order. +UK_COPY_LINEAGE = CopyLineage( + entity="household", + branches=( + CopyBranch( + "spi_support_channel", + index="household_support_clone_index", + marker="household_support_channel", + copy=_SPI_SUPPORT_CHANNEL, + original=_BASE_SUPPORT_CHANNEL, + ), + CopyBranch( + "cgt_support_split", + index="cgt_support_copy_index", + marker="household_is_cgt_support_copy", + ), + CopyBranch( + "high_value_support", + index=HIGH_VALUE_SUPPORT_INDEX_COLUMN, + marker=HIGH_VALUE_SUPPORT_COPY_COLUMN, + ), + CopyBranch("cgt_incidence_clone", marker="household_is_capital_gains_clone"), + CopyBranch( + "cgt_residential_split", + index="cgt_residential_clone_index", + marker="household_is_cgt_residential_clone", + ), + CopyBranch( + GEOGRAPHIC_SUPPORT_BRANCH, index=ladder_clone_index_column("household") + ), + ), +) def _require_bool(series: pd.Series, column: str) -> None: diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/legacy_closure_take_up.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/legacy_closure_take_up.py index 58886d1c3f..190ed7e23d 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/legacy_closure_take_up.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/legacy_closure_take_up.py @@ -63,8 +63,8 @@ UK_DISCLOSURE_FLOOR, UK_WITHHELD, distinct_count, + record_source_households, small_cell_share, - source_household_ids, support_band, ) from microcosm.build.uk_runtime.uc_capital_coherence import ( @@ -317,9 +317,10 @@ def assign_uc_claim_at_legacy_closure( raise ValueError("The legacy closure draw needs benunit 'would_claim_uc'.") # The graph node declares the lineage, since the executor hands a stage # only its declared cells. - household_sources = pd.Series( - source_household_ids(household, stage="The legacy closure stage"), - index=household["household_id"].to_numpy(), + source_ids = record_source_households( + {"person": person, "benunit": benunit, "household": household}, + "benunit", + stage="The legacy closure stage", ) household_weights = frame.weights_for("household") weights = _household_to_benunit_weights( @@ -338,7 +339,6 @@ def assign_uc_claim_at_legacy_closure( unit_households.map(by_household["region"].astype(str)).to_numpy() != "NORTHERN_IRELAND" ) - source_ids = unit_households.map(household_sources).to_numpy() probability, combinations_drawn = legacy_closure_claim_probabilities( combination=combination, drawn=drawn, diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/private_rent_localisation.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/private_rent_localisation.py index 60ae561250..85f74904d7 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/private_rent_localisation.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/private_rent_localisation.py @@ -29,6 +29,8 @@ import numpy as np import pandas as pd +from microcosm.build.uk_runtime.receipt_counts import distinct_carriers + __all__ = [ "CATEGORIES", "COUNTS_SOURCE", @@ -224,12 +226,15 @@ def rent_categories(num_bedrooms) -> np.ndarray: return out -def _spine_rows(*, spine_key, region, category, rent, channel, weight) -> pd.DataFrame: +def _spine_rows( + *, spine_key, source, region, category, rent, channel, weight +) -> pd.DataFrame: """One row per spine household: its clones' summed weight and shared cell.""" frame = pd.DataFrame( { "key": np.asarray(spine_key, dtype=object), + "source": np.asarray(source, dtype=object), "region": np.asarray(region).astype(str), "category": np.asarray(category, dtype=object), "rent": np.asarray(rent, dtype=float), @@ -239,6 +244,8 @@ def _spine_rows(*, spine_key, region, category, rent, channel, weight) -> pd.Dat ) grouped = frame.groupby("key", sort=True) spine = grouped.agg( + source=("source", "first"), + sources=("source", "nunique"), region=("region", "first"), regions=("region", "nunique"), category=("category", "first"), @@ -251,16 +258,17 @@ def _spine_rows(*, spine_key, region, category, rent, channel, weight) -> pd.Dat weight=("weight", "sum"), ) if ( - (spine["regions"] != 1).any() + (spine["sources"] != 1).any() + or (spine["regions"] != 1).any() or (spine["categories"] != 1).any() or (spine["channels"] != 1).any() or (spine["rent_max"] - spine["rent_min"]).abs().max() > 1e-9 ): raise ValueError( - "Pool clones of one spine household disagree on region, bedrooms, " - "channel or rent." + "Pool clones of one spine household disagree on source, region, " + "bedrooms, channel or rent." ) - return spine[["region", "category", "rent", "channel", "weight"]] + return spine[["source", "region", "category", "rent", "channel", "weight"]] # ---------------------------------------------------------------------------- @@ -275,12 +283,19 @@ def sampled_thin_regions(spine: pd.DataFrame, *, strict: bool) -> frozenset[str] """The regions a sampled rung ranks and scales on Great Britain's renters. Those whose sample holds fewer than :data:`MIN_SAMPLED_REGION_RENTERS` - FRS renters; none at full scale (``strict``). + FRS renters, counted in true source households, so a renter's support + copies count once (receipt_counts); none at full scale (``strict``). """ if strict: return frozenset() - held = _reference(spine)["region"].astype(str).value_counts() + reference = _reference(spine) + held = { + str(region): distinct_carriers(group["source"]) + for region, group in reference.groupby( + reference["region"].astype(str), sort=True + ) + } return frozenset( str(region) for region in spine["region"].astype(str).unique() @@ -404,6 +419,7 @@ def _region_scale( def localise_rents( *, spine_key, + source, region, tenure_type, rent, @@ -450,6 +466,7 @@ def localise_rents( regions = np.asarray(region).astype(str)[rows] spine = _spine_rows( spine_key=keys, + source=np.asarray(source, dtype=object)[rows], region=regions, category=categories, rent=rent[rows], diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/receipt_counts.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/receipt_counts.py index a886c6ae64..32cb1225fa 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/receipt_counts.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/receipt_counts.py @@ -31,15 +31,25 @@ from __future__ import annotations import math -from collections.abc import Iterable +from collections.abc import Iterable, Mapping from pathlib import Path from typing import Any import numpy as np - -#: The lineage a stage receipt counts distinct support by: support copies -#: repeat their source household, so a cell is counted in sources, not rows. -SOURCE_HOUSEHOLD_COLUMN = "household_source_id" +import pandas as pd + +from microcosm.build.source_lineage import record_sources +from microcosm.build.uk_runtime.household_lineage import UK_COPY_LINEAGE +from microcosm.build.uk_runtime.national_frame import UK_NATIONAL_SCHEMA +from microcosm.frame.concepts import SOURCE_HOUSEHOLD_ID_COLUMN + +#: The lineage a stage receipt counts distinct support by: every copy and +#: clone keeps the survey household it was made from, its true source, so a +#: cell is counted in survey households, not rows (microcosm#931). The support +#: channel's immediate parent, ``household_source_id``, is lineage the +#: executor reads and never a count's key: a copy made from a clone names the +#: clone there. +SOURCE_HOUSEHOLD_COLUMN = SOURCE_HOUSEHOLD_ID_COLUMN #: CD171's absolute floor in distinct source households: a figure resting on #: fewer is withheld, with any figure that gives it back by difference #: (María's ruling of 2026-10-29 moved every output from ten to it). @@ -51,25 +61,60 @@ def source_household_ids(household: Any, *, stage: str) -> np.ndarray: - """Every household row's source household, for a receipt's support counts. + """Every household row's true source household, for a receipt's counts. - A table without the column is refused, and so is one with a null in it: a - null drops out of a distinct count or counts as one source, so a cell - would read fewer sources than it rests on. + The household table's rows by :func:`record_source_households`' rule. """ - if SOURCE_HOUSEHOLD_COLUMN not in household.columns: - raise ValueError( - f"{stage} counts support by {SOURCE_HOUSEHOLD_COLUMN!r}, which the " - "frame does not carry." + return record_source_households({"household": household}, "household", stage=stage) + + +def record_source_households( + tables: Mapping[str, pd.DataFrame] | Any, + entity: str, + *, + stage: str, + before_copies: bool = False, +) -> np.ndarray: + """Every ``entity`` row's true source household: the key a floor counts. + + ``tables`` is a frame or its tables by entity. A household reads its own + ``source_household_id``, a person its household's, and a benefit unit the + household its members share, through the shared reader + (``microcosm.build.source_lineage.record_sources``) on the UK's copy + lineage. A frame without the column is refused, and so is a null source: + it drops out of a distinct count, so a cell would read fewer sources than + it rests on. A stage that runs before the SPI support channel, the first + copying step, says so with ``before_copies``: no row is a copy yet, so + each household is its own source and its id serves, unless the frame + already carries copy lineage. + """ + + if not isinstance(tables, Mapping): + tables = {name: tables.table(name) for name in UK_NATIONAL_SCHEMA.entities} + try: + return record_sources( + tables, + UK_NATIONAL_SCHEMA, + entity, + UK_COPY_LINEAGE, + before_copies=before_copies, ) - ids = household[SOURCE_HOUSEHOLD_COLUMN] - if ids.isna().any(): + except ValueError as error: raise ValueError( - f"{stage} counts support by {SOURCE_HOUSEHOLD_COLUMN!r}, which is null " - "on some rows: every row needs its source household." - ) - return ids.to_numpy() + f"{stage} counts support by true source households: {error}" + ) from error + + +def own_source_households(person: pd.DataFrame) -> np.ndarray: + """Each person's own household as its true source: the rule before copies. + + For a caller that holds a person table without the frame's lineage, as + every household is its own source before the SPI support channel copies + any; a frame with copies counts through :func:`record_source_households`. + """ + + return person[UK_NATIONAL_SCHEMA.membership_column("household")].to_numpy() def distinct_count( diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py index 987238586d..588115034f 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py @@ -43,8 +43,8 @@ ) from microcosm.build.uk_runtime.receipt_counts import ( distinct_count, + record_source_households, small_cell_share, - source_household_ids, support_band, ) from microcosm.build.uk_runtime.spi_support import support_channel_column @@ -379,7 +379,7 @@ def draw_spi_bonuses( groups = [[cell] for cell in range(len(edges) + 1)] def donor_sources(group: list[int]) -> int: - return len(pd.unique(sources[paid_donors & np.isin(raw_cells, group)])) + return distinct_count(sources, paid_donors & np.isin(raw_cells, group)) position = len(groups) - 1 while len(groups) > 1 and position >= 0: @@ -733,12 +733,11 @@ def impute_salary_sacrifice( f"{bonus_resource['data_year']}, but the frame's period is " f"{uk_time_period(frame)!r}." ) - source_ids = person_households.map( - pd.Series( - source_household_ids(household, stage="The salary-sacrifice stage"), - index=household["household_id"].to_numpy(), - ) - ).to_numpy() + source_ids = record_source_households( + {"person": person, "household": household}, + "person", + stage="The salary-sacrifice stage", + ) spi_draw = draw_spi_bonuses( bonus=bonus_source, employment_income=employment_income, diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/single_year_ages.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/single_year_ages.py index 45c2637237..b765d67556 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/single_year_ages.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/single_year_ages.py @@ -34,6 +34,10 @@ from microcosm.build.uk_runtime.diagnostics import UK_DIAGNOSTIC_MIN_SOURCE_HOUSEHOLDS from microcosm.build.uk_runtime.ledger_fact_vendoring import vendored_rows +from microcosm.build.uk_runtime.receipt_counts import ( + distinct_count, + record_source_households, +) UK_SINGLE_YEAR_AGE_RESOURCE = "ons_mid2025_single_year_age_by_sex.json" UK_SINGLE_YEAR_AGE_PERIOD = 2025 @@ -48,13 +52,6 @@ (80, 90), ) UK_SINGLE_YEAR_AGE_SEXES = ("FEMALE", "MALE") -#: The columns that identify the spine household a row was copied from, in -#: the full build's order of preference (uk_runtime.full_measure). -_SOURCE_IDENTITY_COLUMNS = ( - "household_source_id", - "source_household_id", - "source_household_key", -) def _age_key(age: int) -> str: @@ -93,18 +90,6 @@ def load_ons_single_year_ages() -> dict[tuple[str, int], float]: return populations -def household_source_ids(household: pd.DataFrame) -> np.ndarray: - """Each household row's source household, which every copy of it shares.""" - - for column in _SOURCE_IDENTITY_COLUMNS: - if column in household: - return household[column].to_numpy() - raise ValueError( - "The single-year age report counts each cell's carriers as source " - f"households and needs one of {list(_SOURCE_IDENTITY_COLUMNS)}." - ) - - def single_year_age_report( person: pd.DataFrame, household: pd.DataFrame, @@ -125,7 +110,13 @@ def single_year_age_report( if (position < 0).any(): raise ValueError("Every person must belong to a household row.") person_weight = weights[position] - person_source = household_source_ids(household)[position] + # Each cell's carriers are its true source households of positive weight, + # the receipts' one rule (uk_runtime.receipt_counts). + person_source = record_source_households( + {"person": person, "household": household}, + "person", + stage="The single-year age report", + ) raw_age = person["age"].to_numpy(dtype=float) if not np.isfinite(raw_age).all() or (raw_age < 0).any(): raise ValueError("Every person needs a finite, non-negative age.") @@ -134,7 +125,7 @@ def single_year_age_report( withheld = f"<{minimum_carriers}" def cell(mask: np.ndarray, ons_value: float) -> dict[str, Any]: - carriers = int(np.unique(person_source[mask]).size) + carriers = distinct_count(person_source, mask, person_weight) if carriers < minimum_carriers: return {"source_households": withheld} persons = float(person_weight[mask].sum()) @@ -195,7 +186,6 @@ def cell(mask: np.ndarray, ons_value: float) -> dict[str, Any]: "UK_SINGLE_YEAR_AGE_RESOURCE", "UK_SINGLE_YEAR_AGE_SEXES", "UK_TAIL_AGE_BANDS", - "household_source_ids", "load_ons_single_year_ages", "single_year_age_report", ] diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/size_evaluation.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/size_evaluation.py index d3f4bc84ea..18f41e0230 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/size_evaluation.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/size_evaluation.py @@ -19,6 +19,10 @@ uk_weight_summary, ) from microcosm.build.uk_runtime.national_frame import UK_BUILD_IDENTIFIER_COLUMNS +from microcosm.build.uk_runtime.receipt_counts import ( + SOURCE_HOUSEHOLD_COLUMN, + source_household_ids, +) from microcosm.build.uk_runtime.rowwise_geography import id_multiplier_for_values __all__ = [ @@ -229,10 +233,13 @@ def load_run(path: str | Path, *, label: str, skip_h5: bool = False) -> RowwiseR stored = store.select("household", stop=0).columns carrier = UK_BUILD_IDENTIFIER_COLUMNS["household"] identifier = carrier if carrier in stored else "household_id" + # A file that keeps each household's true source counts support by it + # (microcosm#931); an older one falls back to the id arithmetic below. + sources = [SOURCE_HOUSEHOLD_COLUMN] if SOURCE_HOUSEHOLD_COLUMN in stored else [] weights = pd.read_hdf( h5_path, "household", - columns=[identifier, "household_weight", "clone_index"], + columns=[identifier, "household_weight", "clone_index", *sources], ).rename(columns={identifier: "household_id"}) uk_diagnostics = _mapping(calibration.get("uk_diagnostics")) holdout_value = uk_diagnostics.get("rotated_holdout") @@ -548,11 +555,21 @@ def weight_tables( if weight_frame is not None: values = weight_frame["household_weight"].to_numpy(dtype=np.float64) result["summary"] = uk_weight_summary(values) - multiplier, basis = _source_multiplier(weight_frame, spine_weights) - base_ids = ( - weight_frame["household_id"].to_numpy(dtype=np.int64) - - weight_frame["clone_index"].to_numpy(dtype=np.int64) * multiplier - ) + if SOURCE_HOUSEHOLD_COLUMN in weight_frame: + # Every copy and clone keeps its true source, so a source with + # copies counts once (receipt_counts). + multiplier, basis = None, SOURCE_HOUSEHOLD_COLUMN + base_ids = source_household_ids( + weight_frame, stage="The dataset-size evaluation" + ) + else: + # Without the column only the geographic clones fold back: the id + # arithmetic recovers each spine household, copies apart. + multiplier, basis = _source_multiplier(weight_frame, spine_weights) + base_ids = ( + weight_frame["household_id"].to_numpy(dtype=np.int64) + - weight_frame["clone_index"].to_numpy(dtype=np.int64) * multiplier + ) result["distinct_source_households"] = int(np.unique(base_ids).size) result["source_id_multiplier"] = multiplier result["source_id_multiplier_basis"] = basis diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_benefit_coherence.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_benefit_coherence.py index 34e665ddf9..7e5608757f 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_benefit_coherence.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_benefit_coherence.py @@ -132,7 +132,7 @@ UK_DISCLOSURE_FLOOR, UK_WITHHELD, distinct_count, - source_household_ids, + record_source_households, support_band, ) from microcosm.build.uk_runtime.spi_support import ( @@ -1010,16 +1010,13 @@ def weighted_above(values: np.ndarray) -> float | str: def _person_source_households( person: pd.DataFrame, household: pd.DataFrame ) -> np.ndarray: - """Each person's source household, the lineage the receipt counts by.""" + """Each person's true source household, the lineage the receipt counts by.""" - by_household = pd.Series( - source_household_ids(household, stage=SPI_BENEFIT_COHERENCE_STAGE_NAME), - index=household["household_id"].to_numpy(), + return record_source_households( + {"person": person, "household": household}, + "person", + stage=SPI_BENEFIT_COHERENCE_STAGE_NAME, ) - sources = person["person_household_id"].map(by_household) - if sources.isna().any(): - raise ValueError("SPI benefit coherence persons must map to a household.") - return sources.to_numpy() def _person_weights( diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py index dbecbd7e23..22071d2462 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py @@ -69,6 +69,7 @@ distinct_count, extreme_count, floored_share, + record_source_households, rounded_count, small_cell_share, source_household_ids, @@ -1000,13 +1001,12 @@ def employee_rows( floored ] - household_sources = pd.Series( - source_household_ids(household, stage="The SPI employment pay floor"), - index=household["household_id"].to_numpy(), - ) - def sources_of(frame: pd.DataFrame) -> np.ndarray: - return frame["person_household_id"].map(household_sources).to_numpy() + return record_source_households( + {"person": frame, "household": household}, + "person", + stage="The SPI employment pay floor", + ) weights = person_weights.loc[candidates.index].to_numpy(dtype=np.float64) sources = sources_of(candidates) @@ -3679,11 +3679,11 @@ def _spi_pension_coherence( rows = spi_people.to_numpy(dtype=bool) pay = person.loc[spi_people, "employment_income"].to_numpy(dtype=np.float64) weights = _person_household_weights(person, household).to_numpy(dtype=float)[rows] - sources = ( - person["person_household_id"] - .map(household.set_index("household_id")["household_source_id"]) - .to_numpy()[rows] - ) + sources = record_source_households( + {"person": person, "household": household}, + "person", + stage="The SPI pension coherence", + )[rows] employee_before = person.loc[spi_people, "employee_pension_contributions"].to_numpy( dtype=np.float64 ) diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/support_floor.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/support_floor.py index 8afcadb79e..4b01f4a2f4 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/support_floor.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/support_floor.py @@ -17,7 +17,7 @@ never mixes units. A scope's ``unit`` is the one its targets' contract measurements give (:func:`uk_support_floor_target_unit`). On a built frame, a row in a scope whose matrix row reaches no source household -(``household_source_id``) with a positive prior weight is dropped, not pooled; +(``source_household_id``) with a positive prior weight is dropped, not pooled; each target's dropped published total is reported. The run refuses outside the block's approval window, when a scope's ``unit`` is not its targets' unit (:func:`assert_uk_support_floor_units`), when a scope's dropped rows pass @@ -51,8 +51,11 @@ UK_SUPPORT_FLOOR_VALUE = 1 UK_SUPPORT_FLOOR_KIND = "support_floor" UK_SUPPORT_FLOOR_METRIC = "distinct_source_households_with_positive_prior_weight" -#: The spine household each row was built from; every clone shares it. -UK_SUPPORT_LINEAGE_COLUMN = "household_source_id" +#: The survey household each row was built from, its true source: every copy +#: and clone shares it. The receipts' column (``receipt_counts. +#: SOURCE_HOUSEHOLD_COLUMN``), named here because the target kernels hash this +#: module and not that one; a test holds the two equal (microcosm#931). +UK_SUPPORT_LINEAGE_COLUMN = "source_household_id" _FIELDS = ( "metric", "floor", @@ -352,15 +355,26 @@ def load_uk_support_floor_declaration( def uk_household_source_ids(frame: Any) -> np.ndarray: - """The source household of each household column, or refuse.""" + """The true source household of each household column, or refuse. + + A frame without the column, or with a null in it, is refused: a null + drops out of the distinct count, so a row would read less support than it + has. + """ household = frame.table("household") if UK_SUPPORT_LINEAGE_COLUMN not in household: raise ValueError( - f"The UK support floor counts source households, and the frame has " - f"no household.{UK_SUPPORT_LINEAGE_COLUMN} column." + f"The UK support floor counts true source households, and the frame " + f"has no household.{UK_SUPPORT_LINEAGE_COLUMN} column." + ) + sources = household[UK_SUPPORT_LINEAGE_COLUMN] + if sources.isna().any(): + raise ValueError( + f"The UK support floor counts true source households, and " + f"household.{UK_SUPPORT_LINEAGE_COLUMN} is null on some rows." ) - return household[UK_SUPPORT_LINEAGE_COLUMN].to_numpy() + return sources.to_numpy() def uk_row_support( diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/trading_allowance_receipts.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/trading_allowance_receipts.py index 03260e2af9..9ca1a749d8 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/trading_allowance_receipts.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/trading_allowance_receipts.py @@ -63,9 +63,9 @@ ) from microcosm.build.uk_runtime.receipt_counts import ( distinct_count, + record_source_households, rounded_count, small_cell_share, - source_household_ids, support_band, ) from microcosm.frame import Frame, MassChangeRecord @@ -374,17 +374,12 @@ def store_trading_allowance_claim_status( strict=True, ) ) - source_by_household = dict( - zip( - household["household_id"].to_numpy(), - source_household_ids( - household, stage=TRADING_ALLOWANCE_RECEIPTS_STAGE_NAME - ), - strict=True, - ) - ) weights = person["person_household_id"].map(weight_by_household).to_numpy(float) - sources = person["person_household_id"].map(source_by_household).to_numpy() + sources = record_source_households( + {"person": person, "household": household}, + "person", + stage=TRADING_ALLOWANCE_RECEIPTS_STAGE_NAME, + ) rates = claimant_rates(profit.to_numpy(dtype=np.float64)) trader = profit.to_numpy(dtype=np.float64) > 0.0 claimant = statuses.claimant diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_take_up.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_take_up.py index 80c72bcc20..c077d84fc0 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_take_up.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_take_up.py @@ -129,9 +129,9 @@ UK_WITHHELD, distinct_count, extreme_count, + record_source_households, rounded_count, small_cell_share, - source_household_ids, support_band, ) from microcosm.build.uk_runtime.uc_capital_coherence import ( @@ -237,7 +237,7 @@ UC_TAKE_UP_MINIMUM_POOL_SOURCES = 30 UC_TAKE_UP_POOLING = ( "adjacent bands within a family type, lowest first, until the drawn units " - "rest on minimum_pool_sources distinct household_source_id values; a short " + "rest on minimum_pool_sources distinct source_household_id values; a short " "last pool joins the one before it. Then, lowest first, a pool that cannot " "meet DWP's count (its undrawn entitled units' expected claims exceed the " "count, or the count exceeds them plus the weight of every drawn unit) is " @@ -1431,12 +1431,11 @@ def redraw_uc_take_up( if regions.isna().any(): raise ValueError("Every benefit unit's household must carry a region.") great_britain = regions.astype(str).ne(_OUTSIDE_SOLVE_REGION).to_numpy(dtype=bool) - source_ids = unit_households.map( - pd.Series( - source_household_ids(household, stage="The UC take-up stage"), - index=household["household_id"].to_numpy(), - ) - ).to_numpy() + source_ids = record_source_households( + {"person": person, "benunit": benunit, "household": household}, + "benunit", + stage="The UC take-up stage", + ) # A unit the engine moves off its legacy benefits claims at the closure # with the probability ``uc_legacy_closure_take_up`` gives it; this stage # leaves its flag alone, so the closure's share already claiming, and so diff --git a/packages/microcosm-build/tests/engine/uk/test_uk_carers_allowance_take_up.py b/packages/microcosm-build/tests/engine/uk/test_uk_carers_allowance_take_up.py index 052bbf7996..d67a35782b 100644 --- a/packages/microcosm-build/tests/engine/uk/test_uk_carers_allowance_take_up.py +++ b/packages/microcosm-build/tests/engine/uk/test_uk_carers_allowance_take_up.py @@ -198,7 +198,7 @@ def _frame(): "council_tax": [0.0] * 5, "tenure_type": ["OWNED_OUTRIGHT"] * 5, "rent": [0.0] * 5, - "household_source_id": [1, 2, 3, 4, 5], + "source_household_id": [1, 2, 3, 4, 5], } ) return uk_national_frame( diff --git a/packages/microcosm-build/tests/engine/uk/test_uk_company_cars.py b/packages/microcosm-build/tests/engine/uk/test_uk_company_cars.py index ad81cfc80d..610ecb00dd 100644 --- a/packages/microcosm-build/tests/engine/uk/test_uk_company_cars.py +++ b/packages/microcosm-build/tests/engine/uk/test_uk_company_cars.py @@ -95,7 +95,7 @@ def _frame(): "council_tax": [0.0] * 6, "tenure_type": ["OWNED_OUTRIGHT"] * 6, "rent": [0.0] * 6, - "household_source_id": [1, 2, 3, 4, 5, 6], + "source_household_id": [1, 2, 3, 4, 5, 6], } ) return uk_national_frame( diff --git a/packages/microcosm-build/tests/engine/uk/test_uk_council_tax_liability_tool.py b/packages/microcosm-build/tests/engine/uk/test_uk_council_tax_liability_tool.py index 36d3844271..81263d4728 100644 --- a/packages/microcosm-build/tests/engine/uk/test_uk_council_tax_liability_tool.py +++ b/packages/microcosm-build/tests/engine/uk/test_uk_council_tax_liability_tool.py @@ -64,7 +64,7 @@ def test_the_table_holds_the_engine_liabilities_beside_the_stored_bill( _frame( local_authority=["MAIDSTONE", "CARDIFF"], la_code_oa=["E07000110", "W06000015"], - household_source_id=np.asarray([7, 8], dtype="int64"), + source_household_id=np.asarray([7, 8], dtype="int64"), ), tmp_path / "dense.h5", ) @@ -81,7 +81,7 @@ def test_the_table_holds_the_engine_liabilities_beside_the_stored_bill( assert table.loc[12, "council_tax_band"] == "B" assert table.loc[12, "country"] == "WALES" assert table["la_code_oa"].tolist() == ["E07000110", "W06000015"] - assert table["household_source_id"].tolist() == [7, 8] + assert table["source_household_id"].tolist() == [7, 8] def test_a_file_without_authorities_is_refused(tmp_path: Path) -> None: diff --git a/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py b/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py new file mode 100644 index 0000000000..83e153aa08 --- /dev/null +++ b/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py @@ -0,0 +1,141 @@ +"""The shared readers of copy lineage, on invented tables (microcosm#931).""" + +from __future__ import annotations + +import numpy as np +import pandas as pd +import pytest + +from microcosm.build.source_lineage import CopyBranch, CopyLineage, record_sources +from microcosm.frame import EntitySchema + +SCHEMA = EntitySchema(group_entities=("unit", "household")) +LINEAGE = CopyLineage( + entity="household", + branches=( + CopyBranch( + "support", index="support_index", marker="channel", copy="b", original="a" + ), + CopyBranch("clone", marker="is_clone"), + CopyBranch("place", index="place_index"), + ), +) + + +def _tables(*, with_source: bool = True) -> dict[str, pd.DataFrame]: + """Two survey households; the first has a support copy and a placed clone.""" + + household = pd.DataFrame( + { + "household_id": [1, 2, 3, 4], + "channel": ["a", "a", "b", "a"], + "support_index": [0, 0, 1, 0], + "is_clone": [False, False, False, False], + "place_index": [0, 0, 0, 1], + } + ) + if with_source: + household["source_household_id"] = [1, 2, 1, 1] + person = pd.DataFrame( + { + "person_id": [10, 11, 20, 30, 31, 40, 41], + "person_unit_id": [100, 101, 200, 300, 301, 400, 401], + "person_household_id": [1, 1, 2, 3, 3, 4, 4], + } + ) + unit = pd.DataFrame({"unit_id": [100, 101, 200, 300, 301, 400, 401]}) + return {"person": person, "unit": unit, "household": household} + + +def test_every_entity_reads_its_households_true_source() -> None: + tables = _tables() + assert record_sources(tables, SCHEMA, "household", LINEAGE).tolist() == [ + 1, + 2, + 1, + 1, + ] + assert record_sources(tables, SCHEMA, "person", LINEAGE).tolist() == [ + 1, + 1, + 2, + 1, + 1, + 1, + 1, + ] + assert record_sources(tables, SCHEMA, "unit", LINEAGE).tolist() == [ + 1, + 1, + 2, + 1, + 1, + 1, + 1, + ] + + +def test_a_frame_without_the_source_is_refused_unless_it_holds_no_copies() -> None: + tables = _tables(with_source=False) + with pytest.raises(ValueError, match="copy lineage"): + record_sources(tables, SCHEMA, "person", LINEAGE, before_copies=True) + before = { + **tables, + "household": tables["household"][["household_id"]].iloc[:2], + "person": tables["person"].iloc[:3], + "unit": tables["unit"].iloc[:3], + } + with pytest.raises(ValueError, match="lacks 'source_household_id'"): + record_sources(before, SCHEMA, "person", LINEAGE) + # Before the first copying step each household is its own source. + assert record_sources( + before, SCHEMA, "person", LINEAGE, before_copies=True + ).tolist() == [1, 1, 2] + + +@pytest.mark.parametrize("defect", ["null_source", "orphan_person", "split_unit"]) +def test_a_record_without_one_true_source_is_refused(defect: str) -> None: + tables = _tables() + entity = "person" + if defect == "null_source": + tables["household"]["source_household_id"] = pd.array( + [1, None, 1, 1], dtype="Int64" + ) + elif defect == "orphan_person": + tables["person"].loc[0, "person_household_id"] = 9 + else: + tables["person"].loc[1, "person_unit_id"] = 200 + entity = "unit" + with pytest.raises(ValueError): + record_sources(tables, SCHEMA, entity, LINEAGE) + + +@pytest.mark.parametrize( + "branches", + [ + (CopyBranch("a", index="x"), CopyBranch("a", index="y")), + (CopyBranch("a", index="x"), CopyBranch("b", marker="x")), + (CopyBranch("a", index="source_household_id"),), + ], +) +def test_a_lineage_needs_distinct_branches_and_columns(branches) -> None: + with pytest.raises(ValueError): + CopyLineage(entity="household", branches=branches) + + +@pytest.mark.parametrize( + "kwargs", [{}, {"index": "x", "copy": 1, "original": 1}, {"name": ""}] +) +def test_a_branch_declares_a_column_and_tells_copies_apart(kwargs) -> None: + with pytest.raises(ValueError): + CopyBranch(**{"name": "a", **kwargs}) + + +def test_record_sources_returns_the_tables_row_order() -> None: + tables = _tables() + order = [3, 0, 2, 1] + shuffled = {**tables, "household": tables["household"].iloc[order]} + assert np.array_equal( + record_sources(shuffled, SCHEMA, "household", LINEAGE), + np.asarray([1, 1, 1, 2]), + ) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_carers_allowance_take_up.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_carers_allowance_take_up.py index 57a59c5ea5..3b6a15ff90 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_carers_allowance_take_up.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_carers_allowance_take_up.py @@ -153,7 +153,7 @@ def _frame( } ) if lineage: - household["household_source_id"] = ( + household["source_household_id"] = ( ids if source_ids is None else np.asarray(source_ids, dtype="int64") ) return uk_national_frame( @@ -648,7 +648,7 @@ def _two_route_frame(): frame.table("household"), inside.table("household").assign( household_id=lambda df: df["household_id"] + 10_000, - household_source_id=lambda df: df["household_source_id"] + 10_000, + source_household_id=lambda df: df["source_household_id"] + 10_000, ), ], ignore_index=True, @@ -700,7 +700,7 @@ def test_households_are_read_through_membership_not_position() -> None: { "household_id": household_ids, "region": pd.array(regions, dtype="string"), - "household_source_id": household_ids * 10, + "source_household_id": household_ids * 10, } ) frame = uk_national_frame( @@ -768,7 +768,7 @@ def test_the_stage_refuses_a_frame_without_lineage() -> None: weekly_pay=np.full(3, 300.0), lineage=False, ) - with pytest.raises(ValueError, match="household_source_id"): + with pytest.raises(ValueError, match="source_household_id"): _run(frame) @@ -778,7 +778,7 @@ def test_the_stage_refuses_a_null_lineage() -> None: reported=np.zeros(3), weekly_pay=np.full(3, 300.0), ) - frame.table("household")["household_source_id"] = pd.array( + frame.table("household")["source_household_id"] = pd.array( [1, None, 3], dtype="Int64" ) # A null would drop out of a distinct count or count as one source. @@ -914,7 +914,7 @@ def test_the_graph_node_reads_the_lineage_and_rewrites_the_flag_on_its_own_bound # An open surface: the receipt's lineage and the eligibility's inputs # reach the stage in a graph build. assert { - ("household", "household_source_id"), + ("household", "source_household_id"), ("household", "region"), ("person", "care_hours"), ("person", _INSIDE), diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_company_cars.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_company_cars.py index 4c042ff356..7fd19021cd 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_company_cars.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_company_cars.py @@ -569,7 +569,7 @@ def _stage_frame(seed: int = 1, households: int = 600, order=None, sources=None) household = pd.DataFrame( { "household_id": ids, - "household_source_id": ids if sources is None else sources(ids), + "source_household_id": ids if sources is None else sources(ids), } ) rows = [] @@ -1113,7 +1113,7 @@ def test_salary_sacrifice_runs_on_the_stage_s_output( household = pd.DataFrame( { "household_id": ids, - "household_source_id": ids, + "source_household_id": ids, "household_support_channel": np.where(spi, "spi", "frs"), } ) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_council_tax_liability_tool.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_council_tax_liability_tool.py index 21c0d3912d..49da88438d 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_council_tax_liability_tool.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_council_tax_liability_tool.py @@ -35,7 +35,7 @@ def _households( "simulated_council_tax": simulated, "simulated_council_tax_less_discounts": less_discounts, "la_code_oa": code, - "household_source_id": source, + "source_household_id": source, } for source in sources ] diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_annual_income.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_annual_income.py index 1086ffa522..74d0a02120 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_annual_income.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_annual_income.py @@ -18,6 +18,7 @@ from microcosm.build.source_manifest import SourceOperationSpec, SourceStageSpec from microcosm.build.uk_runtime import frs_annual_income as fai from microcosm.build.uk_runtime.frs_spine import WEEKS_IN_YEAR +from microcosm.build.uk_runtime.receipt_counts import own_source_households from microcosm.build.uk_runtime.stage_health import uk_stage_health_gate INTERVIEW = pd.Timestamp("2024-10-15") @@ -416,6 +417,7 @@ def test_receipt_bands_its_structural_counts(broken: int, count: object) -> None receipt = fai._receipt( pd.DataFrame({"person_household_id": np.arange(rows)}), weights=np.ones(rows), + household_sources=np.arange(rows), descriptors=descriptors, current=np.zeros(rows), se_current=np.zeros(rows), @@ -445,6 +447,7 @@ def test_receipt_says_whether_the_stage_held_the_ratio(ratio, support, held) -> receipt = fai._receipt( pd.DataFrame({"person_household_id": np.arange(rows)}), weights=np.ones(rows), + household_sources=np.arange(rows), descriptors=pd.DataFrame( {column: np.ones(rows) for column in fai.ANNUAL_SHARE_COLUMNS} | {column: np.zeros(rows) for column in fai.OTHER_SPELLS_COLUMNS} @@ -544,6 +547,7 @@ def test_pay_concept_ratio_measures_few_reporters_and_refuses_none() -> None: np.ones(len(person)), job.iloc[:5], np.ones(len(person), dtype=bool), + household_sources=own_source_households(person), ) assert 0 < support < 10 and math.isfinite(ratio) with pytest.raises(ValueError, match="no household reports both"): @@ -552,11 +556,13 @@ def test_pay_concept_ratio_measures_few_reporters_and_refuses_none() -> None: np.ones(len(person)), job.iloc[:0], np.ones(len(person), dtype=bool), + household_sources=own_source_households(person), ) def _reporting_jobs(households: int, ratio: float) -> tuple: - """One current employee main job a household, at one DV-to-usual ratio.""" + """One current employee main job a household, at one DV-to-usual ratio; + each holder is their own household and so their own source.""" person_ids = np.arange(1, households + 1) job = pd.DataFrame( { @@ -576,10 +582,12 @@ def test_a_thin_pay_concept_ratio_is_held_to_its_bounds(measured, used) -> None: """On fewer than ten households a ratio past the plausibility bounds is noise: it is held to them, and the build goes on (Vahid's second review of #1396). On ten or more it still refuses.""" - ratio, support = fai.pay_concept_ratio(*_reporting_jobs(5, measured)) + jobs = _reporting_jobs(5, measured) + ratio, support = fai.pay_concept_ratio(*jobs, household_sources=jobs[0]) assert support == 5 and ratio == pytest.approx(used) with pytest.raises(ValueError, match="lies outside"): - fai.pay_concept_ratio(*_reporting_jobs(10, 1.5)) + jobs = _reporting_jobs(10, 1.5) + fai.pay_concept_ratio(*jobs, household_sources=jobs[0]) @pytest.mark.parametrize("key", ["pay_concept_ratio", "annual_over_current_earners"]) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_graph.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_graph.py index acfb58de36..60ea5700a6 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_graph.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_graph.py @@ -232,6 +232,76 @@ def changed_helper_bytes(path: Path) -> bytes: assert registry.implementation_hash(control) == before[control] +def _imported_module_names(module) -> set[str]: + import ast + import inspect + + tree = ast.parse(Path(inspect.getfile(module)).read_text(encoding="utf-8")) + names: set[str] = set() + for node in ast.walk(tree): + if isinstance(node, ast.ImportFrom): + if node.module: + names.add(node.module.rsplit(".", 1)[-1]) + names.update(alias.name for alias in node.names) + elif isinstance(node, ast.Import): + names.update(alias.name.rsplit(".", 1)[-1] for alias in node.names) + return names + + +def test_every_stage_that_counts_by_lineage_binds_the_counting_modules() -> None: + """An edit to how a floor counts moves the hash of every stage that counts. + + ``source_hash`` does not follow imports, so the receipts' counting rules, + the shared lineage reader and the UK's lineage declaration are bound into + each stage whose module or helpers import one of them (microcosm#931). + """ + from microcosm.build.uk_runtime import graph_kernels + + counting = {"receipt_counts", "household_lineage", "source_lineage"} + expected = { + stage + for stage in graph_kernels._STAGE_MODULES + if any( + counting & _imported_module_names(module) + for module in ( + graph_kernels._stage_module(stage), + *graph_kernels._STAGE_HELPER_MODULES.get(stage, ()), + ) + ) + } + assert set(graph_kernels._COUNTING_STAGES) == expected + + +def test_counting_module_changes_invalidate_every_stage_that_counts(monkeypatch): + from microcosm.build import source_lineage + from microcosm.build.uk_runtime import graph_kernels, receipt_counts + + graph = uk_spine_graph() + registry = uk_registry(graph=graph) + affected = [ + graph.node(stage).kernel for stage in sorted(graph_kernels._COUNTING_STAGES) + ] + control = graph.node("frs_council_tax").kernel + for module in (receipt_counts, source_lineage): + before = { + ref: registry.implementation_hash(ref) for ref in (*affected, control) + } + helper_path = Path(module.__file__).resolve() + original = Path.read_bytes + + def changed_helper_bytes(path: Path, helper=helper_path, read=original): + content = read(path) + if path.resolve() == helper: + return content + b"\n# A helper-only source change.\n" + return content + + with monkeypatch.context() as patched: + patched.setattr(Path, "read_bytes", changed_helper_bytes) + for ref in affected: + assert registry.implementation_hash(ref) != before[ref], ref + assert registry.implementation_hash(control) == before[control] + + def test_isa_statistics_source_changes_invalidate_the_stages_that_read_them( monkeypatch, ): @@ -494,5 +564,5 @@ def test_spi_benefit_coherence_reads_cover_its_work_tests() -> None: SPI_WITHIN_LIMIT_HOURS_COLUMN, SPI_PENSION_PAYMENTS_COLUMN, ) - } | {("household", "household_source_id")} + } | {("household", "source_household_id")} assert required <= declared, sorted(required - declared) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_legacy_closure_take_up.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_legacy_closure_take_up.py index 7a797506f6..d9b409da3a 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_legacy_closure_take_up.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_legacy_closure_take_up.py @@ -200,7 +200,7 @@ def _frame( } ) if lineage: - household["household_source_id"] = ( + household["source_household_id"] = ( ids if source_ids is None else np.asarray(source_ids, dtype="int64") ) return uk_national_frame( @@ -276,7 +276,7 @@ def test_only_the_claimant_and_partner_place_a_unit_in_the_draw() -> None: { "household_id": np.asarray([1, 2], dtype="int64"), "region": pd.array(["NORTH_WEST", "NORTH_WEST"], dtype="string"), - "household_source_id": np.asarray([1, 2], dtype="int64"), + "source_household_id": np.asarray([1, 2], dtype="int64"), } ), time_period="2024", @@ -560,7 +560,7 @@ def test_the_stage_bands_support_copies_on_their_sources() -> None: def test_the_graph_node_bands_support_copies_on_their_sources() -> None: # The same cell through the executor's input projection: the node declares - # household_source_id, so a graph build counts sources too. + # source_household_id, so a graph build counts sources too. combinations = _graph_evidence(_copies_of_two_households())["combinations"] assert combinations["esa_income"]["rate_unreachable"] == "<3" assert combinations["esa_income"]["support"] == "<3" @@ -573,7 +573,7 @@ def test_the_stage_refuses_a_frame_without_lineage() -> None: weights=np.ones(3), lineage=False, ) - with pytest.raises(ValueError, match="household_source_id"): + with pytest.raises(ValueError, match="source_household_id"): lc.assign_uc_claim_at_legacy_closure(frame, rates=_RATES) @@ -618,7 +618,7 @@ def test_the_stage_refuses_a_null_lineage() -> None: would_claim_uc=np.zeros(3, dtype=bool), weights=np.ones(3), ) - frame.table("household")["household_source_id"] = pd.array( + frame.table("household")["source_household_id"] = pd.array( [1, None, 3], dtype="Int64" ) # A null would drop out of a distinct count or count as one source. diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_pension_coherence.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_pension_coherence.py index 461f44191c..b04251e32d 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_pension_coherence.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_pension_coherence.py @@ -107,7 +107,7 @@ def test_the_spi_stage_applies_the_rule_to_its_recipients() -> None: { "household_id": [10, 20, 30, 40, 50], "household_weight": [1.0] * 5, - "household_source_id": [10, 20, 30, 40, 50], + "source_household_id": [10, 20, 30, 40, 50], } ) recipients = pd.Series([True, True, True, False, True]) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_private_rent_localisation.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_private_rent_localisation.py index 588a1fd0e6..c1a43d68d5 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_private_rent_localisation.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_private_rent_localisation.py @@ -49,6 +49,8 @@ def _rows(**overrides) -> dict: base = { "spine_key": np.array(["a", "b", "c", "d", "d", "e", "f"], dtype=object), + # The FRS clone pair d shares its true source household. + "source": np.array([1, 2, 3, 4, 4, 5, 6]), "region": np.array( [ "LONDON", @@ -142,6 +144,7 @@ def test_frs_renters_rank_within_their_cell_and_spi_renters_land_among_them() -> mask = prl.redraw_mask(rows["region"], rows["tenure_type"], rows["rent"]) spine = prl._spine_rows( spine_key=rows["spine_key"][mask], + source=rows["source"][mask], region=rows["region"][mask], category=prl.rent_categories(rows["num_bedrooms"][mask]), rent=rows["rent"][mask], @@ -216,6 +219,7 @@ def test_region_scale_holds_the_frs_mean_on_the_census_mix() -> None: mask = prl.redraw_mask(rows["region"], rows["tenure_type"], rows["rent"]) spine = prl._spine_rows( spine_key=rows["spine_key"][mask], + source=rows["source"][mask], region=rows["region"][mask], category=prl.rent_categories(rows["num_bedrooms"][mask]), rent=rows["rent"][mask], @@ -261,6 +265,7 @@ def test_renters_on_the_census_mix_keep_their_regions_frs_level(seed) -> None: keys = np.array([f"k{i}" for i in range(n)], dtype=object) new, _ = prl.localise_rents( spine_key=keys, + source=np.arange(n), region=np.full(n, "LONDON"), tenure_type=np.full(n, "RENT_PRIVATELY"), rent=rent, @@ -592,6 +597,7 @@ def _regional_rows(*, wales_frs: int, wales_rent: float = 9_000.0) -> dict: channel = ["frs"] * london + ["spi"] + ["frs"] * wales_frs + ["spi"] return { "spine_key": np.array([f"k{index}" for index in range(n)], dtype=object), + "source": np.arange(n), "region": np.array(region), "tenure_type": np.full(n, "RENT_PRIVATELY"), "rent": np.asarray(rent, dtype=float), diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_property_purchases.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_property_purchases.py index 9065c158de..555b57cfd2 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_property_purchases.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_property_purchases.py @@ -417,7 +417,7 @@ def _frame(n: int = 300, seed: int = 3, time_period: str = "2024"): household = pd.DataFrame( { "household_id": np.arange(1, n + 1, dtype="int64"), - "household_source_id": np.arange(1, n + 1, dtype="int64"), + "source_household_id": np.arange(1, n + 1, dtype="int64"), "region": pd.array(regions[rng.integers(0, 6, n)], dtype="string"), "other_residential_property_value": np.where( rng.random(n) < 0.5, rng.lognormal(12.6, 0.8, n), 0.0 @@ -588,7 +588,7 @@ def test_the_stage_refuses_a_stored_output_or_a_missing_lineage() -> None: stored = pp.impute_property_purchases(frame, targets=_frame_targets()).frame with pytest.raises(ValueError, match="already stored"): pp.impute_property_purchases(stored, targets=_frame_targets()) - household = frame.table("household").drop(columns="household_source_id") + household = frame.table("household").drop(columns="source_household_id") bare = uk_national_frame( person=frame.table("person"), benunit=frame.table("benunit"), @@ -597,13 +597,13 @@ def test_the_stage_refuses_a_stored_output_or_a_missing_lineage() -> None: weight_kind=WeightKind.DESIGN, household_weights=np.asarray(frame.weights_for("household").values), ) - with pytest.raises(ValueError, match="household_source_id"): + with pytest.raises(ValueError, match="source_household_id"): pp.impute_property_purchases(bare, targets=_frame_targets()) # A null would drop out of a distinct count or count as one source. nulls = _frame() - sources = nulls.table("household")["household_source_id"].astype("Int64") + sources = nulls.table("household")["source_household_id"].astype("Int64") sources.iloc[0] = None - nulls.table("household")["household_source_id"] = sources + nulls.table("household")["source_household_id"] = sources with pytest.raises(ValueError, match="null"): pp.impute_property_purchases(nulls, targets=_frame_targets()) @@ -617,7 +617,7 @@ def _copies_frame(): household = pd.DataFrame( { "household_id": ids, - "household_source_id": np.arange(n, dtype="int64") % 2, + "source_household_id": np.arange(n, dtype="int64") % 2, "region": pd.array(["LONDON"] * n, dtype="string"), "other_residential_property_value": np.full(n, 200_000.0), "non_residential_property_value": np.zeros(n), diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_receipt_counts.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_receipt_counts.py index 8813e01e7c..ad6fa1df73 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_receipt_counts.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_receipt_counts.py @@ -369,3 +369,233 @@ def test_a_cell_is_counted_by_the_same_rule() -> None: cell = np.array([True, True, True, True, False]) assert distinct_count(ids, cell) == 3 assert distinct_count(ids, cell, np.array([1.0, 0.0, 0.0, 2.0, 1.0])) == 2 + + +#: The columns no UK floor counts directly (microcosm#931): a household row +#: or a person's household is a row, not a survey household, once copies and +#: clones exist, and ``household_source_id`` is the support channel's +#: immediate parent. Floors count true sources through receipt_counts. +_ROW_IDENTITY_COLUMNS = frozenset( + {"household_id", "person_household_id", "household_source_id"} +) +#: Counts of those columns that are no floor: structural checks that every +#: benefit unit sits in one household. Each entry names the phrase holding the +#: count and how many counts it covers in its file. +_KEPT_ROW_COUNTS: dict[str, tuple[tuple[str, int], ...]] = { + "uk_runtime/uc_reporter_redraw.py": ( + ( + 'counts = placements.groupby("person_benunit_id", sort=False)[ ' + '"person_household_id" ].nunique()', + 1, + ), + ), + "tools/preflight_uk_frame_linkage.py": ( + ( + 'households_per_benunit = person.groupby("person_benunit_id")[ ' + '"person_household_id" ].nunique()', + 1, + ), + ), +} +#: Calls that keep an identity's values, so a count of their result counts it. +_VALUE_KEEPING_METHODS = frozenset( + {"to_numpy", "unique", "astype", "tolist", "to_list", "dropna"} + | {"drop_duplicates", "copy", "sort_values"} +) +_VALUE_KEEPING_ATTRIBUTES = frozenset({"values", "loc", "iloc", "array"}) +_VALUE_KEEPING_CALLS = frozenset( + {"asarray", "array", "unique", "list", "set", "Series", "Index", "sorted"} + | {"tuple"} +) + + +def _call_name(node) -> str | None: + import ast + + if isinstance(node.func, ast.Name): + return node.func.id + if isinstance(node.func, ast.Attribute): + return node.func.attr + return None + + +def _row_identity(node, names: set[str]) -> bool: + """Whether ``node`` holds a row identity column's values.""" + + import ast + + while True: + if isinstance(node, ast.Subscript): + key = node.slice + if isinstance(key, ast.Constant) and key.value in _ROW_IDENTITY_COLUMNS: + return True + node = node.value + elif isinstance(node, ast.Attribute): + if node.attr in _ROW_IDENTITY_COLUMNS: + return True + if node.attr not in _VALUE_KEEPING_ATTRIBUTES: + return False + node = node.value + elif isinstance(node, ast.Call): + name = _call_name(node) + if isinstance(node.func, ast.Attribute) and name in _VALUE_KEEPING_METHODS: + node = node.func.value + elif name in _VALUE_KEEPING_CALLS and node.args: + node = node.args[0] + else: + return False + else: + return isinstance(node, ast.Name) and node.id in names + + +def _counted_keys(node): + """The keys a distinct count counts, or None for any other node.""" + + import ast + + if not isinstance(node, ast.Call): + return None + name = _call_name(node) + if name in {"distinct_count", "distinct_carriers"} and node.args: + return node.args[0] + if name in {"nunique", "value_counts"} and isinstance(node.func, ast.Attribute): + return node.func.value + if name == "len" and node.args and isinstance(node.args[0], ast.Call): + inner = node.args[0] + inner_name = _call_name(inner) + if inner_name in {"set", "unique"} and inner.args: + return inner.args[0] + if inner_name in {"unique", "drop_duplicates"} and isinstance( + inner.func, ast.Attribute + ): + return inner.func.value + return None + + +def _row_identity_counts(tree) -> list[int]: + """Lines that count a row identity column, scope by scope. + + A name holds an identity where it is assigned one in its own function or + an enclosing one; a ``map`` through it holds what it maps to. + """ + + import ast + + found: list[int] = [] + + def own_nodes(scope): + stack = list(ast.iter_child_nodes(scope)) + while stack: + node = stack.pop() + yield node + if not isinstance( + node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Lambda, ast.ClassDef) + ): + stack.extend(ast.iter_child_nodes(node)) + + def scan(scope, inherited: set[str]) -> None: + names = set(inherited) + nodes = list(own_nodes(scope)) + assignments = [ + node + for node in nodes + if isinstance(node, (ast.Assign, ast.AnnAssign)) and node.value is not None + ] + grew = True + while grew: + grew = False + for node in assignments: + if not _row_identity(node.value, names): + continue + targets = ( + node.targets if isinstance(node, ast.Assign) else [node.target] + ) + for target in targets: + if isinstance(target, ast.Name) and target.id not in names: + names.add(target.id) + grew = True + for node in nodes: + keys = _counted_keys(node) + if keys is not None and _row_identity(keys, names): + found.append(node.lineno) + if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): + scan(node, names) + elif isinstance(node, ast.ClassDef): + scan(node, set()) + + scan(tree, set()) + return sorted(set(found)) + + +def test_no_uk_floor_counts_rows_by_their_household_ids() -> None: + """Every UK floor counts true source households (microcosm#931). + + Once support copies or geographic clones exist, ``household_id`` and + ``person_household_id`` name rows, and ``household_source_id`` names the + support channel's immediate parent, so a count of any of them reads a + household's copies as sources of their own. Over the UK runtime and the UK + tools, a distinct count (``distinct_count``, ``distinct_carriers``, + ``nunique``, ``value_counts``, or ``len`` of a ``set`` or ``unique``) of + such a column, or of a name holding one, must be named in + ``_KEPT_ROW_COUNTS``; floors count through + ``receipt_counts.record_source_households`` instead. + """ + + import ast + + root = paths_for("microcosm-build").repository + build = paths_for("microcosm-build").package / "src" / "microcosm" / "build" + uk_tool = re.compile(r"(?:^|_)uk(?:_|$)") + paths = ( + *(build / "uk_runtime").rglob("*.py"), + *(path for path in (root / "tools").rglob("*.py") if uk_tool.search(path.stem)), + ) + found = [] + covered: dict[tuple[str, str], int] = {} + for path in sorted(paths): + text = path.read_text(encoding="utf-8") + name = path.relative_to(root).as_posix() + kept = next( + ( + entries + for suffix, entries in _KEPT_ROW_COUNTS.items() + if name.endswith(suffix) + ), + (), + ) + lines = text.splitlines() + for line in _row_identity_counts(ast.parse(text)): + start = sum(len(row) + 1 for row in lines[: line - 1]) + end = start + len(lines[line - 1]) + phrase = next( + ( + phrase + for phrase, _ in kept + if any( + at.start() <= end and at.end() >= start + for at in re.finditer( + r"\s*".join(map(re.escape, phrase.split())), text + ) + ) + ), + None, + ) + if phrase is None: + found.append(f"{name}:{line}: {lines[line - 1].strip()[:120]}") + else: + covered[(name, phrase)] = covered.get((name, phrase), 0) + 1 + assert found == [] + expected = { + (suffix, phrase): count + for suffix, entries in _KEPT_ROW_COUNTS.items() + for phrase, count in entries + } + seen = { + (suffix, phrase): sum( + hits + for (name, kept_phrase), hits in covered.items() + if name.endswith(suffix) and kept_phrase == phrase + ) + for suffix, phrase in expected + } + assert seen == expected diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_regional_home_values.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_regional_home_values.py index b47be01658..0e90e47af4 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_regional_home_values.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_regional_home_values.py @@ -80,7 +80,7 @@ def _frame(n: int = 200, seed: int = 5, *, source_ids=None, lineage: bool = True } ) if lineage: - household["household_source_id"] = ( + household["source_household_id"] = ( household["household_id"].to_numpy() if source_ids is None else np.asarray(source_ids, dtype="int64") @@ -344,21 +344,21 @@ def test_the_cap_cell_is_banded_on_its_source_households(monkeypatch) -> None: # UKDS disclosure control: twelve rows past ten, but three sources, so the # cell reads the sources' band "3-9", not the rows' "10-29", directly and # through the production node as a graph build runs it (the node declares - # household_source_id). + # source_household_id). frame = _london_copies_at_the_cap(monkeypatch) assert rhv.assign_regional_home_values(frame).receipt["sources_at_cap"] == "3-9" assert _graph_evidence(frame)["sources_at_cap"] == "3-9" def test_the_stage_refuses_a_frame_without_lineage() -> None: - with pytest.raises(ValueError, match="household_source_id"): + with pytest.raises(ValueError, match="source_household_id"): rhv.assign_regional_home_values(_frame(lineage=False)) # A null would drop out of the distinct count: the cap cell would read 0 # with rows in it. frame = _frame() - sources = frame.table("household")["household_source_id"].astype("Int64") + sources = frame.table("household")["source_household_id"].astype("Int64") sources.iloc[0] = None - frame.table("household")["household_source_id"] = sources + frame.table("household")["source_household_id"] = sources with pytest.raises(ValueError, match="null"): rhv.assign_regional_home_values(frame) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_salary_sacrifice.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_salary_sacrifice.py index fe663bfa86..877e14d245 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_salary_sacrifice.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_salary_sacrifice.py @@ -105,6 +105,7 @@ def _frame( { "household_id": ids, "household_source_id": ids, + "source_household_id": ids, "household_support_channel": channels, HOUSEHOLD_IS_CGT_CLONE: clones, HOUSEHOLD_IS_CGT_SUPPORT_COPY: donors, @@ -518,6 +519,7 @@ def draw(recipient: pd.DataFrame, ids: np.ndarray) -> pd.DataFrame: HOUSEHOLD_IS_CGT_CLONE: False, HOUSEHOLD_IS_CGT_SUPPORT_COPY: False, "household_source_id": groups, + "source_household_id": groups, } ), household_weights=np.ones(len(ids)), diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_benefit_coherence.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_benefit_coherence.py index 965cc8575b..553f5f7021 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_benefit_coherence.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_benefit_coherence.py @@ -210,6 +210,7 @@ def _frame(*, base_own_right_override: bool | None = None): "household_id": [1, 2, 3, 5, 6, 7], # Each SPI copy repeats its twin's household. "household_source_id": [1, 2, 3, 1, 2, 3], + "source_household_id": [1, 2, 3, 1, 2, 3], } ) return uk_national_frame( diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py index d5b5770622..634dee9eeb 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py @@ -1187,6 +1187,7 @@ def _pay_floor_frames( { "household_id": np.arange(1, len(rows) + 1), "household_source_id": [row.get("source", i) for i, row in enumerate(rows)], + "source_household_id": [row.get("source", i) for i, row in enumerate(rows)], } ) rows_mask = pd.Series([row.get("drawn", True) for row in rows], index=person.index) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_stochastic_tools.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_stochastic_tools.py index d85c10fc00..e56830cdc9 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_stochastic_tools.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_stochastic_tools.py @@ -364,6 +364,7 @@ def test_brma_cell_distribution_masks_small_counts_and_reports_z() -> None: "region": ["LONDON"] * 4, "LHA_category": ["A"] * 4, "brma": ["CENTRAL", "CENTRAL", "CENTRAL", "OUTER"], + "source_household": [1, 2, 3, 4], } ) resource = {"cells": {"LONDON": {"A": {"CENTRAL": 1, "OUTER": 1}}}} @@ -392,6 +393,7 @@ def test_brma_cell_distribution_fails_closed_on_missing_cell() -> None: "region": ["LONDON"], "LHA_category": ["B"], "brma": ["CENTRAL"], + "source_household": [1], } ) resource = {"cells": {"LONDON": {"A": {"CENTRAL": 1}}}} diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_support_floor.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_support_floor.py index 4209f87b3b..12147967ef 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_support_floor.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_support_floor.py @@ -67,7 +67,7 @@ def _frame(): { "household_id": [1, 2, 3, 4, 5, 6], "region": ["LONDON"] * 6, - "household_source_id": [10, 10, 20, 30, 40, 40], + "source_household_id": [10, 10, 20, 30, 40, 40], "band_low": [1.0, 1.0, 1.0, 1.0, 0.0, 0.0], "band_thin": [1.0, 1.0, 0.0, 0.0, 0.0, 1.0], "band_zero_weight": [0.0, 0.0, 0.0, 0.0, 1.0, 1.0], @@ -290,11 +290,11 @@ def test_lineage_is_read_only_when_a_row_in_scope_needs_it(): no_lineage = uk_national_frame( person=frame.table("person"), benunit=frame.table("benunit"), - household=frame.table("household").drop(columns=["household_source_id"]), + household=frame.table("household").drop(columns=["source_household_id"]), household_weights=frame.weights_for("household").values, time_period="2025", ) - with pytest.raises(ValueError, match="household_source_id"): + with pytest.raises(ValueError, match="source_household_id"): uk_household_source_ids(no_lineage) @@ -708,3 +708,13 @@ def test_readers_take_the_solved_register_from_the_problem_bindings(): solved_national_measure_exclusions( document, {"measure_exclusions": {"thin": record}} ) + + +def test_the_floor_counts_the_receipts_true_source_column() -> None: + """The floor names its column because the target kernels hash it and not + receipt_counts; the two stay one column (microcosm#931).""" + + from microcosm.build.uk_runtime.receipt_counts import SOURCE_HOUSEHOLD_COLUMN + from microcosm.build.uk_runtime.support_floor import UK_SUPPORT_LINEAGE_COLUMN + + assert UK_SUPPORT_LINEAGE_COLUMN == SOURCE_HOUSEHOLD_COLUMN diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_trading_allowance_receipts.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_trading_allowance_receipts.py index b81848d232..2045871371 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_trading_allowance_receipts.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_trading_allowance_receipts.py @@ -33,7 +33,7 @@ def _frame(profit: np.ndarray, *, spi=None): household = pd.DataFrame( { "household_id": ids, - "household_source_id": ids, + "source_household_id": ids, "household_weight": 2.0, "region": "LONDON", "household_is_spi_synthetic": ( diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_take_up.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_take_up.py index 0434203b37..d12c1a799a 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_take_up.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_take_up.py @@ -565,7 +565,7 @@ def _frame(time_period: str = "2024"): { "household_id": [1, 2, 3, 4], "region": ["WALES", "WALES", "WALES", "NORTHERN_IRELAND"], - "household_source_id": [101, 102, 103, 104], + "source_household_id": [101, 102, 103, 104], } ) return uk_national_frame( diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_weighted_integrity_measurement.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_weighted_integrity_measurement.py index 92f5c60e97..da8ff8e6ba 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_weighted_integrity_measurement.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_weighted_integrity_measurement.py @@ -46,7 +46,9 @@ def test_no_unit_record_value_is_ever_emitted() -> None: values = np.array([1.0, 2.0, 3.0, 4_000_000.0] * 10) weights = np.ones(values.size) - measured = MEASUREMENT._tail_measurements(values, weights, (10,)) + measured = MEASUREMENT._tail_measurements( + values, weights, (10,), sources=np.arange(values.size) + ) assert "max_abs_value" not in measured assert not any("max" in key or "min" in key for key in measured) @@ -58,7 +60,9 @@ def test_thin_column_suppresses_concentration_and_carrier_count() -> None: values = np.array([5.0, 7.0, 0.0, 0.0]) weights = np.ones(4) - measured = MEASUREMENT._tail_measurements(values, weights, (10,)) + measured = MEASUREMENT._tail_measurements( + values, weights, (10,), sources=np.arange(4) + ) assert measured["disclosure_suppressed"] is True assert measured["carriers"] is None @@ -74,6 +78,7 @@ def test_column_at_the_threshold_reports_its_statistics() -> None: values, weights, (10,), + sources=np.arange(values.size), minimum_count=10, ) @@ -88,12 +93,27 @@ def test_concentration_is_still_measurable_above_the_threshold() -> None: values = np.concatenate([[1_000.0], np.ones(99)]) weights = np.ones(values.size) - measured = MEASUREMENT._tail_measurements(values, weights, (10,)) + measured = MEASUREMENT._tail_measurements( + values, weights, (10,), sources=np.arange(values.size) + ) assert measured["disclosure_suppressed"] is False assert measured["top_shares"]["10"] > 0.9 +def test_carriers_are_counted_in_true_source_households() -> None: + """Four carrier rows copied from two source households are a thin column: + the copies count once (microcosm#931).""" + + values = np.array([5.0, 5.0, 7.0, 7.0, 0.0]) + measured = MEASUREMENT._tail_measurements( + values, np.ones(values.size), (10,), sources=np.array([1, 1, 2, 2, 3]) + ) + + assert measured["disclosure_suppressed"] is True + assert measured["carriers"] is None + + def test_top_k_below_the_minimum_count_is_refused(monkeypatch, tmp_path) -> None: monkeypatch.setattr( sys, diff --git a/tools/compare_uk_council_tax_liability.py b/tools/compare_uk_council_tax_liability.py index 45b1ece6ba..c6b1aed9ea 100644 --- a/tools/compare_uk_council_tax_liability.py +++ b/tools/compare_uk_council_tax_liability.py @@ -37,13 +37,18 @@ import pandas as pd from microcosm.build.uk_runtime.diagnostics import UK_DIAGNOSTIC_MIN_SOURCE_HOUSEHOLDS +from microcosm.build.uk_runtime.receipt_counts import ( + SOURCE_HOUSEHOLD_COLUMN, + distinct_count, + source_household_ids, +) #: The engine's two council tax liabilities, each compared with the stored bill. SIMULATED = ("simulated_council_tax", "simulated_council_tax_less_discounts") STORED = "council_tax" _MEASURES = (STORED, *SIMULATED) #: The stored household columns the comparison is cut by. -_STORED_COLUMNS = ("household_id", "la_code_oa", "household_source_id") +_STORED_COLUMNS = ("household_id", "la_code_oa", SOURCE_HOUSEHOLD_COLUMN) def household_table(dataset: str, year: int) -> pd.DataFrame: @@ -82,9 +87,13 @@ def values(name: str) -> np.ndarray: def _support(rows: pd.DataFrame) -> int: - """Distinct source households with a positive weight among ``rows``.""" + """Distinct true source households with a positive weight among ``rows``.""" - return int(rows.loc[rows["household_weight"] > 0, "household_source_id"].nunique()) + return distinct_count( + source_household_ids(rows, stage="The council-tax comparison"), + np.ones(len(rows), dtype=bool), + rows["household_weight"].to_numpy(dtype=float), + ) def _ratios(numerators: Mapping[str, float], stored: float) -> dict[str, float | None]: diff --git a/tools/diagnose_uk_benefit_cap.py b/tools/diagnose_uk_benefit_cap.py index ad0384064a..e0f961a6d3 100644 --- a/tools/diagnose_uk_benefit_cap.py +++ b/tools/diagnose_uk_benefit_cap.py @@ -194,12 +194,12 @@ def _support( The join is positional: the engine's household population keeps the spine household table's row order, so each benefit unit's household position - (through its first member) indexes the spine's ``household_source_id`` + (through its first member) indexes the spine's ``source_household_id`` directly. No id is cast, so no two households can collide. """ household = pd.read_hdf(spine, "/household") - if "household_source_id" not in household.columns: + if "source_household_id" not in household.columns: return {"available": False} household_population = simulation.populations["household"] person_household_position = np.asarray( @@ -218,7 +218,7 @@ def _support( "spine_households": int(len(household)), "engine_households": int(household_population.count), } - source = household["household_source_id"].to_numpy()[positions] + source = household["source_household_id"].to_numpy()[positions] out = { "available": True, "join": "positional (engine household order is spine table order)", @@ -241,7 +241,7 @@ def main() -> None: parser.add_argument("--dataset", required=True, help="an H5 the engine loads") parser.add_argument( "--spine", - help="the spine H5 whose household table carries household_source_id " + help="the spine H5 whose household table carries source_household_id " "(support counts; only meaningful when --dataset is that spine)", ) parser.add_argument("--year", type=int, default=2025) diff --git a/tools/diagnose_uk_uc_relationships.py b/tools/diagnose_uk_uc_relationships.py index f84f590be6..0101b8111e 100644 --- a/tools/diagnose_uk_uc_relationships.py +++ b/tools/diagnose_uk_uc_relationships.py @@ -107,12 +107,12 @@ def summarize_group(table: pd.DataFrame, mask: np.ndarray) -> dict: result = { "benefit_unit_rows": len(rows), "unique_source_benefit_units": int(rows["benunit_source_id"].nunique()), - "unique_source_households": int(rows["household_source_id"].nunique()), + "unique_source_households": int(rows["source_household_id"].nunique()), "positive_uc_rows": int(claim.sum()), } for weight in ("prior_weight", "fixed_calibrated_weight"): w = rows[weight] - source_mass = rows.loc[claim].groupby("household_source_id")[weight].sum() + source_mass = rows.loc[claim].groupby("source_household_id")[weight].sum() result[weight] = { "benefit_units": float(w.sum()), "positive_uc": float(w[claim].sum()), @@ -203,7 +203,7 @@ def factory(**kwargs): ) result = benunit.copy() result["household_id"] = hh_ids.to_numpy() - for name in ("region", "household_source_id", "household_support_channel", "rent"): + for name in ("region", "source_household_id", "household_support_channel", "rent"): result[name] = hh_ids.map(household.set_index("household_id")[name]).to_numpy() result["prior_weight"] = hh_ids.map(prior).to_numpy() result["fixed_calibrated_weight"] = hh_ids.map(weights).to_numpy() diff --git a/tools/emit_uk_brma_distribution.py b/tools/emit_uk_brma_distribution.py index 499e00ec35..6df014e0d2 100644 --- a/tools/emit_uk_brma_distribution.py +++ b/tools/emit_uk_brma_distribution.py @@ -29,6 +29,14 @@ load_uk_national_frame, uk_time_period, ) +from microcosm.build.uk_runtime.receipt_counts import ( + distinct_carriers, + record_source_households, +) + +#: Each benefit unit's true source household, which the small-count mask +#: counts by (receipt_counts), so a household's copies count once. +SOURCE_COLUMN = "source_household" def brma_cell_distribution( @@ -37,9 +45,13 @@ def brma_cell_distribution( count_resource: Mapping[str, object], minimum_count: int = 3, ) -> dict[str, object]: - """Compare built benunit BRMA shares per (region, LHA category) cell.""" + """Compare built benunit BRMA shares per (region, LHA category) cell. - required = {"region", "LHA_category", "brma"} + A BRMA's count is withheld where one or two source households carry it + (``SOURCE_COLUMN``), however many benefit units they hold. + """ + + required = {"region", "LHA_category", "brma", SOURCE_COLUMN} missing = required - set(benunit.columns) if missing: raise ValueError(f"benunit table is missing column(s): {sorted(missing)}.") @@ -57,10 +69,15 @@ def brma_cell_distribution( ) expected_total = float(sum(expected_counts.values())) built_counts = group["brma"].astype(str).value_counts().to_dict() + built_sources = { + str(brma): distinct_carriers(sources) + for brma, sources in group.groupby(group["brma"].astype(str))[SOURCE_COLUMN] + } cell_n = int(len(group)) for brma, expected_count in sorted(expected_counts.items()): expected_share = float(expected_count) / expected_total built_count = int(built_counts.get(brma, 0)) + carried = int(built_sources.get(str(brma), 0)) row: dict[str, object] = { "region": str(region), "lha_category": str(category), @@ -68,7 +85,7 @@ def brma_cell_distribution( "cell_n": cell_n, "expected_share": expected_share, } - if 0 < built_count < minimum_count: + if 0 < carried < minimum_count: row["built_count"] = f"<{minimum_count}" row["built_share"] = None row["z"] = None @@ -114,6 +131,9 @@ def main() -> None: benunit["region"] = _benunit_regions( frame.table("person"), frame.table("household"), benunit ) + benunit[SOURCE_COLUMN] = record_source_households( + frame, "benunit", stage="The BRMA distribution diagnostics" + ) count_resource = load_brma_count_resource() # Deterministic re-derivation of the benunit-level assignment that fed the # stored household collapse (proven identical by the identity receipt). diff --git a/tools/measure_uk_weighted_integrity_baselines.py b/tools/measure_uk_weighted_integrity_baselines.py index e883b4fdd4..961c47be9c 100644 --- a/tools/measure_uk_weighted_integrity_baselines.py +++ b/tools/measure_uk_weighted_integrity_baselines.py @@ -49,7 +49,11 @@ uk_hmrc_weighted_qrf_output_columns, ) from microcosm.build.uk_runtime.national_frame import load_uk_national_frame -from microcosm.build.uk_runtime.receipt_counts import UK_DISCLOSURE_FLOOR +from microcosm.build.uk_runtime.receipt_counts import ( + UK_DISCLOSURE_FLOOR, + distinct_carriers, + record_source_households, +) from microcosm.build.uk_runtime.was_wealth import UK_WAS_WEALTH_HOUSEHOLD_OUTPUT_COLUMNS from microcosm.build.uk_runtime.weighted_integrity import ( uk_input_mass_totals, @@ -133,6 +137,7 @@ def _tail_measurements( weights: np.ndarray, top_k_grid: tuple[int, ...], *, + sources: np.ndarray, minimum_count: int = DEFAULT_SDC_MINIMUM_COUNT, ) -> dict[str, object]: """Concentration statistics under the UKDS output-disclosure standard. @@ -149,13 +154,17 @@ def _tail_measurements( share times the total recovers the mean of a handful of records. So a column with fewer than `minimum_count` carriers reports no shares at all, and `top_k` values below `minimum_count` are refused. No maximum, - minimum, or other unit-record value is ever emitted. + minimum, or other unit-record value is ever emitted. Carriers are the + true source households behind the column's carrier rows (`sources`, one + per value), so a household's copies count once (microcosm#931). """ finite = np.isfinite(values) & np.isfinite(weights) mass = np.abs(values[finite]) * weights[finite] - mass = mass[mass > 0.0] - carriers = int(mass.size) + carried = mass > 0.0 + mass = mass[carried] + carriers = distinct_carriers(np.asarray(sources)[finite][carried]) + carrier_rows = int(mass.size) total = float(mass.sum()) records = int(values.size) suppressed = carriers > 0 and carriers < minimum_count @@ -164,7 +173,7 @@ def _tail_measurements( for top_k in top_k_grid: if carriers == 0 or total == 0.0: top_shares[str(top_k)] = None - elif carriers <= top_k: + elif carrier_rows <= top_k: # Every carrier is in the tail: the share is 1.0 by # construction and says nothing about individual records. top_shares[str(top_k)] = 1.0 @@ -177,7 +186,7 @@ def _tail_measurements( # frequency, so it is withheld rather than reported. "carriers": None if suppressed else carriers, "nonzero_share": ( - None if suppressed else ((carriers / records) if records else 0.0) + None if suppressed else ((carrier_rows / records) if records else 0.0) ), "total_weighted_abs_mass": total, "top_shares": top_shares, @@ -198,21 +207,30 @@ def _measure( frame, output_columns=declared, ) + person_sources = record_source_households( + frame, "person", stage="The weighted-integrity baselines" + ) qrf_tail = { column: _tail_measurements( values[column], weights[column], top_k_grid, + # An absent or non-numeric column measures no rows. + sources=person_sources if len(values[column]) else values[column], minimum_count=minimum_count, ) for column in sorted(values) } household_values, household_weights = household_tail_concentration_columns(frame) + household_sources = record_source_households( + frame, "household", stage="The weighted-integrity baselines" + ) household_tail = { column: _tail_measurements( household_values[column], household_weights[column], top_k_grid, + sources=household_sources, minimum_count=minimum_count, ) for column in sorted(household_values) From 78e7f24ee3957177b6f4d489330d0e21fe22ffb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Thu, 5 Nov 2026 01:41:10 +0000 Subject: [PATCH 02/20] Fold geographic clones into each survey record in the FRS-trained fits (#931) The fits that train on the frame's FRS rows now fold a record's geographic clones into its first training row, with their weights summed exactly, before they fit: the SPI stage-2 and reference forests, the housing shell, the UC reporter redraw, the UC capital donor cells and the salary-sacrifice forest. SPI, high-value and CGT copies stay rows of their own. Today's spine has no geographic clones, so every fit's rows and weights are unchanged. The machinery is country-neutral. microcosm.build.source_lineage gains copy_paths, which reads every household's ordered copy path from a declared lineage, and replica_keys and collapse_replicas, which keep one row per record and path without the named branches. household_lineage.collapse_geographic_clones is the UK's entry, and uk_household_clone_paths now reads through copy_paths on UK_COPY_LINEAGE with identical paths. The housing shell and UC capital stages declare the lineage live where they run, and a test refuses a collapsing stage whose surface would hide one. Replicated-fixture tests hold each fit to the rows and weights it fits without clones, and fail without the fold. The SPI income stage binds spi_rank_transport into its hash. uk_spine.json is regenerated. Co-Authored-By: Claude Opus 5.5 --- ...31-uk-fits-fold-geographic-clones.added.md | 1 + docs/uk-atomic-household-lineage.md | 8 + .../src/microcosm/build/source_lineage.py | 214 +++++++++++++++++- .../src/microcosm/build/uk_runtime/graph.py | 13 +- .../build/uk_runtime/graph_kernels.py | 19 +- .../build/uk_runtime/household_lineage.py | 193 ++++++---------- .../build/uk_runtime/salary_sacrifice.py | 14 +- .../build/uk_runtime/spi_housing_shell.py | 20 +- .../microcosm/build/uk_runtime/spi_income.py | 18 +- .../build/uk_runtime/uc_capital_coherence.py | 17 +- .../build/uk_runtime/uc_reporter_redraw.py | 16 +- .../engine_free/shared/test_source_lineage.py | 126 ++++++++++- .../uk/test_uk_atomic_identity_graph.py | 6 +- .../engine_free/uk/test_uk_company_cars.py | 1 + .../uk/test_uk_geographic_clone_collapse.py | 143 ++++++++++++ .../uk/test_uk_salary_sacrifice.py | 30 +++ .../uk/test_uk_spi_housing_shell.py | 46 +++- .../engine_free/uk/test_uk_spi_income.py | 85 +++++++ .../uk/test_uk_uc_capital_coherence.py | 22 ++ .../uk/test_uk_uc_reporter_redraw.py | 21 ++ .../microcosm_build/uk_geographic_clones.py | 32 +++ .../microcosm_build/uk_spi_housing_shell.py | 4 + .../uk_uc_capital_coherence.py | 15 +- .../microcosm_build/uk_uc_reporter_redraw.py | 2 + 24 files changed, 907 insertions(+), 159 deletions(-) create mode 100644 changelog.d/931-uk-fits-fold-geographic-clones.added.md create mode 100644 packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py create mode 100644 test_support/microcosm_build/uk_geographic_clones.py diff --git a/changelog.d/931-uk-fits-fold-geographic-clones.added.md b/changelog.d/931-uk-fits-fold-geographic-clones.added.md new file mode 100644 index 0000000000..b58f0b7757 --- /dev/null +++ b/changelog.d/931-uk-fits-fold-geographic-clones.added.md @@ -0,0 +1 @@ +The UK fits trained on the frame's FRS rows now fold geographic clones into each survey record before they fit (#931): the SPI stage-2 and reference forests, the housing shell, the UC reporter redraw, the UC capital donor cells and the salary-sacrifice forest. A record keeps its first row among the training rows, with the weight of all its geographic clones summed exactly; SPI, high-value and CGT copies stay rows of their own, as now. Today's spine has no geographic clones, so every fit's rows and weights stay as they were, value for value; once the spine clones before enrichment, the fits see each record once, the reference transport no longer meets duplicate twins, and the UC capital cells' donor minimum counts records, not clones. The machinery is country-neutral: `microcosm.build.source_lineage` gains `copy_paths` (every household's ordered copy path from a declared lineage, never inferred from ids, weights or values), `replica_keys` (a key per record of any entity that only its replicas in the named branches share, a member's rank in its household telling members apart) and `collapse_replicas`; `household_lineage.collapse_geographic_clones` is the UK's entry, and `uk_household_clone_paths` now reads the clone path through `copy_paths` on `UK_COPY_LINEAGE`, with identical paths and draw keys (three identity-test messages name the shared reader's branches). The housing shell and UC capital stages declare the lineage live where they run, a test refuses a collapsing stage whose surface would hide one, and replicated-fixture tests hold each fit to the rows and weights it fits without clones. The SPI income stage also binds `spi_rank_transport` into its hash. diff --git a/docs/uk-atomic-household-lineage.md b/docs/uk-atomic-household-lineage.md index 3938e9d168..aa69606dc5 100644 --- a/docs/uk-atomic-household-lineage.md +++ b/docs/uk-atomic-household-lineage.md @@ -23,6 +23,14 @@ The host can extract the household pairs from its verified shared EXPAND receipt The full-build graph now adopts this key: `uk.full.identity` (`UKGeographyIdentityKernel`) reads the spine's explicit lineage columns and the pool clone index and writes `geography_household_key` with exactly this encoding, and `test_uk_atomic_identity_graph.py` holds the kernel to this projector on the executor's actual EXPAND receipt. The existing source stage order still interleaves enrichment before later SPI/CGT cloning; moving atomic assignment before every enrichment stage remains a separate staged migration under the geography-first umbrella issue (PolicyEngine/microcosm#931). This helper does not claim that migration, native FRS qualification or a new UK release. +## Shared lineage readers + +The UK's copy lineage is declared once, as data, in `uk_runtime.household_lineage.UK_COPY_LINEAGE`: every copy's true source is `source_household_id`, and each copying step (the SPI support channel, the CGT support split, high-value support, the CGT incidence clone, the CGT residential split and the geographic clone) names its marker and ordinal columns in path order. The country-neutral readers in `microcosm.build.source_lineage` take that declaration as a parameter, so another country can declare its own lineage and reuse them (microcosm#931): + +- `record_sources` gives every record of any entity its true source through household membership. Every UK floor counts distinct sources through it (`receipt_counts.record_source_households`), so a household's copies and clones count once. +- `copy_paths` reads every household's ordered clone path; `uk_household_clone_paths` is the UK's strict entry for the identity kernel. +- `replica_keys` and `collapse_replicas` keep one training row per true source and path without the geographic branch, with the clones' weights summed. The FRS-trained fits (the SPI stage-2 and reference forests, the housing shell, the UC reporter redraw, the UC capital donor cells and the salary-sacrifice forest) fold their training rows through `household_lineage.collapse_geographic_clones`, so once geographic clones precede enrichment each fit still sees each survey record once. A frame without geographic clones keeps its rows and weights value for value. + ## Verification scope Invented tests cover the full four-branch path, explicit selection, exact large IDs, source and ordinal changes, stable keys under row reordering and pool growth, unknown/colliding ancestry refusal and detached output. A real shared CREATE/EXPAND/FILTER graph supplies the household lineage receipt and replays from cache. Its projected keys then feed the existing seven-node atomic graph, including three system imports, assignment, derivation and its gate. That graph also completes required replay and preserves the supplied entity tables, weights, strata and metadata. No native source, private archive, country engine or external resource is used. diff --git a/packages/microcosm-build/src/microcosm/build/source_lineage.py b/packages/microcosm-build/src/microcosm/build/source_lineage.py index 9baba045ab..732183bdde 100644 --- a/packages/microcosm-build/src/microcosm/build/source_lineage.py +++ b/packages/microcosm-build/src/microcosm/build/source_lineage.py @@ -9,19 +9,27 @@ declares its copy lineage once (:class:`CopyLineage`) and passes it in; this module names no country's columns. -:func:`record_sources` gives every record of any entity its true source, -through household membership: the key a disclosure floor counts distinct -sources by, so that a household's copies and clones count once -(microcosm#931). A frame without the source column is refused, since its -copies would count as sources of their own, unless the caller runs before the -first copying step and says so (``before_copies``): each household is then its -own source, and its id serves, as long as the frame carries no declared copy -column either. +- :func:`record_sources` gives every record of any entity its true source, + through household membership: the key a disclosure floor counts distinct + sources by, so that a household's copies and clones count once + (microcosm#931). A frame without the source column is refused, since its + copies would count as sources of their own, unless the caller runs before + the first copying step and says so (``before_copies``): each household is + then its own source, and its id serves, as long as the frame carries no + declared copy column either. +- :func:`copy_paths` gives every household its ordered copy path, read from + the declared columns, never inferred from ids, weights or values. +- :func:`replica_keys` and :func:`collapse_replicas` keep one training row per + true source and path without the named branches, with the rows' weights + summed, so a fit trained on the frame sees each survey record once however + many geographic clones carry it. A frame without such replicas keeps its + rows and weights value for value. """ from __future__ import annotations -from collections.abc import Mapping +import math +from collections.abc import Iterable, Mapping from dataclasses import dataclass import numpy as np @@ -33,7 +41,10 @@ __all__ = [ "CopyBranch", "CopyLineage", + "collapse_replicas", + "copy_paths", "record_sources", + "replica_keys", ] @@ -167,3 +178,188 @@ def record_sources( if not unit_ids.isin(unit_households.index).all(): raise ValueError(f"A {entity} without members has no source.") return unit_ids.map(unit_households).map(by_household).to_numpy() + + +def copy_paths( + household: pd.DataFrame, + lineage: CopyLineage, + *, + require: Iterable[str] = (), +) -> tuple[np.ndarray, list[tuple[tuple[str, int], ...]]]: + """Every household's true source and ordered copy path, in row order. + + A path lists, in branch order, ``(branch, ordinal)`` for each step the + household is a copy in. A step whose columns are all absent has not run + and adds nothing; a step with only some of its columns, or a step named in + ``require`` that is absent, is refused. So are a null, negative or + non-integer ordinal, a marker value the step does not declare, and a + marker that disagrees with its ordinal: the path is read from the declared + columns, never inferred from ids, weights or values. + """ + + required = set(require) + unknown = required - {branch.name for branch in lineage.branches} + if unknown: + raise ValueError(f"No copy branch is named {sorted(unknown)}.") + if lineage.source not in household.columns: + raise ValueError(f"Copy paths need {lineage.entity}.{lineage.source}.") + sources = household[lineage.source] + if sources.isna().any(): + raise ValueError(f"{lineage.entity}.{lineage.source} is null on some rows.") + steps: list[tuple[str, np.ndarray]] = [] + for branch in lineage.branches: + present = [c for c in branch.columns if c in household.columns] + if not present: + if branch.name in required: + raise ValueError( + f"The {lineage.entity} table lacks the {branch.name!r} " + f"step's column(s) {list(branch.columns)}." + ) + continue + if len(present) != len(branch.columns): + raise ValueError( + f"The {branch.name!r} step needs both {list(branch.columns)}; " + f"the {lineage.entity} table carries only {present}." + ) + steps.append((branch.name, _branch_ordinals(household, branch))) + paths = [ + tuple((name, int(ordinals[row])) for name, ordinals in steps if ordinals[row]) + for row in range(len(household)) + ] + return sources.to_numpy(), paths + + +def _branch_ordinals(household: pd.DataFrame, branch: CopyBranch) -> np.ndarray: + ordinals = None + if branch.index is not None: + values = household[branch.index] + if values.isna().any() or not pd.api.types.is_integer_dtype(values.dtype): + raise ValueError(f"The {branch.name!r} ordinals must be integers.") + ordinals = values.to_numpy(dtype=np.int64) + if (ordinals < 0).any(): + raise ValueError(f"The {branch.name!r} step refuses negative ordinals.") + if branch.marker is None: + return ordinals + marker = household[branch.marker] + if marker.isna().any(): + raise ValueError(f"The {branch.name!r} marker is null on some rows.") + if isinstance(branch.copy, bool) and not pd.api.types.is_bool_dtype(marker.dtype): + raise ValueError(f"The {branch.name!r} marker must be boolean.") + is_copy = marker.eq(branch.copy).to_numpy(dtype=bool) + if not (is_copy | marker.eq(branch.original).to_numpy(dtype=bool)).all(): + raise ValueError( + f"The {branch.name!r} marker holds a value other than " + f"{branch.copy!r} and {branch.original!r}." + ) + if ordinals is None: + return is_copy.astype(np.int64) + if not np.array_equal(is_copy, ordinals != 0): + raise ValueError(f"The {branch.name!r} marker and ordinal disagree.") + return ordinals + + +def replica_keys( + tables: Mapping[str, pd.DataFrame], + schema: EntitySchema, + entity: str, + lineage: CopyLineage, + *, + merge: Iterable[str], +) -> np.ndarray: + """A key per ``entity`` record that only its replicas in ``merge`` share. + + A household's key is its true source and its copy path without the + ``merge`` branches; a person's or unit's adds its rank among its + household's members or units by id, which every copy keeps, since a copy + remaps ids in order. Two records share a key exactly when one is the + other's replica in the ``merge`` branches alone. + """ + + merged = set(merge) + unknown = merged - {branch.name for branch in lineage.branches} + if unknown: + raise ValueError(f"No copy branch is named {sorted(unknown)}.") + household = tables[lineage.entity] + sources, paths = copy_paths(household, lineage) + household_keys = pd.Series( + [ + repr((source, tuple(step for step in path if step[0] not in merged))) + for source, path in zip(sources.tolist(), paths, strict=True) + ], + index=household[schema.id_column(lineage.entity)].to_numpy(), + dtype=object, + ) + if entity == lineage.entity: + return household_keys.to_numpy() + person = tables[schema.person_entity] + members = person[schema.membership_column(lineage.entity)] + if not members.isin(household_keys.index).all(): + raise ValueError( + f"Every {schema.person_entity} needs a {lineage.entity} on the frame." + ) + if entity == schema.person_entity: + ids = person[schema.person_id_column] + owners = members + else: + units = pd.DataFrame( + { + "unit": person[schema.membership_column(entity)].to_numpy(), + "household": members.to_numpy(), + } + ).drop_duplicates() + if units["unit"].duplicated().any(): + raise ValueError( + f"A {entity} with members in several {lineage.entity}s has no key." + ) + by_unit = pd.Series(units["household"].to_numpy(), index=units["unit"]) + ids = tables[entity][schema.id_column(entity)] + if not ids.isin(by_unit.index).all(): + raise ValueError(f"A {entity} without members has no key.") + owners = ids.map(by_unit) + rank = ( + pd.Series(ids.to_numpy()) + .groupby(owners.to_numpy(), sort=False) + .rank(method="first") + .astype(np.int64) + ) + keys = owners.map(household_keys).to_numpy(dtype=object) + return np.asarray( + [f"{key}#{position}" for key, position in zip(keys, rank, strict=True)], + dtype=object, + ) + + +def collapse_replicas( + keys: np.ndarray, rows: np.ndarray, weights: np.ndarray +) -> tuple[np.ndarray, np.ndarray]: + """Keep the first of each key's ``rows``, carrying the key's summed weight. + + ``rows`` marks the records a fit trains on and ``weights`` their weights, + both over every record. The first selected record of each key, in row + order, stays selected with the selected weights of its key summed + exactly (:func:`math.fsum`, so the sum does not depend on row order); its + replicas leave the selection. Weights off the selection are returned + unchanged. When no two selected records share a key, the selection and + weights are returned as they were, value for value. + """ + + keys = np.asarray(keys, dtype=object) + selected = np.asarray(rows, dtype=bool) + values = np.asarray(weights, dtype=np.float64) + if not (len(keys) == len(selected) == len(values)): + raise ValueError("Replica keys, rows and weights must align.") + positions = np.flatnonzero(selected) + codes, uniques = pd.factorize(pd.Series(keys[positions], dtype=object), sort=False) + if len(uniques) == len(positions): + return selected, values + first = np.full(len(uniques), -1, dtype=np.int64) + members: list[list[float]] = [[] for _ in range(len(uniques))] + for position, code in zip(positions.tolist(), codes.tolist(), strict=True): + if first[code] < 0: + first[code] = position + members[code].append(float(values[position])) + kept = np.zeros(len(selected), dtype=bool) + kept[first] = True + summed = values.copy() + summed[first] = [math.fsum(group) for group in members] + return kept, summed diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py index 1305bf730b..b953816fa5 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py @@ -439,9 +439,13 @@ } ), # Engine-free: the housing predictors and the channel split. The rewritten - # housing and benefit cells arrive as the rewrite's incumbents. + # housing and benefit cells arrive as the rewrite's incumbents. The + # lineage live here lets the model fold geographic clones into each survey + # household (microcosm#931). "spi_housing_shell": frozenset( { + ("household", "source_household_id"), + ("household", "household_support_clone_index"), ("person", "age"), ("person", "is_household_head"), ("person", "employment_income"), @@ -535,6 +539,13 @@ ), "uc_capital_coherence": frozenset( { + # The lineage live here lets the donor pool fold geographic clones + # into each survey benefit unit (microcosm#931). + ("household", "source_household_id"), + ("household", "household_support_channel"), + ("household", "household_support_clone_index"), + ("household", "household_is_high_value_support_copy"), + ("household", "high_value_support_copy_index"), ("person", "is_benunit_head"), ("person", "is_parent"), ("person", "person_support_channel"), diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py index 578f17b1a4..143426861e 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py @@ -70,6 +70,7 @@ receipt_counts, rowwise_geography, spi_income, + spi_rank_transport, spi_support, uc_capital_coherence, uc_deduction_attributes, @@ -166,8 +167,9 @@ # (microcosm#1164). "frs_annual_income_spells": (receipt_counts,), # The SPI income stage's imputation, band-donor resample and receipt live - # in spi_income, so an edit there moves the stage's hash (microcosm#1278). - "hmrc_spi_income_spine": (spi_income,), + # in spi_income, so an edit there moves the stage's hash (microcosm#1278), + # and its twin transport in spi_rank_transport (microcosm#840). + "hmrc_spi_income_spine": (spi_income, spi_rank_transport), "frs_spine": (uc_relationships,), "frs_legacy_proxies": (uk_engine_adapter,), "frs_education_grant_split": (uk_engine_adapter,), @@ -304,11 +306,12 @@ ), } -# The receipts' counting rules and the shared lineage they read: every floor -# counts true source households through receipt_counts, which reads them -# through source_lineage on household_lineage's declaration (microcosm#931). -# An edit to any of the three moves the hash of every stage whose module or -# helpers import one of them; test_uk_graph derives this set from the imports. +# The receipts' counting rules and the shared lineage readers: every floor +# counts true source households through receipt_counts, and the FRS-trained +# fits fold geographic clones through household_lineage, both reading +# source_lineage on household_lineage's declaration (microcosm#931). An edit +# to any of the three moves the hash of every stage whose module or helpers +# import one of them; test_uk_graph derives this set from the imports. _COUNTING_MODULES = (receipt_counts, household_lineage, source_lineage) _COUNTING_STAGES = frozenset( { @@ -318,6 +321,7 @@ "frs_annual_income_spells", "hmrc_spi_income_spine", "company_cars", + "spi_housing_shell", "high_value_home_support", "regional_home_values", "property_components", @@ -325,6 +329,7 @@ "nts_bus_travel", "lcfs_consumption", "etb_vat", + "uc_reporter_redraw", "spi_benefit_coherence", "uc_capital_coherence", "uc_take_up", diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py index 46d6afb24e..c1fead681a 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py @@ -5,17 +5,27 @@ (microcosm#1240) needs the same path without the geographic clone branch, so that every pool clone of one spine household shares one key. Both read the path through this module, which validates the lineage columns once and never -infers a branch from ids, weights or values. +infers a branch from ids, weights or values. The UK's copy lineage is declared +here (:data:`UK_COPY_LINEAGE`) for the shared readers in +``microcosm.build.source_lineage``: the receipts' true sources and the +FRS-trained fits' collapse of geographic clones read it too. """ from __future__ import annotations -from collections.abc import Sequence +from collections.abc import Mapping, Sequence import numpy as np import pandas as pd -from microcosm.build.source_lineage import CopyBranch, CopyLineage +from microcosm.build.source_lineage import ( + CopyBranch, + CopyLineage, + collapse_replicas, + copy_paths, + replica_keys, +) +from microcosm.build.uk_runtime.national_frame import UK_NATIONAL_SCHEMA from microcosm.build.uk_runtime.rowwise_dataset import ladder_clone_index_column __all__ = [ @@ -24,6 +34,7 @@ "HIGH_VALUE_SUPPORT_INDEX_COLUMN", "UK_COPY_LINEAGE", "UK_HOUSEHOLD_LINEAGE_COLUMNS", + "collapse_geographic_clones", "uk_household_clone_paths", ] @@ -91,10 +102,22 @@ ) -def _require_bool(series: pd.Series, column: str) -> None: - dtype = series.dtype - if dtype != np.dtype("bool") and not isinstance(dtype, pd.BooleanDtype): - raise ValueError(f"Geography identity requires a boolean {column}.") +#: The branches every post-clone household carries: the SPI support channel +#: and the CGT steps. High-value support (a spine built before that stage has +#: neither of its columns) and the geographic clone index (a spine frame has +#: none yet) are read where present. +_REQUIRED_BRANCHES = ( + "spi_support_channel", + "cgt_support_split", + "cgt_incidence_clone", + "cgt_residential_split", +) +_INT64_LINEAGE_COLUMNS = ( + "source_household_id", + "cgt_support_copy_index", + "cgt_residential_clone_index", + HIGH_VALUE_SUPPORT_INDEX_COLUMN, +) def uk_household_clone_paths( @@ -108,129 +131,55 @@ def uk_household_clone_paths( with the copy index when it is a high-value home support copy, ``cgt_incidence_clone`` (ordinal 1) from its flag, ``cgt_residential_split`` with the arm index, and ``geographic_support`` with the pool clone index - when it is not the original copy. Malformed lineage fails by name. + when it is not the original copy. The shared reader + (``microcosm.build.source_lineage.copy_paths``) reads it on + :data:`UK_COPY_LINEAGE`; malformed lineage fails by name. """ clone_column = ladder_clone_index_column("household") required = [c for c in UK_HOUSEHOLD_LINEAGE_COLUMNS if c != clone_column] missing = [c for c in required if c not in household] if missing: raise ValueError(f"Geography identity lacks lineage column(s) {missing}.") - # A spine frame carries no pool clone index yet: every row is clone 0. - columns: list[str] = list(required) + ( - [clone_column] if clone_column in household else [] - ) - has_high_value = all(c in household for c in UK_OPTIONAL_LINEAGE_COLUMNS) - if any(c in household for c in UK_OPTIONAL_LINEAGE_COLUMNS) and not has_high_value: - raise ValueError( - "Geography identity needs both high-value support lineage columns or neither." - ) - if has_high_value: - columns.extend(UK_OPTIONAL_LINEAGE_COLUMNS) - lineage = household.loc[:, columns] - if lineage.isna().any().any(): + present = [ + column + for column in (UK_COPY_LINEAGE.source, *UK_COPY_LINEAGE.copy_columns) + if column in household + ] + if household.loc[:, present].isna().any().any(): raise ValueError("Geography identity refuses null lineage values.") - if lineage["source_household_id"].dtype != np.dtype("int64"): - raise ValueError("Geography identity requires int64 source household ids.") - if lineage["cgt_support_copy_index"].dtype != np.dtype("int64"): - raise ValueError("Geography identity requires an int64 support copy index.") - if lineage["cgt_residential_clone_index"].dtype != np.dtype("int64"): - raise ValueError("Geography identity requires an int64 residential arm index.") - if has_high_value and lineage[HIGH_VALUE_SUPPORT_INDEX_COLUMN].dtype != np.dtype( - "int64" - ): - raise ValueError( - "Geography identity requires an int64 high-value support copy index." - ) - for column in ( - "household_is_cgt_support_copy", - "household_is_capital_gains_clone", - "household_is_cgt_residential_clone", - *((HIGH_VALUE_SUPPORT_COPY_COLUMN,) if has_high_value else ()), - ): - _require_bool(lineage[column], column) - high_value_copy = ( - lineage[HIGH_VALUE_SUPPORT_COPY_COLUMN].to_numpy() - if has_high_value - else np.zeros(len(lineage), dtype=bool) - ) - high_value_index = ( - lineage[HIGH_VALUE_SUPPORT_INDEX_COLUMN].to_numpy() - if has_high_value - else np.zeros(len(lineage), dtype=np.int64) + for column in _INT64_LINEAGE_COLUMNS: + if column in household and household[column].dtype != np.dtype("int64"): + raise ValueError(f"Geography identity requires an int64 {column}.") + sources, paths = copy_paths(household, UK_COPY_LINEAGE, require=_REQUIRED_BRANCHES) + return [int(source) for source in sources], paths + + +def collapse_geographic_clones( + tables: Mapping[str, pd.DataFrame], + entity: str, + rows: np.ndarray, + weights: np.ndarray, +) -> tuple[np.ndarray, np.ndarray]: + """A fit's training rows with each record's geographic clones folded in. + + A survey record a fit trains on keeps one row, its first among ``rows``, + with the weight of all its geographic clones; every other copy (SPI + support, high-value support and the CGT steps) stays a row of its own + (microcosm#931). The record's key is its true source and its clone path + without the geographic branch, through the shared reader + (``microcosm.build.source_lineage``); a frame without geographic clones, + as every spine is today, keeps ``rows`` and ``weights`` value for value. + Returns the kept rows and the weights over every row of ``entity``. + """ + + keys = replica_keys( + tables, + UK_NATIONAL_SCHEMA, + entity, + UK_COPY_LINEAGE, + merge=(GEOGRAPHIC_SUPPORT_BRANCH,), ) - source_ids: list[int] = [] - paths: list[tuple[tuple[str, int], ...]] = [] - for ( - source_id, - channel, - support_index, - support_copy, - copy_index, - cgt, - residential_arm, - residential_index, - clone_index, - hv_copy, - hv_index, - ) in zip( - lineage["source_household_id"].to_numpy(), - lineage["household_support_channel"].to_numpy(), - lineage["household_support_clone_index"].to_numpy(), - lineage["household_is_cgt_support_copy"].to_numpy(), - lineage["cgt_support_copy_index"].to_numpy(), - lineage["household_is_capital_gains_clone"].to_numpy(), - lineage["household_is_cgt_residential_clone"].to_numpy(), - lineage["cgt_residential_clone_index"].to_numpy(), - ( - lineage[clone_column].to_numpy() - if clone_column in lineage - else np.zeros(len(lineage), dtype=np.int64) - ), - high_value_copy, - high_value_index, - strict=True, - ): - channel = str(channel) - support_index, clone_index = int(support_index), int(clone_index) - copy_index = int(copy_index) - residential_index = int(residential_index) - hv_index = int(hv_index) - if residential_index < 0 or hv_index < 0: - raise ValueError("Geography identity refuses negative clone indices.") - if bool(residential_arm) != (residential_index != 0): - raise ValueError("Household residential-arm flag and arm index disagree.") - if channel not in {_BASE_SUPPORT_CHANNEL, _SPI_SUPPORT_CHANNEL}: - raise ValueError(f"Unknown household support channel {channel!r}.") - if support_index < 0 or clone_index < 0 or copy_index < 0: - raise ValueError("Geography identity refuses negative clone indices.") - if (channel == _SPI_SUPPORT_CHANNEL) != (support_index != 0): - raise ValueError( - "Household support channel and support clone index disagree." - ) - if bool(support_copy) != (copy_index != 0): - raise ValueError( - "Household support-copy flag and support copy index disagree." - ) - if bool(hv_copy) != (hv_index != 0): - raise ValueError( - "Household high-value support-copy flag and copy index disagree." - ) - path: list[tuple[str, int]] = [] - if support_index: - path.append(("spi_support_channel", support_index)) - if copy_index: - path.append(("cgt_support_split", copy_index)) - if hv_index: - path.append(("high_value_support", hv_index)) - if bool(cgt): - path.append(("cgt_incidence_clone", 1)) - if residential_index: - path.append(("cgt_residential_split", residential_index)) - if clone_index: - path.append((GEOGRAPHIC_SUPPORT_BRANCH, clone_index)) - source_ids.append(int(source_id)) - paths.append(tuple(path)) - return source_ids, paths + return collapse_replicas(keys, rows, weights) def without_geographic_branch( diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py index 588115034f..fd4c9c39ef 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py @@ -30,6 +30,7 @@ _assert_closed_world_operations, ) from microcosm.build.uk_runtime.cgt_support import HOUSEHOLD_IS_CGT_SUPPORT_COPY +from microcosm.build.uk_runtime.household_lineage import collapse_geographic_clones from microcosm.build.uk_runtime.national_frame import ( uk_household_weight_kind, uk_national_frame, @@ -612,8 +613,19 @@ def impute_salary_sacrifice( index=household["household_id"], ) person_weights = person_households.map(household_weights).to_numpy(dtype=float) + # The forest trains on each asked respondent once: their geographic + # clones fold into their first row with their weight, and every other copy + # stays its own row; a frame without geographic clones keeps every row and + # weight (household_lineage.collapse_geographic_clones, microcosm#931). + kept, fit_weights = collapse_geographic_clones( + {"person": person, "household": household}, + "person", + training_mask.to_numpy(dtype=bool), + person_weights, + ) + training_mask = pd.Series(kept, index=training_mask.index) training = numeric.loc[training_mask, [*SALSAC_PREDICTORS, SALSAC_OUTPUT]].copy() - training["_fit_weight"] = person_weights[training_mask.to_numpy()] + training["_fit_weight"] = fit_weights[kept] model = _qrf_class()( n_estimators=SALSAC_QRF_ESTIMATORS, seed=SALSAC_QRF_SEED, diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_housing_shell.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_housing_shell.py index 86aafa74f0..73918be60a 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_housing_shell.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_housing_shell.py @@ -38,6 +38,7 @@ UK_COUNCIL_TAX_BANDS_BY_REGION, UK_NATION_BY_REGION, ) +from microcosm.build.uk_runtime.household_lineage import collapse_geographic_clones from microcosm.build.uk_runtime.qrf_gates import ( UK_DEFAULT_GATE_CALIBRATION, UK_GATE_OUTCOMES_EVIDENCE, @@ -539,9 +540,18 @@ def impute_spi_housing_shell( weights = pd.Series( np.asarray(household_weights, dtype=float), index=household["household_id"] ) - training_ids = household.loc[ - (channel == FRS_CHANNEL) & (weights.to_numpy() > 0.0), "household_id" - ] + # The model trains on each survey household once: its geographic clones + # fold into its first row with their weight, and every other copy stays + # its own row; a frame without geographic clones keeps every row and + # weight (household_lineage.collapse_geographic_clones, microcosm#931). + training, fit_weights = collapse_geographic_clones( + {"household": household}, + "household", + (channel == FRS_CHANNEL) & (weights.to_numpy() > 0.0), + weights.to_numpy(), + ) + fit_weights = pd.Series(fit_weights, index=household["household_id"]) + training_ids = household.loc[training, "household_id"] recipient_ids = household.loc[channel == SPI_CHANNEL, "household_id"] if training_ids.empty or recipient_ids.empty: raise ValueError("Housing shell needs FRS training rows and SPI recipients.") @@ -551,7 +561,7 @@ def impute_spi_housing_shell( model = fit_housing_model( predictors.loc[training_ids], targets.loc[training_ids], - weights.loc[training_ids].to_numpy(), + fit_weights.loc[training_ids].to_numpy(), seed=seed, n_estimators=n_estimators, gate_calibration=gate_calibration, @@ -597,7 +607,7 @@ def impute_spi_housing_shell( "category_shares": { column: { "training": _weighted_shares( - targets.loc[training_ids, column], weights.loc[training_ids] + targets.loc[training_ids, column], fit_weights.loc[training_ids] ), "recipients": _weighted_shares( draws[column], weights.loc[recipient_ids] diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py index 22071d2462..710023dafe 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py @@ -48,6 +48,7 @@ LOSS_RELIEF_COLUMN, self_employment_income_after_loss_relief, ) +from microcosm.build.uk_runtime.household_lineage import collapse_geographic_clones from microcosm.build.uk_runtime.pension_coherence import ( cap_net_pay_contributions, coherence_receipt, @@ -1520,6 +1521,18 @@ def impute_uk_spi_income_support( ) if not training_people.any(): raise ValueError("FRS-only stage has no canonical base training rows.") + # Both forests train on each survey record once: its geographic clones + # fold into its first row with their weight, and every other copy stays + # its own row; a frame without geographic clones keeps every row and + # weight (household_lineage.collapse_geographic_clones, microcosm#931). + kept, training_weight_values = collapse_geographic_clones( + {"person": person, "household": household}, + "person", + training_people.to_numpy(dtype=bool), + person_weights.to_numpy(dtype=np.float64), + ) + training_people = pd.Series(kept, index=person.index) + training_weights = pd.Series(training_weight_values, index=person.index) # The reference forest's population mirrors the draw's: FRS claimants and # partners aged 16 and over with taxable income under the same rule. reference_people = ( @@ -1587,7 +1600,7 @@ def impute_uk_spi_income_support( # from the stage seed like stage 2's and the band resample's; changing the # offset edits the derivation convention. assert_analogue_map_covers(SPI_INCOME_QRF_OUTPUT_COLUMNS) - reference_weights = person_weights.loc[reference_people] + reference_weights = training_weights.loc[reference_people] reference_targets = list(analogue_targets(SPI_INCOME_QRF_OUTPUT_COLUMNS)) reference_weight_kind: dict[str, str] = {} reference_fits: list[Any] = [] @@ -1830,11 +1843,10 @@ def fit_reference(encoded: pd.DataFrame, observed: pd.DataFrame): _require_finite_numeric(training_targets, label="FRS-only training outputs") if (training_targets.to_numpy(dtype=np.float64) < 0.0).any(): raise ValueError("FRS-only training outputs must be non-negative.") - person_weights = _person_household_weights(person, household) stage2_frame = _person_fit_frame( predictors=encoded_train, targets=training_targets, - weights=person_weights.loc[training_people].to_numpy(dtype=np.float64), + weights=training_weights.loc[training_people].to_numpy(dtype=np.float64), weight_kind=WeightKind.IMPORTANCE, ) # Stage 2 deliberately derives a distinct RNG stream from the single diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py index c4c13588b3..b1384d25fa 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py @@ -24,6 +24,7 @@ from microcosm.build.source_manifest import SourceStageSpec from microcosm.build.stochastic_assignment import stable_identity_uniforms from microcosm.build.uk_runtime.frs_spine import UC_CAPITAL_UNAVAILABLE +from microcosm.build.uk_runtime.household_lineage import collapse_geographic_clones from microcosm.build.uk_runtime.national_frame import ( uk_household_weight_kind, uk_national_frame, @@ -345,6 +346,7 @@ def cohere_uc_capital( levels = _redraw_spi_capital( benunit, person=person, + household=household, weights=weights, reporter=reporter, base=base, @@ -628,6 +630,7 @@ def _redraw_spi_capital( benunit: pd.DataFrame, *, person: pd.DataFrame, + household: pd.DataFrame, weights: np.ndarray, reporter: np.ndarray, base: np.ndarray, @@ -642,7 +645,10 @@ def _redraw_spi_capital( dependent-children band. A cell with fewer than ``minimum_cell_donors`` donors widens in the declared ``UC_CAPITAL_COARSENING`` order; reporter status is never coarsened, and an empty reporter-status pool refuses. - Returns the number of redrawn units drawn at each level. + Each survey benefit unit donates once, its geographic clones folded into + its first row with their weight, so a cell's donor count does not grow + with the clones (``household_lineage.collapse_geographic_clones``, + microcosm#931). Returns the number of redrawn units drawn at each level. """ if not isinstance(minimum_cell_donors, int) or minimum_cell_donors <= 0: @@ -652,7 +658,12 @@ def _redraw_spi_capital( income_band = _investment_income_band(investment) last_band = len(UC_CAPITAL_INCOME_BAND_EDGES) # Domain-validated upstream: every non-sentinel value is >= 0. - donor = base & (capital >= 0.0) & (weights > 0.0) + donor, donor_weight = collapse_geographic_clones( + {"person": person, "benunit": benunit, "household": household}, + "benunit", + base & (capital >= 0.0) & (weights > 0.0), + weights, + ) target_ids = benunit["benunit_id"].to_numpy() draws = stable_identity_uniforms( target_ids, @@ -720,7 +731,7 @@ def _redraw_spi_capital( { "benunit_id": target_ids[donor_cell], "capital": source_capital[donor_cell], - "weight": weights[donor_cell], + "weight": donor_weight[donor_cell], } ).sort_values(["capital", "benunit_id"], kind="mergesort") donor_values = donor_rows["capital"].to_numpy(dtype=float) diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_reporter_redraw.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_reporter_redraw.py index 88a8a5bc87..a337d42e57 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_reporter_redraw.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_reporter_redraw.py @@ -21,6 +21,7 @@ integer_record_keys, stable_identity_uniforms, ) +from microcosm.build.uk_runtime.household_lineage import collapse_geographic_clones from microcosm.build.uk_runtime.national_frame import ( uk_household_weight_kind, uk_national_frame, @@ -318,7 +319,18 @@ def redraw_spi_reported_uc( raise ValueError( "UC reporter redraw has no screened canonical FRS training rows." ) - if float(weights[training].sum()) <= 0.0: + # The forest trains on each screened benefit unit once: its geographic + # clones fold into its first row with their weight, and every other copy + # stays its own row; a frame without geographic clones keeps every row + # and weight (household_lineage.collapse_geographic_clones, microcosm#931). + # The screen is each row's own engine output, so the fold follows it. + training, fit_weights = collapse_geographic_clones( + {"person": person, "benunit": benunit, "household": household}, + "benunit", + training, + weights, + ) + if float(fit_weights[training].sum()) <= 0.0: raise ValueError("UC reporter redraw training weights must have positive mass.") if not target.any(): # An empty draw domain is not a valid outcome: the rewrite would zero @@ -351,7 +363,7 @@ def redraw_spi_reported_uc( encoded_train, model_predictors, [UC_REPORTER_TARGET], - weights=weights[training], + weights=fit_weights[training], groups=benunit_household[training], ) draws = np.zeros(len(benunit), dtype=np.float64) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py b/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py index 83e153aa08..b205bab630 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py @@ -6,7 +6,14 @@ import pandas as pd import pytest -from microcosm.build.source_lineage import CopyBranch, CopyLineage, record_sources +from microcosm.build.source_lineage import ( + CopyBranch, + CopyLineage, + collapse_replicas, + copy_paths, + record_sources, + replica_keys, +) from microcosm.frame import EntitySchema SCHEMA = EntitySchema(group_entities=("unit", "household")) @@ -139,3 +146,120 @@ def test_record_sources_returns_the_tables_row_order() -> None: record_sources(shuffled, SCHEMA, "household", LINEAGE), np.asarray([1, 1, 1, 2]), ) + + +def test_copy_paths_read_each_step_in_declared_order() -> None: + tables = _tables() + tables["household"]["is_clone"] = [False, False, True, False] + sources, paths = copy_paths(tables["household"], LINEAGE) + assert sources.tolist() == [1, 2, 1, 1] + assert paths == [(), (), (("support", 1), ("clone", 1)), (("place", 1),)] + + +def test_a_step_that_has_not_run_adds_nothing_unless_required() -> None: + household = _tables()["household"].drop(columns=["place_index"]) + _, paths = copy_paths(household, LINEAGE) + assert paths == [(), (), (("support", 1),), ()] + with pytest.raises(ValueError, match="lacks the 'place'"): + copy_paths(household, LINEAGE, require=("place",)) + with pytest.raises(ValueError, match="No copy branch"): + copy_paths(household, LINEAGE, require=("unknown",)) + + +@pytest.mark.parametrize( + "defect", + [ + "partial_step", + "disagreeing_marker", + "negative_ordinal", + "float_ordinal", + "unknown_marker", + "integer_flag", + "null_marker", + "no_source", + ], +) +def test_copy_paths_refuse_lineage_they_cannot_read(defect: str) -> None: + household = _tables()["household"] + if defect == "partial_step": + household = household.drop(columns=["support_index"]) + elif defect == "disagreeing_marker": + household.loc[0, "channel"] = "b" + elif defect == "negative_ordinal": + household.loc[3, "place_index"] = -1 + elif defect == "float_ordinal": + household["place_index"] = household["place_index"].astype(float) + elif defect == "unknown_marker": + household.loc[0, "channel"] = "c" + elif defect == "integer_flag": + household["is_clone"] = household["is_clone"].astype(int) + elif defect == "null_marker": + household["channel"] = pd.array(["a", None, "b", "a"], dtype="string") + else: + household = household.drop(columns=["source_household_id"]) + with pytest.raises(ValueError): + copy_paths(household, LINEAGE) + + +def _placed_tables() -> dict[str, pd.DataFrame]: + """The tables placed twice: clone 1 of every row at id + 1000.""" + + tables = _tables() + placed = {} + for entity, table in tables.items(): + clone = table.copy() + for column in clone.columns: + if column.endswith("_id") and column != "source_household_id": + clone[column] = clone[column] + 1000 + if entity == "household": + clone["place_index"] = clone["place_index"] + 1 + placed[entity] = pd.concat([table, clone], ignore_index=True) + return placed + + +def test_replica_keys_are_shared_by_placed_clones_alone() -> None: + tables = _placed_tables() + households = replica_keys(tables, SCHEMA, "household", LINEAGE, merge=("place",)) + # Households 1 and 4 are one record placed twice, and so are their + # clones; the support copy (3) stays apart from its source (1). + first = dict(zip(tables["household"]["household_id"], households, strict=True)) + assert first[1] == first[4] == first[1001] == first[1004] + assert len({first[1], first[2], first[3]}) == 3 + assert first[2] == first[1002] and first[3] == first[1003] + people = replica_keys(tables, SCHEMA, "person", LINEAGE, merge=("place",)) + by_person = dict(zip(tables["person"]["person_id"], people, strict=True)) + # Members keep their rank: a household's first member is the clone's. + assert by_person[10] == by_person[1010] == by_person[40] + assert by_person[11] == by_person[41] and by_person[10] != by_person[11] + units = replica_keys(tables, SCHEMA, "unit", LINEAGE, merge=("place",)) + by_unit = dict(zip(tables["unit"]["unit_id"], units, strict=True)) + assert by_unit[100] == by_unit[400] == by_unit[1100] + with pytest.raises(ValueError, match="No copy branch"): + replica_keys(tables, SCHEMA, "unit", LINEAGE, merge=("elsewhere",)) + + +def test_collapse_keeps_each_records_first_row_with_its_summed_weight() -> None: + keys = np.asarray(["a", "b", "a", "c", "b", "a"], dtype=object) + rows = np.asarray([True, True, True, False, True, True]) + weights = np.asarray([0.1, 0.2, 0.2, 9.0, 0.3, 0.7]) + kept, summed = collapse_replicas(keys, rows, weights) + assert kept.tolist() == [True, True, False, False, False, False] + # Exact sums, whatever the order: 0.1 + 0.2 + 0.7 rounds once. + assert summed[0] == 1.0 and summed[1] == 0.5 + assert summed[3] == 9.0 + order = np.asarray([5, 4, 3, 2, 1, 0]) + reversed_kept, reversed_summed = collapse_replicas( + keys[order], rows[order], weights[order] + ) + assert reversed_summed[reversed_kept].tolist() == [1.0, 0.5] + + +def test_a_selection_without_replicas_keeps_its_rows_and_weights() -> None: + keys = np.asarray(["a", "b", "a"], dtype=object) + rows = np.asarray([True, True, False]) + weights = np.asarray([0.1, 0.2, 0.3]) + kept, summed = collapse_replicas(keys, rows, weights) + assert kept.tolist() == rows.tolist() + assert summed.tobytes() == weights.tobytes() + with pytest.raises(ValueError, match="align"): + collapse_replicas(keys, rows[:2], weights) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_atomic_identity_graph.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_atomic_identity_graph.py index 568bd92451..5394a3c4ec 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_atomic_identity_graph.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_atomic_identity_graph.py @@ -314,12 +314,12 @@ def test_identity_refusals(tmp_path, defect): message = "negative" elif defect == "unknown_channel": rows[2] = (11, 1, "puf", 1, False, 0, "LONDON") - message = "support channel" + message = "spi_support_channel" elif defect == "duplicate_lineage": rows[2] = (11, 1, "frs", 0, False, 0, "LONDON") message = "not unique" elif defect == "copy_flag_index_disagree": - message = "support-copy flag and support copy index disagree" + message = "'cgt_support_split' marker and ordinal disagree" elif defect == "negative_copy_index": rows[6] = (1001, 2, "frs", 0, False, -1, "SCOTLAND") message = "negative" @@ -420,6 +420,6 @@ def clear_flag(household): frame = lineage_frame(RESIDENTIAL_ROWS, mutate=clear_flag) with pytest.raises( - NodeRejectedError, match="residential-arm flag and arm index disagree" + NodeRejectedError, match="'cgt_residential_split' marker and ordinal disagree" ): run_identity(frame, tmp_path, k=1) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_company_cars.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_company_cars.py index 7fd19021cd..534c9460c3 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_company_cars.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_company_cars.py @@ -1115,6 +1115,7 @@ def test_salary_sacrifice_runs_on_the_stage_s_output( "household_id": ids, "source_household_id": ids, "household_support_channel": np.where(spi, "spi", "frs"), + "household_support_clone_index": np.where(spi, 1, 0), } ) frame = uk_national_frame( diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py new file mode 100644 index 0000000000..e5958c5416 --- /dev/null +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py @@ -0,0 +1,143 @@ +"""The FRS-trained fits fold geographic clones, and only them (microcosm#931).""" + +from __future__ import annotations + +import ast +import inspect +from pathlib import Path + +import numpy as np +import pandas as pd + +from microcosm.build.uk_runtime import graph_kernels +from microcosm.build.uk_runtime.graph import _STAGE_CONSUMES, uk_spine_graph +from microcosm.build.uk_runtime.household_lineage import ( + UK_COPY_LINEAGE, + collapse_geographic_clones, +) +from microcosm.build.uk_runtime.national_frame import uk_national_frame +from microcosm.build.uk_runtime.rowwise_dataset import ladder_clone_index_column +from test_support.microcosm_build.uk_geographic_clones import with_geographic_clones + + +def _copies_frame(): + """One survey household and its SPI, high-value and CGT copies.""" + + household = pd.DataFrame( + { + "household_id": np.arange(1, 5, dtype="int64"), + "source_household_id": np.ones(4, dtype="int64"), + "household_support_channel": ["frs", "spi", "frs", "frs"], + "household_support_clone_index": np.asarray([0, 1, 0, 0], dtype="int64"), + "household_is_high_value_support_copy": [False, False, True, False], + "high_value_support_copy_index": np.asarray([0, 0, 1, 0], dtype="int64"), + "household_is_cgt_support_copy": False, + "cgt_support_copy_index": np.zeros(4, dtype="int64"), + "household_is_capital_gains_clone": [False, False, False, True], + "household_is_cgt_residential_clone": False, + "cgt_residential_clone_index": np.zeros(4, dtype="int64"), + } + ) + person = pd.DataFrame( + { + "person_id": np.arange(11, 15, dtype="int64"), + "person_household_id": household["household_id"], + "person_benunit_id": np.arange(21, 25, dtype="int64"), + } + ) + benunit = pd.DataFrame({"benunit_id": np.arange(21, 25, dtype="int64")}) + return uk_national_frame( + person=person, + benunit=benunit, + household=household, + household_weights=np.asarray([2.0, 4.0, 6.0, 8.0]), + time_period="2024", + ) + + +def _tables(frame): + return {name: frame.table(name) for name in ("person", "benunit", "household")} + + +def test_only_geographic_clones_fold_into_their_survey_record() -> None: + frame = _copies_frame() + weights = frame.weights_for("household").values + rows = np.ones(4, dtype=bool) + # Without clones every copy is a row of its own, value for value. + kept, summed = collapse_geographic_clones( + _tables(frame), "household", rows, weights + ) + assert kept.tolist() == rows.tolist() + assert summed.tobytes() == np.asarray(weights).tobytes() + pool = with_geographic_clones(frame) + pool_weights = pool.weights_for("household").values + for entity in ("household", "person", "benunit"): + n = pool.n(entity) + kept, summed = collapse_geographic_clones( + _tables(pool), entity, np.ones(n, dtype=bool), np.full(n, 0.5) + ) + clone = pool.table(entity)[ladder_clone_index_column(entity)].to_numpy() + # Each copy keeps its first clone, which carries both clones' weight. + assert kept.tolist() == (clone == 0).tolist() + assert summed[kept].tolist() == [1.0] * 4 + kept, summed = collapse_geographic_clones( + _tables(pool), "household", np.ones(8, dtype=bool), pool_weights + ) + assert summed[kept].tolist() == list(weights) + + +#: The stages whose fits collapse clones, and the module each one's call is +#: in: the SPI income stage runs its forests from spi_income. +_COLLAPSING_STAGES = { + "hmrc_spi_income_spine": "spi_income", + "spi_housing_shell": "spi_housing_shell", + "uc_reporter_redraw": "uc_reporter_redraw", + "uc_capital_coherence": "uc_capital_coherence", + "salary_sacrifice": "salary_sacrifice", +} + + +def _calls_collapse(path: Path) -> bool: + tree = ast.parse(path.read_text(encoding="utf-8")) + return any( + isinstance(node, ast.Call) + and isinstance(node.func, ast.Name) + and node.func.id == "collapse_geographic_clones" + for node in ast.walk(tree) + ) + + +def test_every_collapsing_stage_sees_the_lineage_live_at_it() -> None: + """A finite surface prunes what it does not declare, and a step whose + columns are pruned reads as one that has not run: its copies would fold + into their sources. So every stage that collapses clones declares every + lineage column live where it runs; in the geography-first order that + includes the geographic clone index (microcosm#931).""" + + runtime = Path(inspect.getfile(graph_kernels)).parent + callers = {path.stem for path in runtime.glob("*.py") if _calls_collapse(path)} + assert callers == set(_COLLAPSING_STAGES.values()) + for stage, module in _COLLAPSING_STAGES.items(): + names = { + graph_kernels._stage_module(stage).__name__, + *(m.__name__ for m in graph_kernels._STAGE_HELPER_MODULES.get(stage, ())), + } + assert f"microcosm.build.uk_runtime.{module}" in names, stage + lineage = { + ("household", column) + for column in (UK_COPY_LINEAGE.source, *UK_COPY_LINEAGE.copy_columns) + } + live: set[tuple[str, str]] = set() + checked = [] + for node in uk_spine_graph().nodes: + if node.id in _COLLAPSING_STAGES and _STAGE_CONSUMES.get(node.id) is not None: + declared = { + (slice_.entity, column) + for slice_ in node.inputs + for column in slice_.columns + } + missing = sorted(live & lineage - declared) + assert not missing, (node.id, missing) + checked.append(node.id) + live |= {(cell.entity, cell.column) for cell in node.outputs} + assert sorted(checked) == ["spi_housing_shell", "uc_capital_coherence"] diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_salary_sacrifice.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_salary_sacrifice.py index 877e14d245..3e1397cf1c 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_salary_sacrifice.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_salary_sacrifice.py @@ -32,6 +32,7 @@ load_bonus_sacrifice_anchor, load_salary_sacrifice_anchor, ) +from test_support.microcosm_build.uk_geographic_clones import with_geographic_clones class _Fitted: @@ -107,8 +108,13 @@ def _frame( "household_source_id": ids, "source_household_id": ids, "household_support_channel": channels, + # The copy steps' ordinals beside their flags, as on the spine. + "household_support_clone_index": np.where( + np.asarray(channels) == "spi", 1, 0 + ), HOUSEHOLD_IS_CGT_CLONE: clones, HOUSEHOLD_IS_CGT_SUPPORT_COPY: donors, + "cgt_support_copy_index": np.asarray(donors, dtype=np.int64), } ) return uk_national_frame( @@ -516,8 +522,10 @@ def draw(recipient: pd.DataFrame, ids: np.ndarray) -> pd.DataFrame: { "household_id": groups, "household_support_channel": "frs", + "household_support_clone_index": 0, HOUSEHOLD_IS_CGT_CLONE: False, HOUSEHOLD_IS_CGT_SUPPORT_COPY: False, + "cgt_support_copy_index": 0, "household_source_id": groups, "source_household_id": groups, } @@ -937,3 +945,25 @@ def test_the_hmrc_salary_sacrifice_rows_bind_the_salary_route_alone() -> None: for row in rows: text = json.dumps(row) assert BONUS_SACRIFICE_OUTPUT not in text, row["target_id"] + + +def test_geographic_clones_train_each_respondent_once_at_their_whole_weight( + monkeypatch: pytest.MonkeyPatch, +) -> None: + """Two geographic clones of every household at half its weight hand the + forest the respondents and weights they hand it alone (microcosm#931).""" + + monkeypatch.setattr(salary_sacrifice, "QRF", _FakeQRF) + _Fitted.value = 5.0 + frame = _frame( + asked=[1, 1, 1, 0, 0], + salary_sacrifice_values=[10.0, 20.0, 30.0, 0.0, 0.0], + employee_pension=[0.0] * 5, + channels=["frs", "frs", "frs", "frs", "spi"], + weights=np.asarray([2.0, 4.0, 6.0, 8.0, 10.0]), + ) + _FakeQRF.training_frames = [] + impute_salary_sacrifice(frame) + impute_salary_sacrifice(with_geographic_clones(frame)) + alone, cloned = _FakeQRF.training_frames + pd.testing.assert_frame_equal(cloned, alone) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_housing_shell.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_housing_shell.py index e5e88687e4..dd56734a98 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_housing_shell.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_housing_shell.py @@ -25,6 +25,7 @@ restrict_bands_to_nation, ) from microcosm.frame import WeightKind +from test_support.microcosm_build.uk_geographic_clones import with_geographic_clones from test_support.microcosm_build.uk_spi_housing_shell import housing_shell_tables @@ -125,7 +126,9 @@ def test_stage_transform_runs_on_a_frame_and_records_its_receipt() -> None: def test_a_frame_without_frs_training_rows_is_refused() -> None: person, _, household, weights = housing_shell_tables() - household = household.assign(household_support_channel="spi") + household = household.assign( + household_support_channel="spi", household_support_clone_index=1 + ) with pytest.raises(ValueError, match="FRS training rows"): impute_spi_housing_shell(person, household, weights, seed=0, n_estimators=20) @@ -288,3 +291,44 @@ def test_without_the_restriction_spi_rows_leave_their_nation(monkeypatch) -> Non band in bands for band, bands in zip(spi["council_tax_band"], allowed, strict=True) ) + + +def test_geographic_clones_train_the_model_as_their_survey_household() -> None: + """Two geographic clones of every household at half its weight fit the + model each survey household fits alone, so every SPI copy's first clone + draws the housing it draws without clones (microcosm#931).""" + + person, benunit, household, weights = housing_shell_tables() + pool = with_geographic_clones( + uk_national_frame( + person=person, + benunit=benunit, + household=household, + household_weights=weights, + time_period="2024", + ) + ) + _, alone, alone_receipt = impute_spi_housing_shell( + person, household, weights, seed=0, n_estimators=20 + ) + _, cloned, receipt = impute_spi_housing_shell( + pool.table("person"), + pool.table("household"), + pool.weights_for("household").values, + seed=0, + n_estimators=20, + ) + columns = [*HOUSING_CATEGORICAL_COLUMNS, *HOUSING_AMOUNT_COLUMNS] + first = cloned.loc[cloned["household_clone_index"] == 0] + pd.testing.assert_frame_equal( + first.set_index("household_id")[columns], + alone.set_index("household_id")[columns], + ) + assert receipt["training_households"] == alone_receipt["training_households"] + assert { + column: shares["training"] + for column, shares in receipt["category_shares"].items() + } == { + column: shares["training"] + for column, shares in alone_receipt["category_shares"].items() + } diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py index 634dee9eeb..d76f616569 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py @@ -1,6 +1,10 @@ """Tests split from packages/microcosm-build/tests/test_uk_spi_income.py.""" # ruff: noqa: F403, F405 +from dataclasses import replace as _replace + +from microcosm.build.uk_runtime.national_frame import uk_national_frame as _uk_frame +from test_support.microcosm_build.uk_geographic_clones import with_geographic_clones from test_support.microcosm_build.uk_spi_income import * @@ -1502,3 +1506,84 @@ def test_each_spi_fit_takes_its_operations_gate_calibration( spi_income.SPI_TRANSPORT_FIT_NAME, } assert set(result.gate_outcomes.values()) == {"cross_fitted"} + + +def _geographic_clones_of(support): + """The support's tables as two geographic clones at half the weight.""" + + household = support.household.drop(columns="household_weight") + pool = with_geographic_clones( + _uk_frame( + person=support.person, + benunit=support.benunit, + household=household, + household_weights=support.household["household_weight"].to_numpy(), + weight_kind=support.household_weight_kind, + time_period="2023", + mass_log=support.mass_log, + ) + ) + cloned = pool.table("household").copy() + cloned["household_weight"] = pool.weights_for("household").values + return _replace( + support, + person=pool.table("person"), + benunit=pool.table("benunit"), + household=cloned, + ) + + +def test_geographic_clones_train_the_frs_forests_as_their_survey_records( + monkeypatch, tmp_path +) -> None: + """Two geographic clones of every household at half its weight hand the + reference and stage-2 forests the rows and weights the households hand + them alone (microcosm#931).""" + + support = _dead_support() + # The legacy artifact clone filter would drop rows the pool does not. + support = _replace(support, household=support.household.drop(columns="clone_index")) + donor_path = tmp_path / SPI_DONOR_FILENAME + _write_donor(donor_path) + monkeypatch.setattr(spi_income, "QRF", _FakeQRF) + _bypass_reviewed_donor_identity(monkeypatch) + real_cross_fit = spi_income.cross_fit_transport + monkeypatch.setattr( + spi_income, + "cross_fit_transport", + lambda *args, **kwargs: real_cross_fit( + *args, **{**kwargs, "allow_in_sample": True} + ), + ) + + def frs_fits(frame): + monkeypatch.setattr(_FakeQRF, "fit_gates", []) + monkeypatch.setattr(_FakeQRF, "fit_weight_values", []) + try: + impute_uk_spi_income_support( + frame, + donor_path, + seed=9, + n_estimators=3, + donor_sample_size=None, + state_pension_age=66, + allow_in_sample_reference=True, + stage1_gate_calibration="cross_fitted", + ) + except ImportError: + pass + # The tape forest trains on the tape, not on the frame. + return list( + zip(_FakeQRF.fit_gates[1:], _FakeQRF.fit_weight_values[1:], strict=True) + ) + + alone = frs_fits(support) + cloned = frs_fits(_geographic_clones_of(support)) + assert alone and len(cloned) == len(alone) + for ((kind, gate, groups), weights), ( + (cloned_kind, cloned_gate, cloned_groups), + cloned_weights, + ) in zip(alone, cloned, strict=True): + assert (cloned_kind, cloned_gate) == (kind, gate) + np.testing.assert_array_equal(cloned_groups, groups) + np.testing.assert_array_equal(cloned_weights, weights) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_capital_coherence.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_capital_coherence.py index 51d4ee6530..3af4460f5e 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_capital_coherence.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_capital_coherence.py @@ -1,6 +1,8 @@ """Tests split from packages/microcosm-build/tests/test_uk_uc_capital_coherence.py.""" # ruff: noqa: F403, F405 +from microcosm.build.uk_runtime.rowwise_dataset import ladder_clone_index_column +from test_support.microcosm_build.uk_geographic_clones import with_geographic_clones from test_support.microcosm_build.uk_uc_capital_coherence import * RECEIPTS = ("coarsening_levels", "capital_against_investment_income", "property_shares") @@ -230,6 +232,7 @@ def redraw_tables( _redraw_spi_capital( benunit_table, person=person_table, + household=household_table, weights=_household_to_benunit_weights( benunit_table, person=person_table, @@ -629,3 +632,22 @@ def test_stage_refuses_a_drifted_property_share_declaration() -> None: ) with pytest.raises(ValueError, match="derive operation"): transform(_frame()) + + +def test_geographic_clones_donate_once_at_their_whole_weight() -> None: + """Two geographic clones of every unit at half its weight donate as the + units donate alone: every SPI unit's first clone draws the capital it + draws without clones, and a cell's donor count reads units, not clones, + so each clone draws at its unit's coarsening level (microcosm#931).""" + + alone = cohere_uc_capital(_frame(), minimum_cell_donors=2) + cloned = cohere_uc_capital(with_geographic_clones(_frame()), minimum_cell_donors=2) + benunit = cloned.frame.table("benunit") + first = benunit.loc[benunit[ladder_clone_index_column("benunit")] == 0] + pd.testing.assert_series_equal( + first.set_index("benunit_id")["frs_benunit_capital"], + alone.frame.table("benunit").set_index("benunit_id")["frs_benunit_capital"], + ) + assert cloned.coarsening_levels == { + level: 2 * count for level, count in alone.coarsening_levels.items() + } diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_reporter_redraw.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_reporter_redraw.py index 73c3e66b3a..f499bd274d 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_reporter_redraw.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_reporter_redraw.py @@ -1,6 +1,7 @@ """Tests split from packages/microcosm-build/tests/test_uk_uc_reporter_redraw.py.""" # ruff: noqa: F403, F405 +from test_support.microcosm_build.uk_geographic_clones import with_geographic_clones from test_support.microcosm_build.uk_uc_reporter_redraw import * @@ -467,3 +468,23 @@ def test_landing_invariants_refuse_base_writes_and_double_landings() -> None: _assert_landing_invariants( wrong_total, benunit, spi=spi, draws=draws, base_before=base_before ) + + +def test_geographic_clones_fit_each_benefit_unit_once_at_its_whole_weight() -> None: + """Two geographic clones of every unit at half its weight hand the forest + the rows and weights the units hand it alone (microcosm#931).""" + + alone = _StubQRFFactory() + redraw_spi_reported_uc(_frame(), engine=_StubEngine(), qrf_factory=alone) + cloned = _StubQRFFactory() + redraw_spi_reported_uc( + with_geographic_clones(_frame()), engine=_StubEngine(), qrf_factory=cloned + ) + assert cloned.record["fit_index"] == alone.record["fit_index"] + np.testing.assert_array_equal( + cloned.record["fit_weights"], alone.record["fit_weights"] + ) + np.testing.assert_array_equal( + cloned.record["fit_groups"], alone.record["fit_groups"] + ) + pd.testing.assert_frame_equal(cloned.record["fit_table"], alone.record["fit_table"]) diff --git a/test_support/microcosm_build/uk_geographic_clones.py b/test_support/microcosm_build/uk_geographic_clones.py new file mode 100644 index 0000000000..8f697172d5 --- /dev/null +++ b/test_support/microcosm_build/uk_geographic_clones.py @@ -0,0 +1,32 @@ +"""Geographic clones of a UK test frame, made as the dense pool makes them. + +The FRS-trained fits fold geographic clones into each survey record +(microcosm#931); a replicated fixture holds them to it. Two clones at half the +weight keep every weight exact, so the folded training rows carry the +original weights bit for bit. +""" + +from __future__ import annotations + +from microcosm.build.uk_runtime.national_frame import uk_time_period +from microcosm.build.uk_runtime.rowwise_dataset import expand_uk_geographic_pool +from microcosm.frame import Frame + + +def with_geographic_clones(frame: Frame, *, n_clones: int = 2) -> Frame: + """``frame`` expanded to ``n_clones`` geographic clones per household. + + Clone 0 keeps every id, so its rows draw on the same keys as the frame's. + """ + + household = frame.table("household").copy() + household["household_weight"] = frame.weights_for("household").values + return expand_uk_geographic_pool( + person=frame.table("person"), + benunit=frame.table("benunit"), + household=household, + n_clones=n_clones, + time_period=uk_time_period(frame), + household_weight_kind=frame.weights_for("household").kind, + mass_log=frame.mass_log, + ).frame diff --git a/test_support/microcosm_build/uk_spi_housing_shell.py b/test_support/microcosm_build/uk_spi_housing_shell.py index 085d4ab1cf..b738dc3ae9 100644 --- a/test_support/microcosm_build/uk_spi_housing_shell.py +++ b/test_support/microcosm_build/uk_spi_housing_shell.py @@ -47,6 +47,10 @@ def housing_shell_tables(n_frs: int = 600, n_spi: int = 200, seed: int = 0): "ons_household_type": household_type, "council_tax_single_adult_raw": np.where(single, 1, 2), "household_support_channel": channel, + # Each household is its own survey source here, and an SPI copy + # is the support channel's first copy. + "source_household_id": household_id, + "household_support_clone_index": np.where(channel == "spi", 1, 0), "tenure_type": tenure, "accommodation_type": accommodation, "num_bedrooms": np.where(high, 4, 2).astype(np.int64), diff --git a/test_support/microcosm_build/uk_uc_capital_coherence.py b/test_support/microcosm_build/uk_uc_capital_coherence.py index 0c94c06236..f35b6265af 100644 --- a/test_support/microcosm_build/uk_uc_capital_coherence.py +++ b/test_support/microcosm_build/uk_uc_capital_coherence.py @@ -122,7 +122,20 @@ def _frame(): "would_claim_uc": [row[7] for row in rows], } ) - household = pd.DataFrame({"household_id": [row[0] for row in rows]}) + # Each household is its own survey source here, with the lineage a spine + # carries by this stage: its unit's support channel and no high-value copy. + household = pd.DataFrame( + { + "household_id": [row[0] for row in rows], + "source_household_id": [row[0] for row in rows], + "household_support_channel": [row[3] for row in rows], + "household_support_clone_index": [ + 1 if row[3] == "spi" else 0 for row in rows + ], + "household_is_high_value_support_copy": False, + "high_value_support_copy_index": 0, + } + ) # No household holds property here; the property-share tests add it. for column in ( *PENSION_CREDIT_PROPERTY_CAPITAL_SOURCES, diff --git a/test_support/microcosm_build/uk_uc_reporter_redraw.py b/test_support/microcosm_build/uk_uc_reporter_redraw.py index fcee2f0523..3289a261d8 100644 --- a/test_support/microcosm_build/uk_uc_reporter_redraw.py +++ b/test_support/microcosm_build/uk_uc_reporter_redraw.py @@ -223,6 +223,8 @@ def _frame(*, child_only: bool = False): household = pd.DataFrame( { "household_id": [row[1] for row in benunit_rows], + # Each household is its own survey source here. + "source_household_id": [row[1] for row in benunit_rows], "region": ["LONDON" if row[1] % 2 else "SCOTLAND" for row in benunit_rows], "household_is_capital_gains_clone": [row[4] for row in benunit_rows], } From 972f824c9ff1fe673500817bb4f11e4d6e27af0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Thu, 5 Nov 2026 01:41:10 +0000 Subject: [PATCH 03/20] Let a shared area draw choose each household's weight column (#931) A sampling stage of the shared atomic-geography declaration can declare weight_by (input, map, default) in place of its one weight column: each household samples by the weight column map names for its input code, or by default where the code is missing, and a code the map does not name is refused. The UK geography-first draw needs it to weight a household's output area by the dwellings in its own council-tax band. Declarations without weight_by keep their canonical bytes, definition digest and draws: New Zealand's committed declaration and today's UK one are unchanged, and the invented fixture's draws are pinned. Only the geography kernels' implementation hashes, and with them their cache keys, move. The graph builder adds the weight_by input to the assignment's household slice. Co-Authored-By: Claude Opus 5.5 --- .../931-atomic-geography-weight-by.added.md | 1 + docs/geography-assignment.md | 7 +- .../src/microcosm/build/atomic_geography.py | 70 +++++++-- .../microcosm/build/graph_atomic_geography.py | 3 + .../shared/test_atomic_geography.py | 139 ++++++++++++++++++ 5 files changed, 206 insertions(+), 14 deletions(-) create mode 100644 changelog.d/931-atomic-geography-weight-by.added.md diff --git a/changelog.d/931-atomic-geography-weight-by.added.md b/changelog.d/931-atomic-geography-weight-by.added.md new file mode 100644 index 0000000000..d381d65616 --- /dev/null +++ b/changelog.d/931-atomic-geography-weight-by.added.md @@ -0,0 +1 @@ +A sampling stage of the shared atomic-geography declaration can declare `weight_by` (`input`, `map`, `default`) in place of its one `weight` column: each household then samples by the weight column `map` names for its `input` code, or by `default` where the code is missing, and a code the map does not name is refused (#931). The UK geography-first draw needs it to weight a household's output area by the dwellings in its own council-tax band. Declarations without `weight_by`, New Zealand's and today's UK one among them, keep their canonical bytes, definition digest and draws; only the geography kernels' implementation hashes, and with them their cache keys, move. The graph builder adds the `weight_by` input to the assignment's household slice. diff --git a/docs/geography-assignment.md b/docs/geography-assignment.md index c71051a230..aa5ba6e8d4 100644 --- a/docs/geography-assignment.md +++ b/docs/geography-assignment.md @@ -142,7 +142,12 @@ cross-platform equivalence has not been established. The version-1 declaration lists `identity`, `stream`, three assignment `outputs` (`area`, `system`, `basis`), and `systems`. Each system supplies its atomic identity and source, a selector, observed constraints, an optional observed-area -column, sampling stages and derived layers. Geographic codes use nullable +column, sampling stages and derived layers. A stage samples by one `weight` +column, or declares `weight_by` (`input`, `map`, `default`) instead: each +household samples by the weight column `map` names for its `input` code, or by +`default` where the code is missing, and a code `map` does not name is refused +(microcosm#931). A declaration without `weight_by` keeps its canonical bytes, +so its definition digest and draws are unchanged. Geographic codes use nullable strings throughout, retaining leading zeroes. An engine that needs integer storage must declare that conversion separately. A system without a particular layer produces missing values for that layer, which the integrity gate checks. diff --git a/packages/microcosm-build/src/microcosm/build/atomic_geography.py b/packages/microcosm-build/src/microcosm/build/atomic_geography.py index dc419490f6..c3da555029 100644 --- a/packages/microcosm-build/src/microcosm/build/atomic_geography.py +++ b/packages/microcosm-build/src/microcosm/build/atomic_geography.py @@ -175,6 +175,39 @@ def decode_atomic_support(payload: bytes) -> AtomicSupport: ) +def _stage_schema(stage) -> bool: + """A stage samples by one weight column, or by one chosen per household. + + ``weight_by`` reads each household's ``input`` code and samples by the + weight column ``map`` names for it, or by ``default`` where the code is + missing (microcosm#931). A stage declares one form, never both, so a + declaration without ``weight_by`` keeps its canonical bytes and draws. + """ + if not isinstance(stage, dict) or not _text(stage.get("level")): + return False + if set(stage) == {"level", "weight"}: + return _text(stage["weight"]) + rule = stage.get("weight_by") + return ( + set(stage) == {"level", "weight_by"} + and isinstance(rule, dict) + and set(rule) == {"input", "map", "default"} + and _text(rule["input"]) + and _text(rule["default"]) + and isinstance(rule["map"], dict) + and bool(rule["map"]) + and all(_text(code) and _text(weight) for code, weight in rule["map"].items()) + ) + + +def _stage_weights(stage: Mapping) -> tuple[str, ...]: + """Every weight column a stage can sample by.""" + if "weight" in stage: + return (stage["weight"],) + rule = stage["weight_by"] + return (*rule["map"].values(), rule["default"]) + + def validate_assignment_spec(spec: Mapping) -> dict: """Normalize a graph parameter mapping without accepting undeclared options. @@ -269,16 +302,7 @@ def validate_assignment_spec(spec: Mapping) -> dict: seen.add(c["support"]) stages = system["stages"] _require(isinstance(stages, list) and bool(stages), "sampling stages") - _require( - all( - isinstance(s, dict) - and set(s) == {"level", "weight"} - and _text(s["level"]) - and _text(s["weight"]) - for s in stages - ), - "stage schema", - ) + _require(all(_stage_schema(s) for s in stages), "stage schema") _require( stages[-1]["level"] == "area" and len({s["level"] for s in stages}) == len(stages), @@ -305,6 +329,9 @@ def validate_assignment_spec(spec: Mapping) -> dict: for system in systems: required.update(system["selector"]) required.update(c["input"] for c in system["constraints"]) + required.update( + s["weight_by"]["input"] for s in system["stages"] if "weight_by" in s + ) if system["observed_area"]: required.add(system["observed_area"]) _require( @@ -343,8 +370,10 @@ def _bind(spec: Mapping, supports: Mapping[str, AtomicSupport]): _require( s["level"] in columns and columns[s["level"]]["kind"] == "code" - and s["weight"] in columns - and columns[s["weight"]]["kind"] == "weight", + and all( + weight in columns and columns[weight]["kind"] == "weight" + for weight in _stage_weights(s) + ), "unknown stage column", ) for layer in system["layers"]: @@ -384,6 +413,19 @@ def _constraints(row, system) -> tuple: return tuple(sorted(values)) +def _household_stage(row, stage: Mapping) -> Mapping: + """The stage with the one weight column this household samples by.""" + rule = stage.get("weight_by") + if rule is None: + return stage + value = row[rule["input"]] + if pd.isna(value): + return {"level": stage["level"], "weight": rule["default"]} + _require(_text(value), "weight-by codes require nonempty strings") + _require(value in rule["map"], "weight-by code has no declared weight") + return {"level": stage["level"], "weight": rule["map"][value]} + + class _SupportIndex: """Index each observed-column pattern once, rather than scanning per household.""" @@ -492,7 +534,9 @@ def assign_atomic( ) else: for stage, uniforms in zip(system["stages"], draws, strict=True): - area = index.pick(constraints, stage, uniforms[local]) + area = index.pick( + constraints, _household_stage(row, stage), uniforms[local] + ) constraints = tuple( sorted({**dict(constraints), stage["level"]: area}.items()) ) diff --git a/packages/microcosm-build/src/microcosm/build/graph_atomic_geography.py b/packages/microcosm-build/src/microcosm/build/graph_atomic_geography.py index a245992a83..5d42252363 100644 --- a/packages/microcosm-build/src/microcosm/build/graph_atomic_geography.py +++ b/packages/microcosm-build/src/microcosm/build/graph_atomic_geography.py @@ -217,6 +217,9 @@ def atomic_geography_nodes( for system in spec["systems"]: inputs.update(system["selector"]) inputs.update(c["input"] for c in system["constraints"]) + inputs.update( + s["weight_by"]["input"] for s in system["stages"] if "weight_by" in s + ) if system["observed_area"]: inputs.add(system["observed_area"]) assignment = tuple(spec["outputs"].values()) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_atomic_geography.py b/packages/microcosm-build/tests/engine_free/shared/test_atomic_geography.py index ac93c30fbd..65f5084b2b 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_atomic_geography.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_atomic_geography.py @@ -1,5 +1,6 @@ """Invented support controls; no survey, Census or administrative files are read.""" +import json from copy import deepcopy from dataclasses import replace @@ -33,6 +34,7 @@ ) from microcosm.graph.canonical import canonical_json from microcosm.graph.keys import opaque_artifact_key +from test_support.paths import paths_for def support_parts(system="invented_block", *, district=True): @@ -187,6 +189,128 @@ def test_stage_law_uses_declared_weights_at_each_level(): assert index.pick((("region", "R"),), spec["systems"][0]["stages"][0], 0.5) == "B" +def test_declarations_without_weight_by_keep_their_bytes_and_draws(): + """A stage without ``weight_by`` keeps its canonical declaration, so its + definition digest and every draw keyed on it stay as they were before the + key existed (microcosm#931); New Zealand's committed declaration too.""" + households, spec, supports, _ = fixture() + assert canonical_json(geo.validate_assignment_spec(spec)) == canonical_json(spec) + nz = paths_for("microcosm-build").package / ( + "src/microcosm/build/nz/geography_assignment.json" + ) + declaration = json.loads(nz.read_text(encoding="utf-8")) + assert canonical_json(geo.validate_assignment_spec(declaration)) == ( + canonical_json(declaration) + ) + assert geo.assign_atomic(households, spec, supports)["block"].tolist() == [ + "0003", + "0002", + "0003", + "0003", + "0002", + "0003", + "0003", + "0004", + ] + + +def banded_fixture(): + """Three invented dwelling counts: band A lies only in 0002, band B only in + 0003 and the unbanded count only in 0001 (and all three in 0004).""" + metadata, arrays = support_parts() + for name, counts in ( + ("band_a", [0, 5, 0, 1]), + ("band_b", [0, 0, 7, 1]), + ("unbanded", [3, 0, 0, 1]), + ): + metadata["columns"][name] = { + "kind": "weight", + "source": "invented-counts-v1", + "basis": "dwellings", + } + arrays[name] = np.asarray(counts) + support = geo.decode_atomic_support(geo.encode_atomic_support(metadata, arrays)) + households, spec, _, _ = fixture() + spec["systems"][0]["stages"] = [ + { + "level": "area", + "weight_by": { + "input": "observed_band", + "map": {"A": "band_a", "B": "band_b"}, + "default": "unbanded", + }, + } + ] + households["observed_band"] = pd.array( + ["A", "A", "B", "B", "A", None, "B", None], dtype="string" + ) + return households, spec, {"invented_block": support} + + +def test_weight_by_samples_each_household_by_its_own_weight_column(): + households, spec, supports = banded_fixture() + result = complete(households, spec, supports) + # Each band's mass lies in one area of region R, so the draw is forced; + # the missing band takes the default, and region S has one area. + assert result["block"].tolist() == [ + "0002", + "0002", + "0003", + "0003", + "0002", + "0001", + "0003", + "0004", + ] + assert geo.validate_geography(result, spec, supports)["outcome"] == "pass" + # The band is an input the declaration reads, so it cannot be overwritten. + altered = deepcopy(spec) + altered["outputs"]["area"] = "observed_band" + with pytest.raises(ValueError, match="overwritten"): + geo.validate_assignment_spec(altered) + + +@pytest.mark.parametrize( + "defect", + [ + "both_forms", + "no_default", + "empty_map", + "padded_map_code", + "code_column_weight", + "unknown_default", + "unmapped_code", + "padded_code", + "zero_mass_cell", + ], +) +def test_weight_by_refuses_undeclared_weights_and_codes(defect): + households, spec, supports = banded_fixture() + stage = spec["systems"][0]["stages"][0] + rule = stage["weight_by"] + if defect == "both_forms": + stage["weight"] = "population" + elif defect == "no_default": + del rule["default"] + elif defect == "empty_map": + rule["map"] = {} + elif defect == "padded_map_code": + rule["map"][" C"] = "band_a" + elif defect == "code_column_weight": + rule["map"]["B"] = "puma" + elif defect == "unknown_default": + rule["default"] = "missing" + elif defect == "unmapped_code": + households.loc[0, "observed_band"] = "C" + elif defect == "padded_code": + households.loc[0, "observed_band"] = "A " + elif defect == "zero_mass_cell": + # Band A has no dwellings in puma B, the only area household 2 may take. + households.loc[2, "observed_band"] = "A" + with pytest.raises(ValueError): + geo.assign_atomic(households, spec, supports) + + def test_qualified_observed_area_is_retained_even_with_zero_sampling_mass(): households, spec, supports, _ = fixture() households["observed_block"] = pd.array(["0001"] + [None] * 7, dtype="string") @@ -469,6 +593,21 @@ def test_graph_builder_refuses_input_overwrites_and_duplicate_inventory(): atomic_geography_nodes(altered, columns, base="spine") +def test_graph_builder_reads_the_weight_by_input(): + _, spec, _ = banded_fixture() + columns = tuple( + Owned("household", c, "string") + for c in ("source_record", "observed_region", "observed_puma") + ) + with pytest.raises(ValueError, match="missing"): + atomic_geography_nodes(spec, columns, base="spine") + nodes = atomic_geography_nodes( + spec, (*columns, Owned("household", "observed_band", "string")), base="spine" + ) + assign = next(node for node in nodes if node.id == "geography.assign") + assert "observed_band" in assign.inputs[0].columns + + @pytest.mark.parametrize("defect", ("missing", "type")) def test_typed_geography_gate_edge_refuses_invalid_producer_contract(defect): _, spec, _, _ = fixture() From 945110ffa32065e6fbcab6506b656046c5f53835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Thu, 5 Nov 2026 14:11:20 +0000 Subject: [PATCH 04/20] Add conditioned UK area supports for the geography-first draw (#931) Each of the three UK atomic-area supports gains a conditioned form that only the geography-first move binds; today's build binds the registered supports, so no output moves. A conditioned support extends its registered support byte for byte and adds: - imd_decile, an exact-match constraint code: the area's decile within its nation at the 2019 vintage the FRS 2024-25 deciles follow (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017), the plurality of its live residential postcodes in the May 2026 NSPL, with ties and postcode-less areas resolved by the parent area; - households by council-tax band times 10^6, exact integers for a weight_by stage: England and Wales from the area's LSOA mix in VOA CTSOP1.1 (band I only in Wales), Scotland from its council's CTAXBASE 2025 chargeable dwellings, so there the band moves mass only between councils, and none in Northern Ireland, which has domestic rates. tools/build_uk_conditioned_area_supports.py builds them from chronicle#412's raw-only registrations, read at PR chronicle#413's head and pinned by sha256. The committed provenance records every input, the decile rule counts, the rounding and a precomputed table of zero-mass draw cells. sources.yaml declares them under role uk_atomic_area_conditioned_support with five new geography vintages; spine.yaml declares the FRS channel's observed_constraints [imd_decile], an optional field the shared spine schema now admits; validate_uk_country_source_projection refuses a spec in which the supports, their conditioned forms and that declaration disagree. The building blocks are country-neutral, in microcosm.build.atomic_support_conditioning: modal_area_codes, apportion_weights, extend_atomic_support and zero_mass_cells. Co-Authored-By: Claude Opus 5.5 --- .../931-uk-conditioned-area-supports.added.md | 20 + docs/geography-assignment.md | 33 + .../build/atomic_support_conditioning.py | 308 +++++ .../spec_engine/schema/spine.schema.json | 8 + .../microcosm/build/uk/country_package.json | 5 + .../src/microcosm/build/uk/spec/sources.yaml | 57 + .../src/microcosm/build/uk/spec/spine.yaml | 2 + .../src/microcosm/build/uk/spec/vintages.yaml | 175 +++ ..._area_conditioned_supports.provenance.json | 1068 +++++++++++++++++ .../build/uk_runtime/atomic_area_support.py | 187 ++- .../build/uk_runtime/country_adapter.py | 57 +- .../test_atomic_support_conditioning.py | 307 +++++ .../engine_free/shared/test_country_spec.py | 2 + .../uk/test_uk_conditioned_area_supports.py | 408 +++++++ .../test_uk_conditioned_area_supports_tool.py | 180 +++ .../engine_free/uk/test_uk_country_adapter.py | 89 +- tools/build_uk_conditioned_area_supports.py | 603 ++++++++++ 17 files changed, 3470 insertions(+), 39 deletions(-) create mode 100644 changelog.d/931-uk-conditioned-area-supports.added.md create mode 100644 packages/microcosm-build/src/microcosm/build/atomic_support_conditioning.py create mode 100644 packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json create mode 100644 packages/microcosm-build/tests/engine_free/shared/test_atomic_support_conditioning.py create mode 100644 packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py create mode 100644 packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py create mode 100644 tools/build_uk_conditioned_area_supports.py diff --git a/changelog.d/931-uk-conditioned-area-supports.added.md b/changelog.d/931-uk-conditioned-area-supports.added.md new file mode 100644 index 0000000000..bf8751ff09 --- /dev/null +++ b/changelog.d/931-uk-conditioned-area-supports.added.md @@ -0,0 +1,20 @@ +The UK atomic-area supports gain conditioned forms for the geography-first draw (#931), which only that move binds; today's build binds the registered supports, so no output moves. + +Each conditioned support extends its system's registered support byte for byte, and adds: + +- **`imd_decile`:** the area's deprivation decile within its nation, at the 2019 vintage the FRS 2024-25 deciles follow (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017). Each area takes the plurality of its live residential postcodes in the May 2026 NSPL; a tie goes to the parent area's plurality, and an area without such a postcode takes its parent's decile. +- **Households by council-tax band, times 10^6, as exact integers:** + - England and Wales take bands A to I from the area's LSOA mix in VOA CTSOP1.1; only Wales has band I. + - Scotland takes bands A to H from its council's CTAXBASE 2025 chargeable dwellings, rounded half to even, so there the band moves mass only between councils. + - Northern Ireland is unbanded. + +`tools/build_uk_conditioned_area_supports.py` builds them from chronicle#412's raw-only registrations (PR chronicle#413), pinned by sha256. `uk/uk_atomic_area_conditioned_supports.provenance.json` records every input, the decile rule counts, the rounding and a precomputed table of zero-mass draw cells. + +`sources.yaml` declares the supports under the new role `uk_atomic_area_conditioned_support`, with five new geography vintages. `spine.yaml` declares the FRS channel's `observed_constraints: [imd_decile]`, an optional field the shared spine schema now admits. `validate_uk_country_source_projection` refuses a spec in which the supports, their conditioned forms and that declaration disagree. + +The country-neutral `microcosm.build.atomic_support_conditioning` provides the building blocks: + +- `modal_area_codes`; +- `apportion_weights`; +- `extend_atomic_support`; +- `zero_mass_cells`. diff --git a/docs/geography-assignment.md b/docs/geography-assignment.md index aa5ba6e8d4..7d1d3b4874 100644 --- a/docs/geography-assignment.md +++ b/docs/geography-assignment.md @@ -187,6 +187,39 @@ on a shared seeded stream) remains available as `--geography-assignment legacy` for measurement builds only, and still supplies the rosters and dispersion checks used by target compilation. +Each support also has a conditioned form for the geography-first draw +(microcosm#931), which only that move binds. It is declared in +`uk/spec/sources.yaml` with role `uk_atomic_area_conditioned_support`, beside +the support it extends, and recorded in +`uk/uk_atomic_area_conditioned_supports.provenance.json`; +`tools/build_uk_conditioned_area_supports.py` builds it from the registered +support's bytes and chronicle#412's raw-only registrations. It adds two kinds of +column: + +- **`imd_decile`**, an exact-match constraint code. It is the area's + deprivation decile within its own nation, at the 2019 vintage the FRS + 2024-25 deciles follow (IoD 2019, WIMD 2019, SIMD 2020v2 and NIMDM 2017). An + area takes the decile that most of its live residential postcodes carry in + the May 2026 NSPL. A tie goes to its parent area's plurality, and an area + without such a postcode takes its parent's decile. The relation is + `inferred_modal`. +- **`households_band_a`, `households_band_b` and so on**, weight columns. Each is + the area's households in that council-tax band times 10^6, which a `weight_by` + stage chooses per household: + - England and Wales take bands A to I from the area's LSOA mix in VOA + CTSOP1.1. Only Wales has band I. + - Scotland takes bands A to H from its council's CTAXBASE 2025 chargeable + dwellings, so there the band moves mass only between councils. + - Northern Ireland has domestic rates, so its support carries no bands. + +The provenance lists every zero-mass draw cell (FRS region by decile, and +region alone, for each weight column), so the move can choose a draw's fallback +ahead of time instead of meeting an empty cell. `spine.yaml` declares the FRS +channel's `observed_constraints: [imd_decile]`, and the UK country adapter +refuses a spec in which the supports, their conditioned forms and that +declaration disagree. The shared pieces (`atomic_support_conditioning`: modal +codes, exact apportionment and zero-mass cells) name no country's columns. + The Northern Ireland source builder currently infers Data Zone constituencies using the modal active-postcode constituency. Review the official [NISRA constituency aggregation and lookup resources](https://www.nisra.gov.uk/publications/census-2021-output-geography-information-papers) diff --git a/packages/microcosm-build/src/microcosm/build/atomic_support_conditioning.py b/packages/microcosm-build/src/microcosm/build/atomic_support_conditioning.py new file mode 100644 index 0000000000..b84c9e1f18 --- /dev/null +++ b/packages/microcosm-build/src/microcosm/build/atomic_support_conditioning.py @@ -0,0 +1,308 @@ +"""Extra columns an atomic-area support carries for a conditioned draw. + +A country conditions its area draw on what its survey records about the real +address (microcosm#931): an exact-match code such as a deprivation decile, and +a weight chosen per household, such as the area's dwellings in the household's +own council-tax band. The shared operator already takes both +(:mod:`microcosm.build.atomic_geography`: code constraints, and ``weight_by``). +This module builds the columns, and names no country's sources or columns: + +- :func:`modal_area_codes` gives each area the code most of its point records + carry (postcodes, say), breaking a tie by the code its parent area's records + favour, and giving an area without records its parent's code; +- :func:`apportion_weights` splits each area's count over categories by stated + shares into exact integers, rounding half to even, and records the rounding; +- :func:`extend_atomic_support` adds declared columns to a support's bytes; +- :func:`zero_mass_cells` lists every constraint cell, at each fallback level, + where a weight column has no sampling mass, so a draw can choose its + fallback ahead of time rather than fail on an empty cell. +""" + +from __future__ import annotations + +import itertools +from collections.abc import Mapping, Sequence +from dataclasses import dataclass + +import numpy as np +import pandas as pd + +from microcosm.build.atomic_geography import ( + AtomicSupport, + decode_atomic_support, + encode_atomic_support, +) + +_U53 = 2**53 + + +def _require(condition: bool, message: str) -> None: + if not condition: + raise ValueError("Atomic support conditioning: " + message) + + +def _codes(array: np.ndarray, name: str) -> np.ndarray: + _require( + isinstance(array, np.ndarray) and array.ndim == 1 and array.dtype.kind == "U", + f"{name} must be a one-dimensional Unicode array", + ) + return array + + +@dataclass(frozen=True) +class ModalAreaCodes: + """Each area's code, the rule that chose it, and the records' spread. + + ``rule`` is ``area`` (the area's own plurality), ``area_tie_parent`` (a + tie broken by the parent's records), ``area_tie_order`` (a tie the parent + leaves, broken by the domain order), ``parent`` (no record of its own: + the parent's plurality) or ``parent_tie_order``. ``spanning`` marks areas + whose own records carry more than one code. + """ + + codes: np.ndarray + rule: np.ndarray + spanning: np.ndarray + records: int + + def receipt(self) -> dict[str, object]: + """Counts only: areas by rule, areas spanning codes, records read.""" + rules, counts = np.unique(self.rule, return_counts=True) + return { + "areas": int(len(self.codes)), + "records": int(self.records), + "areas_by_rule": { + str(rule): int(count) for rule, count in zip(rules, counts, strict=True) + }, + "areas_whose_records_span_codes": int(self.spanning.sum()), + } + + +def modal_area_codes( + areas: np.ndarray, + parents: np.ndarray, + record_areas: np.ndarray, + record_codes: np.ndarray, + *, + domain: Sequence[str], +) -> ModalAreaCodes: + """Give each area the code most of its records carry. + + ``areas`` are a support's unique atomic codes and ``parents`` the area + each nests in (one per area). Each record names its area and its code; + a record outside ``areas`` or a code outside ``domain`` is refused, so the + caller drops out-of-scope records explicitly. ``domain`` lists every code + in tie-break order. An area whose parent has no record at all is refused. + """ + areas = _codes(areas, "areas") + parents = _codes(parents, "parents") + record_areas = _codes(record_areas, "record areas") + record_codes = _codes(record_codes, "record codes") + _require(len(parents) == len(areas), "one parent per area") + _require(len(record_areas) == len(record_codes), "one code per record") + _require(len(np.unique(areas)) == len(areas), "areas must be unique") + domain = tuple(domain) + _require( + bool(domain) + and len(set(domain)) == len(domain) + and all(isinstance(code, str) and code for code in domain), + "domain must list distinct nonempty codes", + ) + area_index = pd.Index(areas).get_indexer(record_areas) + _require( + bool(np.all(area_index >= 0)), "a record names an area outside the support" + ) + code_index = pd.Index(domain).get_indexer(record_codes) + _require( + bool(np.all(code_index >= 0)), "a record carries a code outside the domain" + ) + counts = np.zeros((len(areas), len(domain)), dtype=np.int64) + np.add.at(counts, (area_index, code_index), 1) + parent_codes, parent_index = np.unique(parents, return_inverse=True) + parent_counts = np.zeros((len(parent_codes), len(domain)), dtype=np.int64) + np.add.at(parent_counts, parent_index, counts) + own = counts.sum(axis=1) > 0 + _require( + bool(np.all(parent_counts[parent_index[~own]].sum(axis=1) > 0)), + "an area and its parent have no record", + ) + chosen = np.empty(len(areas), dtype=np.int64) + rule = np.empty(len(areas), dtype=object) + for row in range(len(areas)): + parent = parent_counts[parent_index[row]] + if own[row]: + tied = np.flatnonzero(counts[row] == counts[row].max()) + if len(tied) == 1: + chosen[row], rule[row] = tied[0], "area" + continue + best = tied[parent[tied] == parent[tied].max()] + chosen[row] = best[0] + rule[row] = "area_tie_parent" if len(best) == 1 else "area_tie_order" + else: + tied = np.flatnonzero(parent == parent.max()) + chosen[row] = tied[0] + rule[row] = "parent" if len(tied) == 1 else "parent_tie_order" + return ModalAreaCodes( + codes=np.asarray(domain, dtype="U")[chosen], + rule=np.asarray(rule.tolist(), dtype="U"), + spanning=(counts > 0).sum(axis=1) > 1, + records=len(record_areas), + ) + + +def _integers(array: np.ndarray, name: str) -> list[int]: + _require( + isinstance(array, np.ndarray) and array.ndim == 1 and array.dtype.kind in "iu", + f"{name} must be a one-dimensional integer array", + ) + _require(bool(np.all(array >= 0)), f"{name} must be nonnegative") + return [int(value) for value in array] + + +def _round_half_even(numerator: int, denominator: int) -> int: + quotient, remainder = divmod(numerator, denominator) + twice = 2 * remainder + if twice > denominator or (twice == denominator and quotient % 2): + return quotient + 1 + return quotient + + +def apportion_weights( + counts: np.ndarray, + numerators: Mapping[str, np.ndarray], + denominators: np.ndarray, + *, + scale: int, +) -> tuple[dict[str, np.ndarray], dict[str, object]]: + """Split each area's count over categories into exact integer weights. + + Category ``c`` of area ``i`` weighs ``count[i] × scale × numerators[c][i] + / denominators[i]``, rounded half to even in exact integer arithmetic. + Each area's numerators must sum to its denominator, so its weights sum to + ``count × scale`` up to the rounding, which the receipt records. Every + weight column's total must stay within the operator's exact sampling range. + """ + _require(type(scale) is int and scale > 0, "scale must be a positive int") + _require( + isinstance(numerators, Mapping) and bool(numerators), "categories required" + ) + count = _integers(counts, "counts") + denominator = _integers(denominators, "denominators") + _require(len(denominator) == len(count), "one denominator per area") + shares = {name: _integers(array, name) for name, array in numerators.items()} + _require( + all(len(values) == len(count) for values in shares.values()), + "one numerator per area and category", + ) + for row in range(len(count)): + stated = sum(values[row] for values in shares.values()) + _require( + stated == denominator[row] and (denominator[row] > 0 or count[row] == 0), + "each area's numerators must sum to a positive denominator", + ) + weights = {} + for name, values in shares.items(): + column = [ + 0 + if count[row] == 0 + else _round_half_even(count[row] * scale * values[row], denominator[row]) + for row in range(len(count)) + ] + total = sum(column) + _require(total <= _U53, f"{name} total outside the exact sampling range") + weights[name] = np.asarray(column, dtype=np.int64) + deviation = [ + sum(int(weights[name][row]) for name in weights) - count[row] * scale + for row in range(len(count)) + ] + receipt = { + "rounding": "round_half_even", + "scale": scale, + "areas_with_rounding": sum(1 for value in deviation if value), + "largest_area_deviation": max((abs(value) for value in deviation), default=0), + "total_deviation": sum(deviation), + "column_totals": { + name: int(sum(int(v) for v in w)) for name, w in weights.items() + }, + } + return weights, receipt + + +def extend_atomic_support( + payload: bytes, + *, + arrays: Mapping[str, np.ndarray], + columns: Mapping[str, Mapping[str, str]], +) -> bytes: + """Add declared code or weight columns to a support's bytes. + + The support keeps its identity, rows and existing columns; a new column + may not replace one. The result is validated by the shared decoder. + """ + support = decode_atomic_support(payload) + _require(set(arrays) == set(columns) and bool(arrays), "declare each new column") + clash = set(arrays) & set(support.arrays) + _require(not clash, f"columns already present: {sorted(clash)}") + rows = len(support.arrays["area"]) + _require( + all(isinstance(a, np.ndarray) and a.shape == (rows,) for a in arrays.values()), + "one value per area", + ) + metadata = { + **dict(support.metadata), + "columns": { + **{name: dict(c) for name, c in support.metadata["columns"].items()}, + **{name: dict(columns[name]) for name in columns}, + }, + } + merged = {name: np.asarray(array) for name, array in support.arrays.items()} + merged.update({name: np.asarray(array) for name, array in arrays.items()}) + return encode_atomic_support(metadata, merged) + + +def zero_mass_cells( + support: AtomicSupport, + *, + domains: Mapping[str, Sequence[str]], + levels: Sequence[Sequence[str]], + weights: Sequence[str], +) -> list[dict[str, object]]: + """Every constraint cell, at each fallback level, with no sampling mass. + + ``levels`` lists the constraint columns of each fallback level, in order; + ``domains`` gives every value a household may carry for each column, so a + combination the support never shows is listed too. Each entry names the + level's columns, a weight column and the cells (value tuples, in domain + order) whose summed weight is zero. + """ + columns = support.metadata["columns"] + _require( + all(columns.get(w, {}).get("kind") == "weight" for w in weights) + and bool(weights), + "weights must be support weight columns", + ) + table = [] + for level in levels: + level = tuple(level) + _require( + bool(level) + and all(columns.get(c, {}).get("kind") == "code" for c in level) + and all(c in domains and len(domains[c]) for c in level), + "each level needs code columns with declared domains", + ) + frame = pd.DataFrame( + { + **{c: np.asarray(support.arrays[c]) for c in level}, + **{w: np.asarray(support.arrays[w], dtype=np.int64) for w in weights}, + } + ) + mass = frame.groupby(list(level), sort=False)[list(weights)].sum() + cells = list(itertools.product(*(tuple(domains[c]) for c in level))) + for weight in weights: + empty = [] + for cell in cells: + key = cell if len(level) > 1 else cell[0] + if int(mass[weight].get(key, 0)) == 0: + empty.append(list(cell)) + table.append({"constraints": list(level), "weight": weight, "cells": empty}) + return table diff --git a/packages/microcosm-build/src/microcosm/build/spec_engine/schema/spine.schema.json b/packages/microcosm-build/src/microcosm/build/spec_engine/schema/spine.schema.json index 251360cf95..c659da2006 100644 --- a/packages/microcosm-build/src/microcosm/build/spec_engine/schema/spine.schema.json +++ b/packages/microcosm-build/src/microcosm/build/spec_engine/schema/spine.schema.json @@ -48,6 +48,14 @@ }, "observed_geography": { "$ref": "defs.schema.json#/$defs/identifier" + }, + "observed_constraints": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "$ref": "defs.schema.json#/$defs/identifier" + } } } } diff --git a/packages/microcosm-build/src/microcosm/build/uk/country_package.json b/packages/microcosm-build/src/microcosm/build/uk/country_package.json index cc6b45ab8f..c0835ebaeb 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/country_package.json +++ b/packages/microcosm-build/src/microcosm/build/uk/country_package.json @@ -497,6 +497,11 @@ "kind": "legacy_json", "schema_id": "legacy_json" }, + { + "path": "uk_atomic_area_conditioned_supports.provenance.json", + "kind": "legacy_json", + "schema_id": "legacy_json" + }, { "path": "target_references.json", "kind": "legacy_json", diff --git a/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml b/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml index c6b2716a93..73cf1d441d 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml +++ b/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml @@ -181,6 +181,63 @@ sources: - id: uk_dea_2014 kind: geography_vintage value: 2014_dea +- id: uk_ew_output_area_2021_conditioned_support + role: uk_atomic_area_conditioned_support + sha256: 0b0f80ea6be84ffbede290e0bcb71c82fbf8c7574658583e0be896ce426f1ea8 + byte_size: 6357835 + loader: kernel:load_uk_atomic_area_support + vintages: + - vintage:uk_oa_2021 + - vintage:uk_lad_2023 + - vintage:uk_rgn_2024 + - vintage:uk_pcon_2024 + - vintage:uk_wd_2024 + - vintage:uk_itl_2025 + - vintage:uk_iod_wimd_2019 + - vintage:uk_ctsop_2025 + vintage_authorities: + - id: uk_iod_wimd_2019 + kind: geography_vintage + value: 2019_iod_wimd + - id: uk_ctsop_2025 + kind: geography_vintage + value: 2025_ctsop +- id: uk_scotland_output_area_2022_conditioned_support + role: uk_atomic_area_conditioned_support + sha256: 648e1a88dce6ad246aca5d09c9209f82646f48d0c3f4778955b51dcae907941a + byte_size: 1028754 + loader: kernel:load_uk_atomic_area_support + vintages: + - vintage:uk_oa_2022 + - vintage:uk_ca_2019 + - vintage:uk_scotland_ew_2022 + - vintage:uk_pcon_2024 + - vintage:uk_itl_2025 + - vintage:uk_simd_2020v2 + - vintage:uk_ctaxbase_2025 + vintage_authorities: + - id: uk_simd_2020v2 + kind: geography_vintage + value: 2020v2_simd + - id: uk_ctaxbase_2025 + kind: geography_vintage + value: 2025_ctaxbase +- id: uk_ni_data_zone_2021_conditioned_support + role: uk_atomic_area_conditioned_support + sha256: 6d71f2a98f26f80d80a4671b7e37389dd92f8ff9b9a02ee35c09819763b3b450 + byte_size: 47473 + loader: kernel:load_uk_atomic_area_support + vintages: + - vintage:uk_dz_2021 + - vintage:uk_lgd_2014 + - vintage:uk_dea_2014 + - vintage:uk_pcon_2024 + - vintage:uk_itl_2025 + - vintage:uk_nimdm_2017 + vintage_authorities: + - id: uk_nimdm_2017 + kind: geography_vintage + value: 2017_nimdm_soa stage_manifest: version: 1 country: uk diff --git a/packages/microcosm-build/src/microcosm/build/uk/spec/spine.yaml b/packages/microcosm-build/src/microcosm/build/uk/spec/spine.yaml index 1cbfb84763..dc472abcfe 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/spec/spine.yaml +++ b/packages/microcosm-build/src/microcosm/build/uk/spec/spine.yaml @@ -17,6 +17,8 @@ channels: - frs_penprov - frs_pension observed_geography: region + observed_constraints: + - imd_decile assembly: mass_anchor_channel: frs shared_dtype_policy: canonical_string_storage diff --git a/packages/microcosm-build/src/microcosm/build/uk/spec/vintages.yaml b/packages/microcosm-build/src/microcosm/build/uk/spec/vintages.yaml index 02b30c8c44..60eb76119f 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/spec/vintages.yaml +++ b/packages/microcosm-build/src/microcosm/build/uk/spec/vintages.yaml @@ -21,16 +21,67 @@ records: source: source:uk_scotland_output_area_2022_support authority: uk_ca_2019 compatible_with: + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 + - vintage:uk_wd_2024 +- id: uk_ctaxbase_2025 + kind: geography_vintage_ref + authority_ref: + kind: source_record + source: source:uk_scotland_output_area_2022_conditioned_support + authority: uk_ctaxbase_2025 + compatible_with: + - vintage:uk_ca_2019 + - vintage:uk_ctsop_2025 + - vintage:uk_dea_2014 + - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 + - vintage:uk_itl_2025 + - vintage:uk_lad_2023 + - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 + - vintage:uk_oa_2021 + - vintage:uk_oa_2022 + - vintage:uk_pcon_2024 + - vintage:uk_rgn_2024 + - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 + - vintage:uk_wd_2024 +- id: uk_ctsop_2025 + kind: geography_vintage_ref + authority_ref: + kind: source_record + source: source:uk_ew_output_area_2021_conditioned_support + authority: uk_ctsop_2025 + compatible_with: + - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_dea_2014 + - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 + - vintage:uk_itl_2025 + - vintage:uk_lad_2023 + - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 + - vintage:uk_oa_2021 + - vintage:uk_oa_2022 + - vintage:uk_pcon_2024 + - vintage:uk_rgn_2024 + - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 - vintage:uk_wd_2024 - id: uk_dea_2014 kind: geography_vintage_ref @@ -40,15 +91,20 @@ records: authority: uk_dea_2014 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 - vintage:uk_wd_2024 - id: uk_dz_2021 kind: geography_vintage_ref @@ -58,15 +114,43 @@ records: authority: uk_dz_2021 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 + - vintage:uk_dea_2014 + - vintage:uk_iod_wimd_2019 + - vintage:uk_itl_2025 + - vintage:uk_lad_2023 + - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 + - vintage:uk_oa_2021 + - vintage:uk_oa_2022 + - vintage:uk_pcon_2024 + - vintage:uk_rgn_2024 + - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 + - vintage:uk_wd_2024 +- id: uk_iod_wimd_2019 + kind: geography_vintage_ref + authority_ref: + kind: source_record + source: source:uk_ew_output_area_2021_conditioned_support + authority: uk_iod_wimd_2019 + compatible_with: + - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 + - vintage:uk_dz_2021 - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 - vintage:uk_wd_2024 - id: uk_itl_2025 kind: geography_vintage_ref @@ -76,15 +160,20 @@ records: authority: uk_itl_2025 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 - vintage:uk_wd_2024 - id: uk_lad_2023 kind: geography_vintage_ref @@ -94,15 +183,20 @@ records: authority: uk_lad_2023 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_itl_2025 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 - vintage:uk_wd_2024 - id: uk_lgd_2014 kind: geography_vintage_ref @@ -112,15 +206,43 @@ records: authority: uk_lgd_2014 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 + - vintage:uk_dea_2014 + - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 + - vintage:uk_itl_2025 + - vintage:uk_lad_2023 + - vintage:uk_nimdm_2017 + - vintage:uk_oa_2021 + - vintage:uk_oa_2022 + - vintage:uk_pcon_2024 + - vintage:uk_rgn_2024 + - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 + - vintage:uk_wd_2024 +- id: uk_nimdm_2017 + kind: geography_vintage_ref + authority_ref: + kind: source_record + source: source:uk_ni_data_zone_2021_conditioned_support + authority: uk_nimdm_2017 + compatible_with: + - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_itl_2025 - vintage:uk_lad_2023 + - vintage:uk_lgd_2014 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 - vintage:uk_wd_2024 - id: uk_oa_2021 kind: geography_vintage_ref @@ -130,15 +252,20 @@ records: authority: uk_oa_2021 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 - vintage:uk_wd_2024 - id: uk_oa_2022 kind: geography_vintage_ref @@ -148,15 +275,20 @@ records: authority: uk_oa_2022 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 - vintage:uk_wd_2024 - id: uk_pcon_2024 kind: geography_vintage_ref @@ -166,15 +298,20 @@ records: authority: uk_pcon_2024 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_rgn_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 - vintage:uk_wd_2024 - id: uk_rgn_2024 kind: geography_vintage_ref @@ -184,15 +321,20 @@ records: authority: uk_rgn_2024 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 - vintage:uk_wd_2024 - id: uk_scotland_ew_2022 kind: geography_vintage_ref @@ -202,15 +344,43 @@ records: authority: uk_scotland_ew_2022 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 + - vintage:uk_dea_2014 + - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 + - vintage:uk_itl_2025 + - vintage:uk_lad_2023 + - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 + - vintage:uk_oa_2021 + - vintage:uk_oa_2022 + - vintage:uk_pcon_2024 + - vintage:uk_rgn_2024 + - vintage:uk_simd_2020v2 + - vintage:uk_wd_2024 +- id: uk_simd_2020v2 + kind: geography_vintage_ref + authority_ref: + kind: source_record + source: source:uk_scotland_output_area_2022_conditioned_support + authority: uk_simd_2020v2 + compatible_with: + - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 + - vintage:uk_scotland_ew_2022 - vintage:uk_wd_2024 - id: uk_wd_2024 kind: geography_vintage_ref @@ -220,13 +390,18 @@ records: authority: uk_wd_2024 compatible_with: - vintage:uk_ca_2019 + - vintage:uk_ctaxbase_2025 + - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 diff --git a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json new file mode 100644 index 0000000000..ce71576a71 --- /dev/null +++ b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json @@ -0,0 +1,1068 @@ +{ + "band_weight_scale": 1000000, + "built_on": "2026-11-05", + "chronicle": { + "commit": "df468b8911efc54701326c5b528cfbf7650f92b5", + "merged": false, + "pull_request": "PolicyEngine/chronicle#413" + }, + "issues": { + "chronicle_registration": "PolicyEngine/chronicle#412", + "umbrella": "PolicyEngine/microcosm#931" + }, + "kind": "uk_atomic_area_conditioned_supports_provenance", + "notes": [ + "imd_decile is the 2019 vintage of each nation's index (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017): the FRS 2024-25 variables IMDE, IMDW, IMDS and IMDN carry no change note from 2023-24, which predates the 2025 indices, and on an internal comparison England's FRS decile shares by region fit IoD 2019 better than IoD 2025, as the 2023-24 FRS does. DWP has been asked to confirm.", + "An area's decile is the one most of its live small-user postcodes carry in the May 2026 NSPL (oa21cd: the 2021 output area in England and Wales, the 2022 output area in Scotland, the 2021 data zone in Northern Ireland). Ranks are within-nation only.", + "Northern Ireland's SOAs (2001) do not nest in its 2021 data zones, so many data zones' postcodes span deciles; the modal decile is recorded with relation inferred_modal and the counts below.", + "England and Wales band weights read each area's LSOA mix as committed (shares to 6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read its council's chargeable dwellings, rounded half to even per band." + ], + "publisher_files": { + "iod2019": { + "chronicle_package_id": "mhclg-english-indices-of-deprivation-2019-file-1", + "chronicle_source_id": "mhclg", + "chronicle_year": 2019, + "filename": "File_1_-_IMD2019_Index_of_Multiple_Deprivation.xlsx", + "product": "English indices of deprivation 2019, File 1: index of multiple deprivation", + "publisher": "MHCLG", + "sha256": "b95ca12952c3a8ebdb2e5c3bb03d5b0e56b76ede3fcf45205db26f280b912d9d", + "size_bytes": 1433347, + "url": "https://assets.publishing.service.gov.uk/media/5d8b3abded915d0373d3540f/File_1_-_IMD2019_Index_of_Multiple_Deprivation.xlsx" + }, + "nimdm2017": { + "chronicle_package_id": "nisra-nimdm-2017-soa-results", + "chronicle_source_id": "nisra", + "chronicle_year": 2017, + "filename": "NIMDM17_SOAresults.xls", + "product": "NIMDM 2017 results by Super Output Area", + "publisher": "NISRA", + "sha256": "3738edf2d264491301b41cc7b64967373d49b09a6f5719225a0e4f7d789af9d3", + "size_bytes": 1772032, + "url": "https://www.nisra.gov.uk/files/nisra/publications/NIMDM17_SOAresults.xls" + }, + "nspl": { + "chronicle_package_id": "ons-nspl-may-2026", + "chronicle_source_id": "ons", + "chronicle_year": 2026, + "filename": "NSPL_MAY_2026.zip", + "product": "National Statistics Postcode Lookup, May 2026", + "publisher": "ONS", + "sha256": "e0ccd5b3d90fdb537c29afc85b33c6c7ff8647e89e390f2e9ae48530f85f42c1", + "size_bytes": 187209017, + "url": "https://www.arcgis.com/sharing/rest/content/items/7668e0d35cab4f6db6f15f03be610fb0/data" + }, + "simd2020v2": { + "chronicle_package_id": "scotgov-simd-2020v2-data-zone-lookup", + "chronicle_source_id": "scotgov", + "chronicle_year": 2020, + "filename": "SIMD_2020v2_datazone_lookup_updated_2025.xlsx", + "product": "SIMD 2020v2 data zone lookup (updated 2025)", + "publisher": "Scottish Government", + "sha256": "0a64937af60fb339a1be85cd2f65b6a3d410a38dc5b6c7f25a72ba2d7060a03e", + "size_bytes": 1339239, + "url": "https://www.gov.scot/binaries/content/documents/govscot/publications/statistics/2020/01/scottish-index-of-multiple-deprivation-2020-data-zone-look-up-file/documents/scottish-index-of-multiple-deprivation-data-zone-look-up/scottish-index-of-multiple-deprivation-data-zone-look-up/govscot%3Adocument/SIMD%2B2020v2%2B-%2Bdatazone%2Blookup%2B-%2Bupdated%2B2025.xlsx" + }, + "wimd2019": { + "chronicle_package_id": "welshgov-wimd-2019-ranks-by-small-area", + "chronicle_source_id": "welshgov", + "chronicle_year": 2019, + "filename": "welsh-index-multiple-deprivation-2019-index-and-domain-ranks-by-small-area.ods", + "product": "WIMD 2019 index and domain ranks by small area", + "publisher": "Welsh Government", + "sha256": "2e7b65a3a276e31a10d4bf24a7d26e5cd9d2d95a796ab65e894fcd4e4b159430", + "size_bytes": 232940, + "url": "https://www.gov.wales/sites/default/files/statistics-and-research/2022-02/welsh-index-multiple-deprivation-2019-index-and-domain-ranks-by-small-area.ods" + } + }, + "resources": { + "scotgov_chargeable_dwellings_by_band.json": { + "as_at": "2025-09", + "publisher_file": "CTAXBASE_2025_Tables_Chargeable_Dwellings.xlsx", + "publisher_package": "scotgov-council-tax-bands-2025", + "publisher_sha256": "8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f", + "resource": "scotgov_chargeable_dwellings_by_band.json", + "sha256": "7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + }, + "voa_council_tax_band_mix_lsoa.json": { + "as_at": "2025-03-31", + "publisher_file": "CTSOP1.1.zip", + "publisher_package": "voa-council-tax-stock-by-lad-2025", + "publisher_sha256": "e1979a4196e23207489a6e049ddb10197cd127ab775be5828ee662743fe4fbe7", + "resource": "voa_council_tax_band_mix_lsoa.json", + "sha256": "0e2e5b37f500f2deaaf8bf4ca857b7ce6c6db3a5cc9d138f4e11992e07d9f498" + } + }, + "schema_version": 1, + "supports": { + "uk_ew_output_area_2021": { + "band_weights": { + "areas_with_rounding": 0, + "column_totals": { + "households_band_a": 5735445835501, + "households_band_b": 4886113564804, + "households_band_c": 5471412148929, + "households_band_d": 3897798904448, + "households_band_e": 2475397052263, + "households_band_f": 1319848671029, + "households_band_g": 860712399159, + "households_band_h": 132108737264, + "households_band_i": 4466686603 + }, + "largest_area_deviation": 0, + "rounding": "round_half_even", + "scale": 1000000, + "total_deviation": 0 + }, + "base": { + "sha256": "1b0dec268be0141f03ec05dc3b55c13733cc2bb20be5e403d76d73c8e27dc797", + "source": "uk_ew_output_area_2021_support" + }, + "column_metadata": { + "households_band_a": { + "basis": "census_2021_households_x_voa_ctsop1_1_2025_lsoa_band_a_share_6dp_x1e6", + "kind": "weight", + "source": "voa-council-tax-stock-by-lad-2025@sha256:e1979a4196e23207489a6e049ddb10197cd127ab775be5828ee662743fe4fbe7#voa_council_tax_band_mix_lsoa.json@sha256:0e2e5b37f500f2deaaf8bf4ca857b7ce6c6db3a5cc9d138f4e11992e07d9f498" + }, + "households_band_b": { + "basis": "census_2021_households_x_voa_ctsop1_1_2025_lsoa_band_b_share_6dp_x1e6", + "kind": "weight", + "source": "voa-council-tax-stock-by-lad-2025@sha256:e1979a4196e23207489a6e049ddb10197cd127ab775be5828ee662743fe4fbe7#voa_council_tax_band_mix_lsoa.json@sha256:0e2e5b37f500f2deaaf8bf4ca857b7ce6c6db3a5cc9d138f4e11992e07d9f498" + }, + "households_band_c": { + "basis": "census_2021_households_x_voa_ctsop1_1_2025_lsoa_band_c_share_6dp_x1e6", + "kind": "weight", + "source": "voa-council-tax-stock-by-lad-2025@sha256:e1979a4196e23207489a6e049ddb10197cd127ab775be5828ee662743fe4fbe7#voa_council_tax_band_mix_lsoa.json@sha256:0e2e5b37f500f2deaaf8bf4ca857b7ce6c6db3a5cc9d138f4e11992e07d9f498" + }, + "households_band_d": { + "basis": "census_2021_households_x_voa_ctsop1_1_2025_lsoa_band_d_share_6dp_x1e6", + "kind": "weight", + "source": "voa-council-tax-stock-by-lad-2025@sha256:e1979a4196e23207489a6e049ddb10197cd127ab775be5828ee662743fe4fbe7#voa_council_tax_band_mix_lsoa.json@sha256:0e2e5b37f500f2deaaf8bf4ca857b7ce6c6db3a5cc9d138f4e11992e07d9f498" + }, + "households_band_e": { + "basis": "census_2021_households_x_voa_ctsop1_1_2025_lsoa_band_e_share_6dp_x1e6", + "kind": "weight", + "source": "voa-council-tax-stock-by-lad-2025@sha256:e1979a4196e23207489a6e049ddb10197cd127ab775be5828ee662743fe4fbe7#voa_council_tax_band_mix_lsoa.json@sha256:0e2e5b37f500f2deaaf8bf4ca857b7ce6c6db3a5cc9d138f4e11992e07d9f498" + }, + "households_band_f": { + "basis": "census_2021_households_x_voa_ctsop1_1_2025_lsoa_band_f_share_6dp_x1e6", + "kind": "weight", + "source": "voa-council-tax-stock-by-lad-2025@sha256:e1979a4196e23207489a6e049ddb10197cd127ab775be5828ee662743fe4fbe7#voa_council_tax_band_mix_lsoa.json@sha256:0e2e5b37f500f2deaaf8bf4ca857b7ce6c6db3a5cc9d138f4e11992e07d9f498" + }, + "households_band_g": { + "basis": "census_2021_households_x_voa_ctsop1_1_2025_lsoa_band_g_share_6dp_x1e6", + "kind": "weight", + "source": "voa-council-tax-stock-by-lad-2025@sha256:e1979a4196e23207489a6e049ddb10197cd127ab775be5828ee662743fe4fbe7#voa_council_tax_band_mix_lsoa.json@sha256:0e2e5b37f500f2deaaf8bf4ca857b7ce6c6db3a5cc9d138f4e11992e07d9f498" + }, + "households_band_h": { + "basis": "census_2021_households_x_voa_ctsop1_1_2025_lsoa_band_h_share_6dp_x1e6", + "kind": "weight", + "source": "voa-council-tax-stock-by-lad-2025@sha256:e1979a4196e23207489a6e049ddb10197cd127ab775be5828ee662743fe4fbe7#voa_council_tax_band_mix_lsoa.json@sha256:0e2e5b37f500f2deaaf8bf4ca857b7ce6c6db3a5cc9d138f4e11992e07d9f498" + }, + "households_band_i": { + "basis": "census_2021_households_x_voa_ctsop1_1_2025_lsoa_band_i_share_6dp_x1e6", + "kind": "weight", + "source": "voa-council-tax-stock-by-lad-2025@sha256:e1979a4196e23207489a6e049ddb10197cd127ab775be5828ee662743fe4fbe7#voa_council_tax_band_mix_lsoa.json@sha256:0e2e5b37f500f2deaaf8bf4ca857b7ce6c6db3a5cc9d138f4e11992e07d9f498" + }, + "imd_decile": { + "kind": "code", + "relation": "inferred_modal", + "source": "ons-nspl-may-2026@sha256:e0ccd5b3d90fdb537c29afc85b33c6c7ff8647e89e390f2e9ae48530f85f42c1+mhclg-english-indices-of-deprivation-2019-file-1@sha256:b95ca12952c3a8ebdb2e5c3bb03d5b0e56b76ede3fcf45205db26f280b912d9d+welshgov-wimd-2019-ranks-by-small-area@sha256:2e7b65a3a276e31a10d4bf24a7d26e5cd9d2d95a796ab65e894fcd4e4b159430#modal-live-small-user-postcode", + "vintage": "2019_iod_wimd" + } + }, + "filename": "uk_ew_output_area_2021_conditioned_support.npz", + "households_by_imd_decile": { + "1": 2451219, + "10": 2329796, + "2": 2468558, + "3": 2517420, + "4": 2531210, + "5": 2520779, + "6": 2563141, + "7": 2492141, + "8": 2478349, + "9": 2430691 + }, + "imd_decile": { + "areas": 188880, + "areas_by_rule": { + "area": 188841, + "area_tie_parent": 4, + "parent": 35 + }, + "areas_whose_records_span_codes": 357, + "postcodes_in_areas": 1518234, + "postcodes_without_rank": 0, + "records": 1518234 + }, + "sha256": "0b0f80ea6be84ffbede290e0bcb71c82fbf8c7574658583e0be896ce426f1ea8", + "size_bytes": 6357835, + "zero_mass_cells": [ + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_a" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_b" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_c" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_d" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_e" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_f" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_g" + }, + { + "cells": [ + [ + "EAST_MIDLANDS", + "1" + ], + [ + "EAST_OF_ENGLAND", + "1" + ], + [ + "NORTH_EAST", + "2" + ], + [ + "NORTH_WEST", + "1" + ], + [ + "SOUTH_EAST", + "1" + ], + [ + "YORKSHIRE", + "1" + ], + [ + "YORKSHIRE", + "2" + ] + ], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_h" + }, + { + "cells": [ + [ + "EAST_MIDLANDS", + "1" + ], + [ + "EAST_MIDLANDS", + "2" + ], + [ + "EAST_MIDLANDS", + "3" + ], + [ + "EAST_MIDLANDS", + "4" + ], + [ + "EAST_MIDLANDS", + "5" + ], + [ + "EAST_MIDLANDS", + "6" + ], + [ + "EAST_MIDLANDS", + "7" + ], + [ + "EAST_MIDLANDS", + "8" + ], + [ + "EAST_MIDLANDS", + "9" + ], + [ + "EAST_MIDLANDS", + "10" + ], + [ + "EAST_OF_ENGLAND", + "1" + ], + [ + "EAST_OF_ENGLAND", + "2" + ], + [ + "EAST_OF_ENGLAND", + "3" + ], + [ + "EAST_OF_ENGLAND", + "4" + ], + [ + "EAST_OF_ENGLAND", + "5" + ], + [ + "EAST_OF_ENGLAND", + "6" + ], + [ + "EAST_OF_ENGLAND", + "7" + ], + [ + "EAST_OF_ENGLAND", + "8" + ], + [ + "EAST_OF_ENGLAND", + "9" + ], + [ + "EAST_OF_ENGLAND", + "10" + ], + [ + "LONDON", + "1" + ], + [ + "LONDON", + "2" + ], + [ + "LONDON", + "3" + ], + [ + "LONDON", + "4" + ], + [ + "LONDON", + "5" + ], + [ + "LONDON", + "6" + ], + [ + "LONDON", + "7" + ], + [ + "LONDON", + "8" + ], + [ + "LONDON", + "9" + ], + [ + "LONDON", + "10" + ], + [ + "NORTH_EAST", + "1" + ], + [ + "NORTH_EAST", + "2" + ], + [ + "NORTH_EAST", + "3" + ], + [ + "NORTH_EAST", + "4" + ], + [ + "NORTH_EAST", + "5" + ], + [ + "NORTH_EAST", + "6" + ], + [ + "NORTH_EAST", + "7" + ], + [ + "NORTH_EAST", + "8" + ], + [ + "NORTH_EAST", + "9" + ], + [ + "NORTH_EAST", + "10" + ], + [ + "NORTH_WEST", + "1" + ], + [ + "NORTH_WEST", + "2" + ], + [ + "NORTH_WEST", + "3" + ], + [ + "NORTH_WEST", + "4" + ], + [ + "NORTH_WEST", + "5" + ], + [ + "NORTH_WEST", + "6" + ], + [ + "NORTH_WEST", + "7" + ], + [ + "NORTH_WEST", + "8" + ], + [ + "NORTH_WEST", + "9" + ], + [ + "NORTH_WEST", + "10" + ], + [ + "SOUTH_EAST", + "1" + ], + [ + "SOUTH_EAST", + "2" + ], + [ + "SOUTH_EAST", + "3" + ], + [ + "SOUTH_EAST", + "4" + ], + [ + "SOUTH_EAST", + "5" + ], + [ + "SOUTH_EAST", + "6" + ], + [ + "SOUTH_EAST", + "7" + ], + [ + "SOUTH_EAST", + "8" + ], + [ + "SOUTH_EAST", + "9" + ], + [ + "SOUTH_EAST", + "10" + ], + [ + "SOUTH_WEST", + "1" + ], + [ + "SOUTH_WEST", + "2" + ], + [ + "SOUTH_WEST", + "3" + ], + [ + "SOUTH_WEST", + "4" + ], + [ + "SOUTH_WEST", + "5" + ], + [ + "SOUTH_WEST", + "6" + ], + [ + "SOUTH_WEST", + "7" + ], + [ + "SOUTH_WEST", + "8" + ], + [ + "SOUTH_WEST", + "9" + ], + [ + "SOUTH_WEST", + "10" + ], + [ + "WEST_MIDLANDS", + "1" + ], + [ + "WEST_MIDLANDS", + "2" + ], + [ + "WEST_MIDLANDS", + "3" + ], + [ + "WEST_MIDLANDS", + "4" + ], + [ + "WEST_MIDLANDS", + "5" + ], + [ + "WEST_MIDLANDS", + "6" + ], + [ + "WEST_MIDLANDS", + "7" + ], + [ + "WEST_MIDLANDS", + "8" + ], + [ + "WEST_MIDLANDS", + "9" + ], + [ + "WEST_MIDLANDS", + "10" + ], + [ + "YORKSHIRE", + "1" + ], + [ + "YORKSHIRE", + "2" + ], + [ + "YORKSHIRE", + "3" + ], + [ + "YORKSHIRE", + "4" + ], + [ + "YORKSHIRE", + "5" + ], + [ + "YORKSHIRE", + "6" + ], + [ + "YORKSHIRE", + "7" + ], + [ + "YORKSHIRE", + "8" + ], + [ + "YORKSHIRE", + "9" + ], + [ + "YORKSHIRE", + "10" + ] + ], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_i" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_a" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_b" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_c" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_d" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_e" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_f" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_g" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_h" + }, + { + "cells": [ + [ + "EAST_MIDLANDS" + ], + [ + "EAST_OF_ENGLAND" + ], + [ + "LONDON" + ], + [ + "NORTH_EAST" + ], + [ + "NORTH_WEST" + ], + [ + "SOUTH_EAST" + ], + [ + "SOUTH_WEST" + ], + [ + "WEST_MIDLANDS" + ], + [ + "YORKSHIRE" + ] + ], + "constraints": [ + "frs_region" + ], + "weight": "households_band_i" + } + ] + }, + "uk_ni_data_zone_2021": { + "band_weights": null, + "base": { + "sha256": "facb9923f589cb68eefa8fad37911e618b6137964ff58a231976ef62584b669f", + "source": "uk_ni_data_zone_2021_support" + }, + "column_metadata": { + "imd_decile": { + "kind": "code", + "relation": "inferred_modal", + "source": "ons-nspl-may-2026@sha256:e0ccd5b3d90fdb537c29afc85b33c6c7ff8647e89e390f2e9ae48530f85f42c1+nisra-nimdm-2017-soa-results@sha256:3738edf2d264491301b41cc7b64967373d49b09a6f5719225a0e4f7d789af9d3#modal-live-small-user-postcode", + "vintage": "2017_nimdm_soa" + } + }, + "filename": "uk_ni_data_zone_2021_conditioned_support.npz", + "households_by_imd_decile": { + "1": 75618, + "10": 71900, + "2": 81335, + "3": 75402, + "4": 81218, + "5": 77642, + "6": 76098, + "7": 80406, + "8": 75574, + "9": 73620 + }, + "imd_decile": { + "areas": 3780, + "areas_by_rule": { + "area": 3691, + "area_tie_order": 1, + "area_tie_parent": 88 + }, + "areas_whose_records_span_codes": 1607, + "postcodes_in_areas": 48276, + "postcodes_without_rank": 0, + "records": 48276 + }, + "sha256": "6d71f2a98f26f80d80a4671b7e37389dd92f8ff9b9a02ee35c09819763b3b450", + "size_bytes": 47473, + "zero_mass_cells": [ + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households" + } + ] + }, + "uk_scotland_output_area_2022": { + "band_weights": { + "areas_with_rounding": 24812, + "column_totals": { + "households_band_a": 477656371974, + "households_band_b": 558484112506, + "households_band_c": 407475622303, + "households_band_d": 353516527279, + "households_band_e": 350498043811, + "households_band_f": 211364523185, + "households_band_g": 135864913826, + "households_band_h": 13854884024 + }, + "largest_area_deviation": 3, + "rounding": "round_half_even", + "scale": 1000000, + "total_deviation": -1092 + }, + "base": { + "sha256": "1649fa831315e6fac80caa4af7f68e837fd985b7f59c2831bb0db8cbfeeee443", + "source": "uk_scotland_output_area_2022_support" + }, + "column_metadata": { + "households_band_a": { + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_a_share_round_half_even_x1e6", + "kind": "weight", + "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + }, + "households_band_b": { + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_b_share_round_half_even_x1e6", + "kind": "weight", + "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + }, + "households_band_c": { + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_c_share_round_half_even_x1e6", + "kind": "weight", + "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + }, + "households_band_d": { + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_d_share_round_half_even_x1e6", + "kind": "weight", + "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + }, + "households_band_e": { + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_e_share_round_half_even_x1e6", + "kind": "weight", + "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + }, + "households_band_f": { + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_f_share_round_half_even_x1e6", + "kind": "weight", + "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + }, + "households_band_g": { + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_g_share_round_half_even_x1e6", + "kind": "weight", + "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + }, + "households_band_h": { + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_h_share_round_half_even_x1e6", + "kind": "weight", + "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + }, + "imd_decile": { + "kind": "code", + "relation": "inferred_modal", + "source": "ons-nspl-may-2026@sha256:e0ccd5b3d90fdb537c29afc85b33c6c7ff8647e89e390f2e9ae48530f85f42c1+scotgov-simd-2020v2-data-zone-lookup@sha256:0a64937af60fb339a1be85cd2f65b6a3d410a38dc5b6c7f25a72ba2d7060a03e#modal-live-small-user-postcode", + "vintage": "2020v2_simd" + } + }, + "filename": "uk_scotland_output_area_2022_conditioned_support.npz", + "households_by_imd_decile": { + "1": 261091, + "10": 228333, + "2": 260145, + "3": 253334, + "4": 255698, + "5": 249831, + "6": 251195, + "7": 254221, + "8": 255818, + "9": 239049 + }, + "imd_decile": { + "areas": 46363, + "areas_by_rule": { + "area": 45780, + "area_tie_order": 5, + "area_tie_parent": 485, + "parent": 93 + }, + "areas_whose_records_span_codes": 2363, + "postcodes_in_areas": 156932, + "postcodes_without_rank": 0, + "records": 156932 + }, + "sha256": "648e1a88dce6ad246aca5d09c9209f82646f48d0c3f4778955b51dcae907941a", + "size_bytes": 1028754, + "zero_mass_cells": [ + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_a" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_b" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_c" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_d" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_e" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_f" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_g" + }, + { + "cells": [], + "constraints": [ + "frs_region", + "imd_decile" + ], + "weight": "households_band_h" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_a" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_b" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_c" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_d" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_e" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_f" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_g" + }, + { + "cells": [], + "constraints": [ + "frs_region" + ], + "weight": "households_band_h" + } + ] + } + }, + "tool": "tools/build_uk_conditioned_area_supports.py" +} diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/atomic_area_support.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/atomic_area_support.py index 8efeb97f2f..26a98b9eaa 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/atomic_area_support.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/atomic_area_support.py @@ -21,6 +21,7 @@ encode_atomic_support, validate_assignment_spec, ) +from microcosm.build.atomic_support_conditioning import extend_atomic_support from microcosm.build.uk_runtime.rowwise_geography import FRS_REGION_TO_REGION_CODE from microcosm.graph.canonical import canonical_json @@ -45,6 +46,23 @@ #: The committed provenance of the three support artifacts: per-column source #: and vintage of every derived layer, with the artifacts' digests. PROVENANCE_RESOURCE = "uk_atomic_area_supports.provenance.json" +#: The conditioned supports (microcosm#931): each system's support plus the +#: area's IMD decile and, where council tax is banded, its households by band. +#: Only the geography-first move binds them; today's build binds SOURCES. +CONDITIONED_SOURCES = {system: system + "_conditioned_support" for system in SYSTEMS} +CONDITIONED_PROVENANCE_RESOURCE = "uk_atomic_area_conditioned_supports.provenance.json" +#: The FRS records the deprivation tenth of each address within its own nation. +IMD_DECILE_COLUMN = "imd_decile" +IMD_DECILES = tuple(str(decile) for decile in range(1, 11)) +#: Households by council-tax band, times BAND_WEIGHT_SCALE: bands A to I in +#: England and Wales (only Wales has band I), A to H in Scotland. Northern +#: Ireland has domestic rates, so its support carries no band weights. +BAND_WEIGHT_SCALE = 10**6 +BAND_WEIGHT_COLUMNS = { + SYSTEMS[0]: tuple(f"households_band_{band}" for band in "abcdefghi"), + SYSTEMS[1]: tuple(f"households_band_{band}" for band in "abcdefgh"), + SYSTEMS[2]: (), +} def uk_area_code_frames() -> dict[str, dict[str, str]]: @@ -108,6 +126,10 @@ def without_uk_native_alias_columns(household): "itl3_code", ) _COUNT_COLUMNS = frozenset({"population", "households"}) +#: Every column of an unconditioned support, as the adapter normalizes it. +_SUPPORT_COLUMNS = frozenset( + {"area", *_INPUT_COLUMNS[1:], "frs_region", "itl1_code", "itl2_code"} +) _CODE = re.compile(r"[EWSN][0-9]{8}") _WARD = re.compile(r"[EWSN][0-9]{2}[0-9RS][0-9]{5}") _ITL = re.compile(r"TL[C-N][0-9A-Z]{2}") @@ -312,6 +334,147 @@ def assemble_uk_atomic_area_support( ) +def _canonical_support(system: str, support) -> bytes: + """Re-assemble a decoded support's adapter columns into canonical bytes.""" + arrays = { + column: support.arrays["area" if column == "oa_code" else column] + for column in _INPUT_COLUMNS + } + metadata = { + column: dict( + support.metadata["columns"]["area" if column == "oa_code" else column] + ) + for column in _INPUT_COLUMNS + } + return assemble_uk_atomic_area_support( + system=system, arrays=arrays, column_metadata=metadata + ) + + +def assemble_uk_conditioned_area_support( + *, + base: bytes, + imd_decile: np.ndarray, + band_weights: Mapping[str, np.ndarray], + column_metadata: Mapping, +) -> bytes: + """Add each area's IMD decile and households by band to a canonical support. + + ``base`` must be this adapter's canonical output for its system, the + support today's build binds. ``imd_decile`` gives each area, in support + order, its decile code within the nation. ``band_weights`` gives each of + the system's band columns (:data:`BAND_WEIGHT_COLUMNS`) the area's + households in that band times :data:`BAND_WEIGHT_SCALE`; an area's band + weights must sum to its households times the scale, up to half a unit + per band of rounding. English areas carry no band I. The caller states + every new column's source, vintage or basis, as for any support column. + """ + _require(type(base) is bytes, "immutable support bytes required") + support = decode_atomic_support(base) + system = support.metadata["system"] + _require(system in SYSTEMS, "unknown area system") + _require(set(support.arrays) == _SUPPORT_COLUMNS, "base is already conditioned") + _require( + _canonical_support(system, support) == base, + "base is not the canonical UK adapter output", + ) + bands = BAND_WEIGHT_COLUMNS[system] + _require( + type(column_metadata) is dict + and set(column_metadata) == {IMD_DECILE_COLUMN, *bands}, + "exact conditioning metadata required", + ) + for column, item in column_metadata.items(): + code = column == IMD_DECILE_COLUMN + _require( + type(item) is dict + and set(item) + == ( + {"kind", "source", "vintage", "relation"} + if code + else {"kind", "source", "basis"} + ) + and all(_text(value) for value in item.values()) + and item["kind"] == ("code" if code else "weight") + and (not code or item["relation"] in RELATIONS), + "conditioning column description", + ) + areas = len(support.arrays["area"]) + _require( + type(imd_decile) is np.ndarray + and imd_decile.dtype.kind == "U" + and imd_decile.shape == (areas,) + and set(imd_decile.tolist()) <= set(IMD_DECILES), + "one decile code, 1 to 10, per area", + ) + _require( + type(band_weights) is dict and set(band_weights) == set(bands), + "exact band weights required", + ) + weights = {} + for band in bands: + array = band_weights[band] + _require( + type(array) is np.ndarray + and array.dtype.kind in "iu" + and array.shape == (areas,) + and bool(np.all(array >= 0)), + "nonnegative integer band weights, one per area", + ) + weights[band] = array.astype(np.int64) + if bands: + households = [int(value) for value in support.arrays["households"]] + for row, count in enumerate(households): + split = sum(int(weights[band][row]) for band in bands) + _require( + 2 * abs(split - count * BAND_WEIGHT_SCALE) <= len(bands), + "band weights must split the area's households", + ) + if system == SYSTEMS[0]: + english = np.char.startswith(np.asarray(support.arrays["area"]), "E") + _require( + not np.any(weights["households_band_i"][english]), + "band I exists only in Wales", + ) + return extend_atomic_support( + base, + arrays={IMD_DECILE_COLUMN: imd_decile.copy(), **weights}, + columns={column: dict(item) for column, item in column_metadata.items()}, + ) + + +def uk_conditioned_support_base(payload: bytes) -> bytes: + """The canonical support a conditioned support extends. + + Refuses a payload that is not exactly what + :func:`assemble_uk_conditioned_area_support` makes of that base, so a + caller can hold a conditioned support to the registered support it adds to. + """ + _require(type(payload) is bytes, "immutable support bytes required") + support = decode_atomic_support(payload) + system = support.metadata["system"] + _require(system in SYSTEMS, "unknown area system") + extra = (IMD_DECILE_COLUMN, *BAND_WEIGHT_COLUMNS[system]) + _require( + set(support.arrays) == _SUPPORT_COLUMNS | set(extra), + "conditioned support columns differ", + ) + base = _canonical_support(system, support) + rebuilt = assemble_uk_conditioned_area_support( + base=base, + imd_decile=np.asarray(support.arrays[IMD_DECILE_COLUMN]).copy(), + band_weights={ + band: np.asarray(support.arrays[band]).copy() + for band in BAND_WEIGHT_COLUMNS[system] + }, + column_metadata={ + column: dict(support.metadata["columns"][column]) for column in extra + }, + ) + _require(rebuilt == payload, "support is not the canonical conditioned output") + return base + + def _layers(system: str) -> tuple[tuple[str, str], ...]: shared = tuple( (column, column) @@ -382,32 +545,12 @@ def uk_atomic_assignment_definition( ), "support system identity differs", ) - expected_columns = { - "area", - *(_INPUT_COLUMNS[1:]), - "frs_region", - "itl1_code", - "itl2_code", - } - _require(set(support.arrays) == expected_columns, "support columns differ") + _require(set(support.arrays) == _SUPPORT_COLUMNS, "support columns differ") # The declaration accepts this adapter's normalized form. This closes # forged derived aliases/region normalization without claiming source # authority from a self-consistent payload. - restored_arrays = { - column: support.arrays["area" if column == "oa_code" else column] - for column in _INPUT_COLUMNS - } - restored_metadata = { - column: dict( - support.metadata["columns"]["area" if column == "oa_code" else column] - ) - for column in _INPUT_COLUMNS - } _require( - assemble_uk_atomic_area_support( - system=system, arrays=restored_arrays, column_metadata=restored_metadata - ) - == supports[system], + _canonical_support(system, support) == supports[system], "support is not the canonical UK adapter output", ) systems.append( diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/country_adapter.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/country_adapter.py index 6f32d4fa93..fccd45770b 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/country_adapter.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/country_adapter.py @@ -58,30 +58,64 @@ def validate_uk_country_source_projection(spec: CountrySpec) -> None: for artifact in root.artifacts if artifact["role"] == "frs_table" ] - # The atomic-area supports (microcosm#932) are declared beside the raw FRS - # tables with their own role and loader; every other row is an FRS table. + # The atomic-area supports (microcosm#932) and their conditioned forms + # (microcosm#931) are declared beside the raw FRS tables with their own + # roles and loader; every other row is an FRS table. declared = [row for row in sources["sources"] if row["role"] == "frs_raw_table"] if declared != expected: raise ValueError( "UK country raw-source pins differ from the canonical FRS spine stage." ) + from .atomic_area_support import CONDITIONED_SOURCES, IMD_DECILE_COLUMN, SOURCES + + supports = { + "uk_atomic_area_support": SOURCES, + "uk_atomic_area_conditioned_support": CONDITIONED_SOURCES, + } others = [row for row in sources["sources"] if row["role"] != "frs_raw_table"] if any( - row["role"] != "uk_atomic_area_support" + row["role"] not in supports or row["loader"] != "kernel:load_uk_atomic_area_support" for row in others ): raise ValueError( "UK country sources beyond the raw FRS tables must be atomic-area supports." ) + by_id = {row["id"]: row for row in others} + if sorted(by_id) != sorted( + source for ids in supports.values() for source in ids.values() + ) or any( + by_id[source]["role"] != role + for role, ids in supports.items() + for source in ids.values() + ): + raise ValueError( + "UK atomic-area supports must be each system's support and its " + "conditioned form." + ) + # A conditioned support keeps its system's area vintages and adds the + # vintages of the columns it conditions on. + for system, source in SOURCES.items(): + if not set(by_id[source]["vintages"]) < set( + by_id[CONDITIONED_SOURCES[system]]["vintages"] + ): + raise ValueError( + f"The conditioned {system} support must extend its support's vintages." + ) + # The FRS records each address's region and IMD decile; the conditioned + # supports carry the decile the geography-first draw matches. if spine["channels"] != [ { "id": "frs", "source": [row["id"] for row in expected], "observed_geography": "region", + "observed_constraints": [IMD_DECILE_COLUMN], } ]: - raise ValueError("UK FRS channel must consume the declared raw FRS tables.") + raise ValueError( + "UK FRS channel must consume the declared raw FRS tables and observe " + "the region and the IMD decile." + ) if bundle["dataset_run"]["target_period"] != release.calibration_year: raise ValueError( "UK country target period differs from the FRS release calibration year." @@ -90,6 +124,8 @@ def validate_uk_country_source_projection(spec: CountrySpec) -> None: def uk_atomic_support_register( spec: CountrySpec | None = None, + *, + conditioned: bool = False, ) -> dict[str, dict[str, object]]: """The committed identity of each atomic-area support, by system. @@ -98,16 +134,23 @@ def uk_atomic_support_register( build on exactly these bytes, whatever digest the operator pinned on the command line; the dense release pre-flight reads the same register against the manifest's ``geography.assignment.support_pins``. + ``conditioned`` reads the conditioned supports (microcosm#931) instead, + which only the geography-first move binds. """ - from .atomic_area_support import SOURCES + from .atomic_area_support import CONDITIONED_SOURCES, SOURCES spec = load_country_spec("uk") if spec is None else spec if spec.resolved_spec is None: raise ValueError("The atomic-area support register needs a resolved UK spec.") + role, sources = ( + ("uk_atomic_area_conditioned_support", CONDITIONED_SOURCES) + if conditioned + else ("uk_atomic_area_support", SOURCES) + ) rows = spec.resolved_spec.resource("sources").domain.to_wire()["sources"] - by_id = {row["id"]: row for row in rows if row["role"] == "uk_atomic_area_support"} + by_id = {row["id"]: row for row in rows if row["role"] == role} register = {} - for system, source in SOURCES.items(): + for system, source in sources.items(): row = by_id.get(source) if row is None: raise ValueError( diff --git a/packages/microcosm-build/tests/engine_free/shared/test_atomic_support_conditioning.py b/packages/microcosm-build/tests/engine_free/shared/test_atomic_support_conditioning.py new file mode 100644 index 0000000000..15ac747096 --- /dev/null +++ b/packages/microcosm-build/tests/engine_free/shared/test_atomic_support_conditioning.py @@ -0,0 +1,307 @@ +"""The country-neutral columns a support carries for a conditioned draw.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from microcosm.build.atomic_geography import ( + assign_atomic, + decode_atomic_support, + encode_atomic_support, + validate_assignment_spec, +) +from microcosm.build.atomic_support_conditioning import ( + apportion_weights, + extend_atomic_support, + modal_area_codes, + zero_mass_cells, +) + +DOMAIN = ("1", "2", "3") + + +def _u(*values: str) -> np.ndarray: + return np.asarray(values, dtype="U") + + +def _support() -> bytes: + """Four areas in two regions, invented codes and counts.""" + code = {"kind": "code", "source": "invented", "vintage": "v1", "relation": "exact"} + return encode_atomic_support( + { + "version": 1, + "system": "toy", + "level": "area", + "code_system": "toy", + "vintage": "v1", + "columns": { + "area": code, + "region": code, + "households": { + "kind": "weight", + "source": "invented", + "basis": "count", + }, + }, + }, + { + "area": _u("a1", "a2", "b1", "b2"), + "region": _u("north", "north", "south", "south"), + "households": np.asarray([10, 30, 20, 0], dtype=np.int64), + }, + ) + + +def test_modal_codes_take_the_plurality_then_the_parent_then_the_order(): + areas = _u("a1", "a2", "a3", "b1") + parents = _u("A", "A", "A", "B") + records = { + "a1": ["2", "2", "1"], # own plurality + "a2": ["2", "3"], # tie broken by the parent's records (A: 3 twos) + # a3 has no record: it takes its parent's plurality + "b1": ["1", "2"], # tie the parent cannot break: domain order + } + record_areas = _u(*[area for area, codes in records.items() for _ in codes]) + record_codes = _u(*[code for codes in records.values() for code in codes]) + modal = modal_area_codes(areas, parents, record_areas, record_codes, domain=DOMAIN) + assert modal.codes.tolist() == ["2", "2", "2", "1"] + assert modal.rule.tolist() == [ + "area", + "area_tie_parent", + "parent", + "area_tie_order", + ] + assert modal.spanning.tolist() == [True, True, False, True] + assert modal.receipt() == { + "areas": 4, + "records": 7, + "areas_by_rule": { + "area": 1, + "area_tie_order": 1, + "area_tie_parent": 1, + "parent": 1, + }, + "areas_whose_records_span_codes": 3, + } + + +@pytest.mark.parametrize( + ("record_areas", "record_codes", "message"), + [ + (("a1", "zz"), ("1", "1"), "outside the support"), + (("a1", "a2"), ("1", "9"), "outside the domain"), + (("a2",), ("1",), "parent have no record"), + ], +) +def test_modal_codes_refuse_unknown_records_and_unsupported_areas( + record_areas, record_codes, message +): + with pytest.raises(ValueError, match=message): + modal_area_codes( + _u("a1", "a2"), + _u("A", "B"), + _u(*record_areas), + _u(*record_codes), + domain=DOMAIN, + ) + + +def test_apportioned_weights_are_exact_and_round_half_to_even(): + counts = np.asarray([3, 1, 0], dtype=np.int64) + numerators = { + "x": np.asarray([1, 1, 0], dtype=np.int64), + "y": np.asarray([1, 1, 0], dtype=np.int64), + } + denominators = np.asarray([2, 2, 0], dtype=np.int64) + weights, receipt = apportion_weights(counts, numerators, denominators, scale=1) + # 3 × 1/2 = 1.5 rounds to 2 (even) in both columns; 1 × 1/2 = 0.5 to 0. + assert weights["x"].tolist() == [2, 0, 0] + assert weights["y"].tolist() == [2, 0, 0] + assert receipt == { + "rounding": "round_half_even", + "scale": 1, + "areas_with_rounding": 2, + "largest_area_deviation": 1, + "total_deviation": 0, + "column_totals": {"x": 2, "y": 2}, + } + exact, receipt = apportion_weights(counts, numerators, denominators, scale=10) + assert exact["x"].tolist() == [15, 5, 0] + assert receipt["areas_with_rounding"] == 0 + + +@pytest.mark.parametrize( + ("numerators", "denominators", "message"), + [ + ({"x": [1], "y": [2]}, [2], "sum to a positive denominator"), + ({"x": [-1], "y": [3]}, [2], "nonnegative"), + ({"x": [1], "y": [1]}, [2, 2], "one denominator per area"), + ], +) +def test_apportioned_weights_refuse_shares_that_do_not_partition( + numerators, denominators, message +): + with pytest.raises(ValueError, match=message): + apportion_weights( + np.asarray([4], dtype=np.int64), + {k: np.asarray(v, dtype=np.int64) for k, v in numerators.items()}, + np.asarray(denominators, dtype=np.int64), + scale=1, + ) + + +def test_apportioned_weights_refuse_totals_beyond_exact_sampling(): + with pytest.raises(ValueError, match="exact sampling range"): + apportion_weights( + np.asarray([2**40], dtype=np.int64), + {"x": np.asarray([1], dtype=np.int64)}, + np.asarray([1], dtype=np.int64), + scale=2**20, + ) + + +def test_extended_support_keeps_its_columns_and_decodes(): + base = _support() + extended = extend_atomic_support( + base, + arrays={ + "decile": _u("1", "2", "1", "3"), + "households_x": np.asarray([5, 0, 20, 0], dtype=np.int64), + }, + columns={ + "decile": { + "kind": "code", + "source": "invented", + "vintage": "v2019", + "relation": "inferred_modal", + }, + "households_x": {"kind": "weight", "source": "invented", "basis": "x"}, + }, + ) + before, after = decode_atomic_support(base), decode_atomic_support(extended) + assert set(after.arrays) == {*before.arrays, "decile", "households_x"} + for name, array in before.arrays.items(): + assert np.array_equal(after.arrays[name], array) + with pytest.raises(ValueError, match="already present"): + extend_atomic_support( + base, + arrays={"households": np.zeros(4, dtype=np.int64)}, + columns={"households": {"kind": "weight", "source": "s", "basis": "b"}}, + ) + + +def test_zero_mass_cells_list_empty_and_absent_cells_at_each_level(): + extended = decode_atomic_support( + extend_atomic_support( + _support(), + arrays={ + "decile": _u("1", "2", "1", "3"), + "households_x": np.asarray([5, 0, 20, 0], dtype=np.int64), + }, + columns={ + "decile": { + "kind": "code", + "source": "invented", + "vintage": "v", + "relation": "exact", + }, + "households_x": {"kind": "weight", "source": "s", "basis": "b"}, + }, + ) + ) + table = zero_mass_cells( + extended, + domains={"region": ("north", "south"), "decile": DOMAIN}, + levels=(("region", "decile"), ("region",)), + weights=("households", "households_x"), + ) + assert table == [ + { + "constraints": ["region", "decile"], + "weight": "households", + # b2 (south, 3) has no households; (north, 3) and (south, 2) are absent. + "cells": [["north", "3"], ["south", "2"], ["south", "3"]], + }, + { + "constraints": ["region", "decile"], + "weight": "households_x", + "cells": [["north", "2"], ["north", "3"], ["south", "2"], ["south", "3"]], + }, + {"constraints": ["region"], "weight": "households", "cells": []}, + {"constraints": ["region"], "weight": "households_x", "cells": []}, + ] + + +def test_the_shared_operator_draws_on_the_added_columns(): + """An added code column is an exact-match constraint and an added weight + column is a weight_by choice: the operator needs nothing else.""" + import pandas as pd + + extended = extend_atomic_support( + _support(), + arrays={ + "decile": _u("1", "2", "1", "2"), + "households_x": np.asarray([0, 7, 5, 0], dtype=np.int64), + }, + columns={ + "decile": { + "kind": "code", + "source": "s", + "vintage": "v", + "relation": "exact", + }, + "households_x": {"kind": "weight", "source": "s", "basis": "b"}, + }, + ) + spec = validate_assignment_spec( + { + "version": 1, + "identity": ["key"], + "stream": ["sha256-u53-v1", "toy", 0, 1], + "outputs": { + "area": "area_code", + "system": "area_system", + "basis": "area_basis", + }, + "systems": [ + { + "id": "toy", + "level": "area", + "code_system": "toy", + "vintage": "v1", + "source": "toy_support", + "selector": {"region": ["north", "south"]}, + "constraints": [ + {"input": "region", "support": "region", "required": True}, + {"input": "decile", "support": "decile", "required": False}, + ], + "observed_area": None, + "stages": [ + { + "level": "area", + "weight_by": { + "input": "band", + "map": {"x": "households_x"}, + "default": "households", + }, + } + ], + "layers": [], + } + ], + } + ) + households = pd.DataFrame( + { + "key": ["h1", "h2", "h3"], + "region": ["north", "south", "north"], + "decile": ["2", "1", pd.NA], + "band": ["x", "x", pd.NA], + } + ) + assigned = assign_atomic(households, spec, {"toy": decode_atomic_support(extended)}) + # h1 can only be a2 (north, decile 2, band x); h2 only b1; h3 any northern + # area with households. + assert assigned["area_code"].tolist()[:2] == ["a2", "b1"] + assert assigned["area_code"].tolist()[2] in {"a1", "a2"} diff --git a/packages/microcosm-build/tests/engine_free/shared/test_country_spec.py b/packages/microcosm-build/tests/engine_free/shared/test_country_spec.py index 030b08e056..f395a49891 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_country_spec.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_country_spec.py @@ -1159,6 +1159,7 @@ def test_spi_spine_adds_no_country_package_resources(self) -> None: "local_area_crosswalk.json", "local_authority_names.json", "uk_atomic_area_supports.provenance.json", + "uk_atomic_area_conditioned_supports.provenance.json", "target_references.json", "target_reference_membership.json", "local_target_references.json", @@ -1345,6 +1346,7 @@ def test_uk_package_loads(self) -> None: "local_area_crosswalk.json", "local_authority_names.json", "uk_atomic_area_supports.provenance.json", + "uk_atomic_area_conditioned_supports.provenance.json", "target_references.json", "target_reference_membership.json", "local_target_references.json", diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py new file mode 100644 index 0000000000..1b2ed159a7 --- /dev/null +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py @@ -0,0 +1,408 @@ +"""The UK conditioned atomic-area supports (microcosm#931). + +Each extends the registered support of its system with the area's IMD +decile and, where council tax is banded, its households by band; only the +geography-first move binds them. The committed provenance, ``sources.yaml`` +and ``vintages.yaml`` must agree; when the support bytes are mounted under +``build/uk/supports``, the last tests check them against all three. +""" + +from __future__ import annotations + +import hashlib +import json +import re + +import numpy as np +import pandas as pd +import pytest + +from microcosm.build.atomic_geography import ( + decode_atomic_support, + encode_atomic_support, +) +from microcosm.build.atomic_support_conditioning import ( + apportion_weights, + zero_mass_cells, +) +from microcosm.build.spec_engine import load_bundle +from microcosm.build.spec_engine.compiler_ir import compile_spec +from microcosm.build.uk_runtime.atomic_area_support import ( + BAND_WEIGHT_COLUMNS, + BAND_WEIGHT_SCALE, + CONDITIONED_PROVENANCE_RESOURCE, + CONDITIONED_SOURCES, + IMD_DECILE_COLUMN, + IMD_DECILES, + SOURCES, + SYSTEMS, + assemble_uk_conditioned_area_support, + uk_conditioned_support_base, +) +from microcosm.build.uk_runtime.country_adapter import uk_atomic_support_register +from test_support.microcosm_build.uk_atomic_support_fixtures import toy_support_payloads +from test_support.paths import paths_for + +EW, SCOT, NI = SYSTEMS +_TEST_PATHS = paths_for("microcosm-build") +_UK = _TEST_PATHS.package / "src/microcosm/build/uk" +_REPOSITORY = _TEST_PATHS.repository +_SHA = re.compile(r"[0-9a-f]{64}") +#: The vintage authorities each conditioned support adds to its base's. +CONDITIONING_VINTAGES = { + EW: {"uk_iod_wimd_2019": "2019_iod_wimd", "uk_ctsop_2025": "2025_ctsop"}, + SCOT: {"uk_simd_2020v2": "2020v2_simd", "uk_ctaxbase_2025": "2025_ctaxbase"}, + NI: {"uk_nimdm_2017": "2017_nimdm_soa"}, +} +#: The authority behind each system's decile column. +DECILE_VINTAGE = {EW: "uk_iod_wimd_2019", SCOT: "uk_simd_2020v2", NI: "uk_nimdm_2017"} + + +def _metadata(system: str) -> dict: + metadata = { + IMD_DECILE_COLUMN: { + "kind": "code", + "source": "invented@sha256:" + "0" * 64, + "vintage": "invented_2019", + "relation": "inferred_modal", + } + } + for column in BAND_WEIGHT_COLUMNS[system]: + metadata[column] = {"kind": "weight", "source": "invented", "basis": "invented"} + return metadata + + +def _inputs(system: str, payload: bytes) -> tuple[np.ndarray, dict[str, np.ndarray]]: + """Invented deciles, and each area's households spread evenly over its bands.""" + support = decode_atomic_support(payload) + areas = np.asarray(support.arrays["area"]) + deciles = np.asarray([IMD_DECILES[i % 10] for i in range(len(areas))], dtype="U") + bands = BAND_WEIGHT_COLUMNS[system] + if not bands: + return deciles, {} + numerators = {column: np.ones(len(areas), dtype=np.int64) for column in bands} + if system == EW: + english = np.char.startswith(areas, "E") + numerators["households_band_i"] = np.where(english, 0, 1).astype(np.int64) + weights, _ = apportion_weights( + np.asarray(support.arrays["households"], dtype=np.int64), + numerators, + sum(numerators.values()), + scale=BAND_WEIGHT_SCALE, + ) + return deciles, weights + + +@pytest.fixture(scope="module") +def toys() -> dict[str, bytes]: + return toy_support_payloads() + + +@pytest.mark.parametrize("system", SYSTEMS) +def test_conditioned_support_extends_its_canonical_base(toys, system) -> None: + deciles, weights = _inputs(system, toys[system]) + payload = assemble_uk_conditioned_area_support( + base=toys[system], + imd_decile=deciles, + band_weights=weights, + column_metadata=_metadata(system), + ) + assert uk_conditioned_support_base(payload) == toys[system] + support, base = decode_atomic_support(payload), decode_atomic_support(toys[system]) + assert set(support.arrays) - set(base.arrays) == { + IMD_DECILE_COLUMN, + *BAND_WEIGHT_COLUMNS[system], + } + for column, array in base.arrays.items(): + assert np.array_equal(support.arrays[column], array) + assert support.arrays[IMD_DECILE_COLUMN].tolist() == deciles.tolist() + # Northern Ireland has domestic rates: its support carries no band weights. + assert bool(BAND_WEIGHT_COLUMNS[system]) is (system != NI) + + +def _defect(system: str, defect: str, toys: dict[str, bytes]): + deciles, weights = _inputs(system, toys[system]) + metadata = _metadata(system) + base = toys[system] + if defect == "conditioned_base": + base = assemble_uk_conditioned_area_support( + base=base, + imd_decile=deciles, + band_weights=weights, + column_metadata=metadata, + ) + elif defect == "decile_code": + deciles = deciles.copy() + deciles[0] = "11" + elif defect == "missing_band": + weights.pop("households_band_i") + elif defect == "english_band_i": + weights["households_band_i"] = weights["households_band_i"].copy() + english = int( + np.flatnonzero( + np.char.startswith(decode_atomic_support(base).arrays["area"], "E") + )[0] + ) + weights["households_band_i"][english] = 1 + weights["households_band_b"][english] -= 1 + elif defect == "unsplit_households": + weights["households_band_b"] = weights["households_band_b"] + 10 + elif defect == "decile_metadata": + metadata[IMD_DECILE_COLUMN] = {**metadata[IMD_DECILE_COLUMN], "kind": "weight"} + elif defect == "float_weights": + weights["households_band_a"] = weights["households_band_a"].astype(np.float64) + return base, deciles, weights, metadata + + +@pytest.mark.parametrize( + ("defect", "message"), + [ + ("conditioned_base", "already conditioned"), + ("decile_code", "decile code"), + ("missing_band", "exact band weights"), + ("english_band_i", "band I exists only in Wales"), + ("unsplit_households", "split the area's households"), + ("decile_metadata", "conditioning column description"), + ("float_weights", "nonnegative integer band weights"), + ], +) +def test_conditioned_assembler_refuses_defects(toys, defect, message) -> None: + base, deciles, weights, metadata = _defect(EW, defect, toys) + with pytest.raises(ValueError, match=message): + assemble_uk_conditioned_area_support( + base=base, + imd_decile=deciles, + band_weights=weights, + column_metadata=metadata, + ) + + +def test_conditioned_base_refuses_a_forged_or_foreign_column(toys) -> None: + deciles, weights = _inputs(SCOT, toys[SCOT]) + payload = assemble_uk_conditioned_area_support( + base=toys[SCOT], + imd_decile=deciles, + band_weights=weights, + column_metadata=_metadata(SCOT), + ) + support = decode_atomic_support(payload) + columns = {name: dict(c) for name, c in support.metadata["columns"].items()} + arrays = {name: np.asarray(a) for name, a in support.arrays.items()} + columns["households_band_i"] = dict(columns["households_band_a"]) + arrays["households_band_i"] = arrays["households_band_a"].copy() + forged = encode_atomic_support( + {**dict(support.metadata), "columns": columns}, arrays + ) + with pytest.raises(ValueError, match="conditioned support columns differ"): + uk_conditioned_support_base(forged) + with pytest.raises(ValueError, match="conditioned support columns differ"): + uk_conditioned_support_base(toys[SCOT]) + + +@pytest.fixture(scope="module") +def provenance() -> dict: + return json.loads( + (_UK / CONDITIONED_PROVENANCE_RESOURCE).read_text(encoding="utf-8") + ) + + +@pytest.fixture(scope="module") +def bundle(): + return compile_spec(load_bundle("uk")) + + +def test_provenance_pins_chronicle_registrations_and_resources(provenance) -> None: + import importlib.util + + path = _REPOSITORY / "tools/build_uk_conditioned_area_supports.py" + spec = importlib.util.spec_from_file_location("uk_conditioned_tool_pins", path) + tool = importlib.util.module_from_spec(spec) + spec.loader.exec_module(tool) + assert provenance["kind"] == "uk_atomic_area_conditioned_supports_provenance" + assert provenance["publisher_files"] == tool.SOURCES + assert provenance["chronicle"] == tool.CHRONICLE + assert ( + provenance["issues"]["chronicle_registration"] == "PolicyEngine/chronicle#412" + ) + assert provenance["band_weight_scale"] == BAND_WEIGHT_SCALE + for name, resource in provenance["resources"].items(): + # A regenerated band mix must regenerate the conditioned supports. + assert ( + resource["sha256"] == hashlib.sha256((_UK / name).read_bytes()).hexdigest() + ) + assert _SHA.fullmatch(resource["publisher_sha256"]) + + +@pytest.mark.parametrize("system", SYSTEMS) +def test_column_metadata_names_every_input_and_its_vintage(provenance, system) -> None: + entry = provenance["supports"][system] + files = provenance["publisher_files"] + decile = entry["column_metadata"][IMD_DECILE_COLUMN] + assert decile["kind"] == "code" and decile["relation"] == "inferred_modal" + tags = decile["source"].split("#")[0].split("+") + sha_by_package = { + row["chronicle_package_id"]: row["sha256"] for row in files.values() + } + assert tags[0].startswith("ons-nspl-may-2026@sha256:") + for tag in tags: + package, _, digest = tag.partition("@sha256:") + assert sha_by_package[package] == digest + assert decile["vintage"] in CONDITIONING_VINTAGES[system].values() + assert set(entry["column_metadata"]) == { + IMD_DECILE_COLUMN, + *BAND_WEIGHT_COLUMNS[system], + } + resources = provenance["resources"] + for column in BAND_WEIGHT_COLUMNS[system]: + item = entry["column_metadata"][column] + assert item["kind"] == "weight" and item["basis"].endswith("_x1e6") + publisher, _, resource = item["source"].partition("#") + name, _, digest = resource.partition("@sha256:") + assert resources[name]["sha256"] == digest + package, _, publisher_digest = publisher.partition("@sha256:") + assert ( + resources[name]["publisher_package"], + resources[name]["publisher_sha256"], + ) == ( + package, + publisher_digest, + ) + + +def test_spec_declares_the_conditioned_bytes_and_their_vintages( + provenance, bundle +) -> None: + sources = {row["id"]: row for row in bundle.resource("sources")["sources"]} + records = {row["id"]: row for row in bundle.resource("vintages")["records"]} + register = uk_atomic_support_register(conditioned=True) + for system in SYSTEMS: + row, base = sources[CONDITIONED_SOURCES[system]], sources[SOURCES[system]] + entry = provenance["supports"][system] + assert row["role"] == "uk_atomic_area_conditioned_support" + assert (row["sha256"], row["byte_size"]) == ( + entry["sha256"], + entry["size_bytes"], + ) + assert register[system] == { + "sha256": entry["sha256"], + "size_bytes": entry["size_bytes"], + } + assert entry["base"] == {"source": SOURCES[system], "sha256": base["sha256"]} + added = [ + v.removeprefix("vintage:") + for v in row["vintages"] + if v not in base["vintages"] + ] + assert row["vintages"][: len(base["vintages"])] == base["vintages"] + assert { + a["id"]: a["value"] for a in row["vintage_authorities"] + } == CONDITIONING_VINTAGES[system] + assert added == list(CONDITIONING_VINTAGES[system]) + for vintage_id in added: + record = records[vintage_id] + assert record["kind"] == "geography_vintage_ref" + assert record["authority_ref"] == { + "kind": "source_record", + "source": f"source:{CONDITIONED_SOURCES[system]}", + "authority": vintage_id, + } + assert ( + entry["column_metadata"][IMD_DECILE_COLUMN]["vintage"] + == CONDITIONING_VINTAGES[system][DECILE_VINTAGE[system]] + ) + + +def test_receipts_count_areas_and_households_only(provenance) -> None: + base = json.loads((_UK / "uk_atomic_area_supports.provenance.json").read_text()) + for system in SYSTEMS: + entry = provenance["supports"][system] + receipt = entry["imd_decile"] + assert receipt["areas"] == base["supports"][system]["areas"] + assert sum(receipt["areas_by_rule"].values()) == receipt["areas"] + assert set(entry["households_by_imd_decile"]) == set(IMD_DECILES) + assert ( + sum(entry["households_by_imd_decile"].values()) + == base["supports"][system]["households_total"] + ) + levels = [ + (tuple(e["constraints"]), e["weight"]) for e in entry["zero_mass_cells"] + ] + assert levels == [ + (level, weight) + for level in (("frs_region", IMD_DECILE_COLUMN), ("frs_region",)) + for weight in ("households", *BAND_WEIGHT_COLUMNS[system]) + ] + bands = entry["band_weights"] + if system == NI: + assert bands is None + continue + assert set(bands["column_totals"]) == set(BAND_WEIGHT_COLUMNS[system]) + # Half a unit per band at most, of households × 10^6. + assert 2 * bands["largest_area_deviation"] <= len(BAND_WEIGHT_COLUMNS[system]) + if system == EW: + assert bands["areas_with_rounding"] == 0 + + +def _mounted(system: str) -> bytes: + path = _REPOSITORY / "build/uk/supports" / f"{CONDITIONED_SOURCES[system]}.npz" + if not path.is_file(): + pytest.skip(f"{path.name} is not mounted under build/uk/supports") + return path.read_bytes() + + +@pytest.mark.parametrize("system", SYSTEMS) +def test_mounted_conditioned_support_extends_the_registered_support( + provenance, system +) -> None: + payload = _mounted(system) + entry = provenance["supports"][system] + assert hashlib.sha256(payload).hexdigest() == entry["sha256"] + assert len(payload) == entry["size_bytes"] + base = uk_conditioned_support_base(payload) + assert ( + hashlib.sha256(base).hexdigest() + == uk_atomic_support_register()[system]["sha256"] + ) + support = decode_atomic_support(payload) + assert { + c: dict(support.metadata["columns"][c]) for c in entry["column_metadata"] + } == entry["column_metadata"] + households = pd.Series(np.asarray(support.arrays["households"], dtype=np.int64)) + by_decile = households.groupby(np.asarray(support.arrays[IMD_DECILE_COLUMN])).sum() + assert {k: int(by_decile.get(k, 0)) for k in IMD_DECILES} == entry[ + "households_by_imd_decile" + ] + assert ( + zero_mass_cells( + support, + domains={ + "frs_region": sorted(set(support.arrays["frs_region"].tolist())), + IMD_DECILE_COLUMN: IMD_DECILES, + }, + levels=(("frs_region", IMD_DECILE_COLUMN), ("frs_region",)), + weights=("households", *BAND_WEIGHT_COLUMNS[system]), + ) + == entry["zero_mass_cells"] + ) + + +def test_mounted_scottish_band_weights_move_mass_only_between_councils( + provenance, +) -> None: + support = decode_atomic_support(_mounted(SCOT)) + frame = pd.DataFrame( + { + "council": np.asarray(support.arrays["local_authority_code"]), + "households": np.asarray(support.arrays["households"], dtype=np.int64), + **{ + c: np.asarray(support.arrays[c], dtype=np.int64) + for c in BAND_WEIGHT_COLUMNS[SCOT] + }, + } + ) + totals = frame.groupby("council").sum() + for column in BAND_WEIGHT_COLUMNS[SCOT]: + # Within a council every area holds the council's band share of its + # households, so its weight is that share times households, rounded. + share = frame["council"].map(totals[column] / totals["households"]) + assert np.all(np.abs(frame[column] - frame["households"] * share) <= 1.0) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py new file mode 100644 index 0000000000..b4ebaf2e1d --- /dev/null +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py @@ -0,0 +1,180 @@ +"""The UK conditioned-support tool on toy supports and invented inputs.""" + +from __future__ import annotations + +import hashlib +import importlib.util +import json +from collections import Counter + +import numpy as np +import pandas as pd +import pytest + +from microcosm.build.atomic_geography import decode_atomic_support +from microcosm.build.uk_runtime.atomic_area_support import ( + BAND_WEIGHT_COLUMNS, + BAND_WEIGHT_SCALE, + IMD_DECILE_COLUMN, + SYSTEMS, + uk_conditioned_support_base, +) +from test_support.microcosm_build.uk_atomic_support_fixtures import toy_support_payloads +from test_support.paths import paths_for + +EW, SCOT, NI = SYSTEMS + + +@pytest.fixture(scope="module") +def tool(): + path = ( + paths_for("microcosm-build").repository + / "tools/build_uk_conditioned_area_supports.py" + ) + spec = importlib.util.spec_from_file_location("uk_conditioned_tool_fixture", path) + assert spec is not None and spec.loader is not None + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def _invented_inputs(bases: dict[str, bytes]): + """Three postcodes per area, two of them at rank 1; band mixes per LSOA and council.""" + postcodes = [] + for payload in bases.values(): + for area in decode_atomic_support(payload).arrays["area"].tolist(): + postcodes += [(area, "1"), (area, "1"), (area, "2")] + frame = pd.DataFrame(postcodes, columns=["oa21cd", "imd20ind"]) + deciles = {nation: {1: "4", 2: "9"} for nation in "EWSN"} + ew = decode_atomic_support(bases[EW]) + lsoa = {} + for code in ew.arrays["lsoa_code"].tolist(): + # England: an eighth in each of bands A to H. Wales: a tenth in each of + # A to H and a fifth in band I. + cumulative = ( + [0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0, 1.0] + if code.startswith("E") + else [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0] + ) + lsoa[code] = {"all_properties": 40, "cumulative": cumulative} + voa = {"bands": list("ABCDEFGHI"), "lsoa": lsoa} + council = decode_atomic_support(bases[SCOT]).arrays["local_authority_code"][0] + scot = { + "rows": [ + { + "geography": {"id": str(council)}, + "measure_id": f"band_{band}", + "value": value, + } + for band, value in zip("abcdefgh", (1, 2, 1, 1, 1, 1, 1, 1), strict=True) + ] + } + resources = { + name: { + "resource": name, + "sha256": "1" * 64, + "publisher_package": "invented-package", + "publisher_sha256": "2" * 64, + } + for name in ( + "voa_council_tax_band_mix_lsoa.json", + "scotgov_chargeable_dwellings_by_band.json", + ) + } + return frame, deciles, voa, scot, resources + + +def test_tool_conditions_each_registered_support(tool) -> None: + bases = toy_support_payloads() + postcodes, deciles, voa, scot, resources = _invented_inputs(bases) + payloads, entries = tool.condition_supports( + bases, + postcodes, + deciles, + voa_mix=voa, + scotland_counts=scot, + resources=resources, + ) + for system in SYSTEMS: + assert uk_conditioned_support_base(payloads[system]) == bases[system] + support = decode_atomic_support(payloads[system]) + # Two of every area's three postcodes carry rank 1, decile 4. + assert set(support.arrays[IMD_DECILE_COLUMN].tolist()) == {"4"} + receipt = entries[system]["imd_decile"] + assert receipt["areas_by_rule"] == {"area": len(support.arrays["area"])} + assert receipt["areas_whose_records_span_codes"] == len(support.arrays["area"]) + households = np.asarray(support.arrays["households"], dtype=np.int64) + weights = { + c: np.asarray(support.arrays[c]) for c in BAND_WEIGHT_COLUMNS[system] + } + if system == EW: + english = np.char.startswith(np.asarray(support.arrays["area"]), "E") + assert np.array_equal( + weights["households_band_c"][english], households[english] * 125_000 + ) + assert not weights["households_band_i"][english].any() + assert np.array_equal( + weights["households_band_i"][~english], households[~english] * 200_000 + ) + if system == SCOT: + # A ninth in band A, rounded half to even. + ninth = [round(int(h) * BAND_WEIGHT_SCALE / 9) for h in households] + assert weights["households_band_a"].tolist() == ninth + if system == NI: + assert not weights and entries[system]["band_weights"] is None + + +def test_tool_refuses_a_rank_outside_its_nation_index(tool) -> None: + bases = toy_support_payloads() + postcodes, deciles, voa, scot, resources = _invented_inputs(bases) + postcodes.loc[0, "imd20ind"] = "77" + with pytest.raises(ValueError, match="not in the E index"): + tool.condition_supports( + bases, + postcodes, + deciles, + voa_mix=voa, + scotland_counts=scot, + resources=resources, + ) + + +def test_rank_deciles_refuse_a_split_tie_and_a_short_index(tool, monkeypatch) -> None: + monkeypatch.setitem(tool.INDEX_AREAS, "E", 3) + ok = tool._rank_deciles(pd.Series([1, 1, 3]), pd.Series([1, 1, 2]), nation="E") + assert ok == {1: "1", 3: "2"} + with pytest.raises(ValueError, match="no single decile"): + tool._rank_deciles(pd.Series([1, 1, 3]), pd.Series([1, 2, 2]), nation="E") + with pytest.raises(ValueError, match="expected 3"): + tool._rank_deciles(pd.Series([1, 2]), pd.Series([1, 2]), nation="E") + + +def test_northern_ireland_deciles_are_tenths_of_its_soas(tool) -> None: + deciles = tool._northern_ireland() + assert len(deciles) == 890 + assert Counter(deciles.values()) == {str(d): 89 for d in range(1, 11)} + assert (deciles[1], deciles[89], deciles[90], deciles[890]) == ("1", "1", "2", "10") + + +def test_pinned_sources_refuse_bytes_other_than_the_registration( + tool, tmp_path +) -> None: + rows = {} + for name, spec in tool.SOURCES.items(): + path = tmp_path / str(spec["filename"]) + path.write_bytes(name.encode()) + rows[name] = { + "path": str(path), + "url": spec["url"], + "sha256": spec["sha256"], + "bytes": spec["size_bytes"], + } + manifest = tmp_path / "manifest.json" + manifest.write_text(json.dumps({"schema_version": 1, "sources": rows})) + with pytest.raises(ValueError, match="identity mismatch"): + tool._pinned_sources(manifest) + real = tmp_path / str(tool.SOURCES["nspl"]["filename"]) + rows["nspl"]["sha256"] = hashlib.sha256(real.read_bytes()).hexdigest() + manifest.write_text(json.dumps({"schema_version": 1, "sources": rows})) + with pytest.raises(ValueError, match="differs from its registration"): + tool._pinned_sources(manifest) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_country_adapter.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_country_adapter.py index 4564401ab0..c1465c1c97 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_country_adapter.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_country_adapter.py @@ -21,25 +21,42 @@ def test_country_raw_source_projection_is_current(): assert {"frs_adult", "frs_benefits", "frs_child", "frs_househol"} <= { row["id"] for row in frs } - # The three atomic-area supports (microcosm#932) sit beside the FRS tables. - supports = [row for row in sources if row["role"] != "frs_raw_table"] - assert {row["id"] for row in supports} == { - "uk_ew_output_area_2021_support", - "uk_scotland_output_area_2022_support", - "uk_ni_data_zone_2021_support", + # The three atomic-area supports (microcosm#932) and their conditioned + # forms (microcosm#931) sit beside the FRS tables. + supports = { + row["id"]: row["role"] for row in sources if row["role"] != "frs_raw_table" + } + systems = ( + "uk_ew_output_area_2021", + "uk_scotland_output_area_2022", + "uk_ni_data_zone_2021", + ) + assert supports == { + **{f"{system}_support": "uk_atomic_area_support" for system in systems}, + **{ + f"{system}_conditioned_support": "uk_atomic_area_conditioned_support" + for system in systems + }, } assert all( - row["role"] == "uk_atomic_area_support" - and row["loader"] == "kernel:load_uk_atomic_area_support" - for row in supports + row["loader"] == "kernel:load_uk_atomic_area_support" + for row in sources + if row["id"] in supports ) assert "uk_national_candidate_2023" not in str(sources) + spine = spec.resolved_spec.resource("spine").domain.to_wire() + assert spine["channels"][0]["observed_constraints"] == ["imd_decile"] -def test_country_source_projection_refuses_divergent_header_pin(tmp_path): +def _copied_package(tmp_path): source = paths_for("microcosm-build").package / "src/microcosm/build/uk" destination = tmp_path / "uk" shutil.copytree(source, destination) + return destination + + +def test_country_source_projection_refuses_divergent_header_pin(tmp_path): + destination = _copied_package(tmp_path) path = destination / "spec/sources.yaml" text = path.read_text() first_sha = text.split(" sha256: ", 1)[1].splitlines()[0] @@ -49,6 +66,58 @@ def test_country_source_projection_refuses_divergent_header_pin(tmp_path): validate_uk_country_source_projection(spec) +def test_country_source_projection_refuses_a_spine_without_the_decile(tmp_path): + destination = _copied_package(tmp_path) + path = destination / "spec/spine.yaml" + text = path.read_text() + assert text.count(" observed_constraints:\n - imd_decile\n") == 1 + path.write_text(text.replace(" observed_constraints:\n - imd_decile\n", "")) + with pytest.raises(ValueError, match="observe the region and the IMD decile"): + validate_uk_country_source_projection(load_country_spec(destination)) + + +def test_country_source_projection_refuses_a_support_without_its_conditioned_form( + tmp_path, +): + destination = _copied_package(tmp_path) + path = destination / "spec/sources.yaml" + text = path.read_text() + renamed = text.replace( + "id: uk_ni_data_zone_2021_conditioned_support", + "id: uk_ni_data_zone_2021_other_support", + ) + assert renamed != text + path.write_text(renamed) + vintages = destination / "spec/vintages.yaml" + vintages.write_text( + vintages.read_text().replace( + "source:uk_ni_data_zone_2021_conditioned_support", + "source:uk_ni_data_zone_2021_other_support", + ) + ) + with pytest.raises(ValueError, match="each system's support and its conditioned"): + validate_uk_country_source_projection(load_country_spec(destination)) + + +def test_conditioned_support_register_is_the_committed_provenance(): + import json + + from microcosm.build.uk_runtime.atomic_area_support import SYSTEMS + + register = uk_atomic_support_register(conditioned=True) + assert tuple(register) == SYSTEMS + package = paths_for("microcosm-build").package / "src/microcosm/build/uk" + provenance = json.loads( + (package / "uk_atomic_area_conditioned_supports.provenance.json").read_text() + ) + base = uk_atomic_support_register() + for system, row in register.items(): + entry = provenance["supports"][system] + assert row == {"sha256": entry["sha256"], "size_bytes": entry["size_bytes"]} + assert entry["base"]["sha256"] == base[system]["sha256"] + assert row["sha256"] != base[system]["sha256"] + + def test_atomic_support_register_is_the_committed_provenance(): """The register a release candidate is checked against (microcosm#932 round 1) is sources.yaml's, and it agrees with the provenance resource.""" diff --git a/tools/build_uk_conditioned_area_supports.py b/tools/build_uk_conditioned_area_supports.py new file mode 100644 index 0000000000..5f0055fb0b --- /dev/null +++ b/tools/build_uk_conditioned_area_supports.py @@ -0,0 +1,603 @@ +#!/usr/bin/env python3 +"""Build the three UK conditioned atomic-area supports (microcosm#931). + +Each extends the registered support of its system (``sources.yaml`` role +``uk_atomic_area_support``, built by ``build_uk_atomic_area_supports.py``) +with the columns the geography-first draw conditions on. Only that move binds +them; today's build binds the registered supports. + +- ``imd_decile``: the area's deprivation decile at the 2019 vintage of each + nation's index (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017), the vintage + the FRS 2024-25 deciles follow. The May 2026 NSPL, the last edition to carry + those ranks, gives every live residential (small-user) postcode its small + area and its rank. An area takes the decile most of its postcodes carry; a + tie goes to the decile its parent area's postcodes favour, and an area + without such a postcode takes its parent's (LSOA, data zone, super data + zone). Deciles are the publishers' own; NISRA publishes none, so Northern + Ireland's are its 890 SOA ranks in tenths of 89. +- ``households_band_a`` ... : the area's households by council-tax band, times + 10^6. England and Wales use the VOA CTSOP1.1 mix of the area's LSOA + (``voa_council_tax_band_mix_lsoa.json``); Scotland uses its council's + CTAXBASE 2025 chargeable dwellings (``scotgov_chargeable_dwellings_by_band.json``), + so there the band moves mass only between councils. Northern Ireland has + domestic rates and no bands. + +The publisher files are chronicle#412's raw-only registrations (PR +chronicle#413), pinned here by sha256; the band mixes are committed package +resources. The provenance register records every input's identity, each +nation's decile rule counts, the rounding, and every zero-mass draw cell. + +Example (odfpy reads the Welsh Government's ODS; nothing else here needs it): + uv run --no-sync --with odfpy python tools/build_uk_conditioned_area_supports.py \\ + --supports-dir build/uk/supports \\ + --source-manifest build/uk/conditioned_sources.json \\ + --out-dir build/uk/supports + +``--source-manifest`` names exact local files (path/url/sha256/bytes per +source, schema_version 1, as for the registered supports); nothing is +downloaded. +""" + +from __future__ import annotations + +import argparse +import datetime as dt +import hashlib +import json +import sys +import zipfile +from collections.abc import Mapping +from pathlib import Path + +import numpy as np +import pandas as pd + +from microcosm.build.atomic_geography import decode_atomic_support +from microcosm.build.atomic_support_conditioning import ( + apportion_weights, + modal_area_codes, + zero_mass_cells, +) +from microcosm.build.uk_runtime.atomic_area_support import ( + BAND_WEIGHT_COLUMNS, + BAND_WEIGHT_SCALE, + CONDITIONED_PROVENANCE_RESOURCE, + CONDITIONED_SOURCES, + IMD_DECILE_COLUMN, + IMD_DECILES, + SYSTEMS, + assemble_uk_conditioned_area_support, + uk_conditioned_support_base, +) +from microcosm.build.uk_runtime.atomic_area_support import ( + SOURCES as SUPPORT_SOURCES, +) +from microcosm.graph.codecs import RAW_BYTES_MAX_BYTES + +_TOOLS = Path(__file__).resolve().parent +_REPOSITORY_ROOT = _TOOLS.parent +_UK_PACKAGE = _REPOSITORY_ROOT / "packages/microcosm-build/src/microcosm/build/uk" +_DEFAULT_PROVENANCE = _UK_PACKAGE / CONDITIONED_PROVENANCE_RESOURCE +VOA_BAND_MIX = "voa_council_tax_band_mix_lsoa.json" +SCOTLAND_BAND_COUNTS = "scotgov_chargeable_dwellings_by_band.json" + +PROVENANCE_SCHEMA_VERSION = 1 +PROVENANCE_KIND = "uk_atomic_area_conditioned_supports_provenance" +EW, SCOT, NI = SYSTEMS + +#: chronicle#412's raw-only registrations, as PR chronicle#413 pins them. +SOURCES: dict[str, dict[str, str | int]] = { + "nspl": { + "chronicle_source_id": "ons", + "chronicle_package_id": "ons-nspl-may-2026", + "chronicle_year": 2026, + "filename": "NSPL_MAY_2026.zip", + "url": "https://www.arcgis.com/sharing/rest/content/items/7668e0d35cab4f6db6f15f03be610fb0/data", + "sha256": "e0ccd5b3d90fdb537c29afc85b33c6c7ff8647e89e390f2e9ae48530f85f42c1", + "size_bytes": 187_209_017, + "publisher": "ONS", + "product": "National Statistics Postcode Lookup, May 2026", + }, + "iod2019": { + "chronicle_source_id": "mhclg", + "chronicle_package_id": "mhclg-english-indices-of-deprivation-2019-file-1", + "chronicle_year": 2019, + "filename": "File_1_-_IMD2019_Index_of_Multiple_Deprivation.xlsx", + "url": "https://assets.publishing.service.gov.uk/media/5d8b3abded915d0373d3540f/File_1_-_IMD2019_Index_of_Multiple_Deprivation.xlsx", + "sha256": "b95ca12952c3a8ebdb2e5c3bb03d5b0e56b76ede3fcf45205db26f280b912d9d", + "size_bytes": 1_433_347, + "publisher": "MHCLG", + "product": "English indices of deprivation 2019, File 1: index of multiple deprivation", + }, + "wimd2019": { + "chronicle_source_id": "welshgov", + "chronicle_package_id": "welshgov-wimd-2019-ranks-by-small-area", + "chronicle_year": 2019, + "filename": "welsh-index-multiple-deprivation-2019-index-and-domain-ranks-by-small-area.ods", + "url": "https://www.gov.wales/sites/default/files/statistics-and-research/2022-02/welsh-index-multiple-deprivation-2019-index-and-domain-ranks-by-small-area.ods", + "sha256": "2e7b65a3a276e31a10d4bf24a7d26e5cd9d2d95a796ab65e894fcd4e4b159430", + "size_bytes": 232_940, + "publisher": "Welsh Government", + "product": "WIMD 2019 index and domain ranks by small area", + }, + "simd2020v2": { + "chronicle_source_id": "scotgov", + "chronicle_package_id": "scotgov-simd-2020v2-data-zone-lookup", + "chronicle_year": 2020, + "filename": "SIMD_2020v2_datazone_lookup_updated_2025.xlsx", + "url": "https://www.gov.scot/binaries/content/documents/govscot/publications/statistics/2020/01/scottish-index-of-multiple-deprivation-2020-data-zone-look-up-file/documents/scottish-index-of-multiple-deprivation-data-zone-look-up/scottish-index-of-multiple-deprivation-data-zone-look-up/govscot%3Adocument/SIMD%2B2020v2%2B-%2Bdatazone%2Blookup%2B-%2Bupdated%2B2025.xlsx", + "sha256": "0a64937af60fb339a1be85cd2f65b6a3d410a38dc5b6c7f25a72ba2d7060a03e", + "size_bytes": 1_339_239, + "publisher": "Scottish Government", + "product": "SIMD 2020v2 data zone lookup (updated 2025)", + }, + "nimdm2017": { + "chronicle_source_id": "nisra", + "chronicle_package_id": "nisra-nimdm-2017-soa-results", + "chronicle_year": 2017, + "filename": "NIMDM17_SOAresults.xls", + "url": "https://www.nisra.gov.uk/files/nisra/publications/NIMDM17_SOAresults.xls", + "sha256": "3738edf2d264491301b41cc7b64967373d49b09a6f5719225a0e4f7d789af9d3", + "size_bytes": 1_772_032, + "publisher": "NISRA", + "product": "NIMDM 2017 results by Super Output Area", + }, +} +#: The commit of chronicle#413 these registrations were read at. Re-pinned to +#: the merge commit once chronicle#413 lands; the file digests do not move. +CHRONICLE = { + "pull_request": "PolicyEngine/chronicle#413", + "commit": "df468b8911efc54701326c5b528cfbf7650f92b5", + "merged": False, +} +ISSUES = { + "umbrella": "PolicyEngine/microcosm#931", + "chronicle_registration": "PolicyEngine/chronicle#412", +} +NSPL_MEMBER = "Data/NSPL_MAY_2026_UK.csv" +#: Small areas each index ranks, within its own nation only. +INDEX_AREAS = {"E": 32_844, "W": 1_909, "S": 6_976, "N": 890} +#: The source registrations behind each nation's ranks and deciles. +NATION_INDEX = {"E": "iod2019", "W": "wimd2019", "S": "simd2020v2", "N": "nimdm2017"} +NATION_PREFIXES = {EW: ("E", "W"), SCOT: ("S",), NI: ("N",)} +#: The vintage each system's decile column declares. +DECILE_VINTAGES = {EW: "2019_iod_wimd", SCOT: "2020v2_simd", NI: "2017_nimdm_soa"} +BAND_VINTAGES = {EW: "2025_ctsop", SCOT: "2025_ctaxbase"} +#: Each area's parent for ties and areas without a residential postcode. +PARENT_COLUMNS = {EW: "lsoa_code", SCOT: "lsoa_code", NI: "msoa_code"} + +NOTES = ( + "imd_decile is the 2019 vintage of each nation's index (IoD 2019, WIMD 2019, " + "SIMD 2020v2, NIMDM 2017): the FRS 2024-25 variables IMDE, IMDW, IMDS and IMDN " + "carry no change note from 2023-24, which predates the 2025 indices, and on an " + "internal comparison England's FRS decile shares by region fit IoD 2019 better than " + "IoD 2025, as the 2023-24 FRS does. DWP has been asked to confirm.", + "An area's decile is the one most of its live small-user postcodes carry in the May " + "2026 NSPL (oa21cd: the 2021 output area in England and Wales, the 2022 output area " + "in Scotland, the 2021 data zone in Northern Ireland). Ranks are within-nation only.", + "Northern Ireland's SOAs (2001) do not nest in its 2021 data zones, so many data " + "zones' postcodes span deciles; the modal decile is recorded with relation " + "inferred_modal and the counts below.", + "England and Wales band weights read each area's LSOA mix as committed (shares to " + "6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read " + "its council's chargeable dwellings, rounded half to even per band.", +) + + +def _sha256(path: Path) -> str: + digest = hashlib.sha256() + with path.open("rb") as handle: + for chunk in iter(lambda: handle.read(1 << 20), b""): + digest.update(chunk) + return digest.hexdigest() + + +def _log(message: str) -> None: + print(message, file=sys.stderr, flush=True) + + +def _parse_args(argv: list[str] | None = None) -> argparse.Namespace: + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + parser.add_argument("--supports-dir", required=True, type=Path) + parser.add_argument("--source-manifest", required=True, type=Path) + parser.add_argument("--out-dir", required=True, type=Path) + parser.add_argument("--provenance-json", type=Path, default=_DEFAULT_PROVENANCE) + parser.add_argument("--resource-dir", type=Path, default=_UK_PACKAGE) + return parser.parse_args(argv) + + +def _pinned_sources(path: Path) -> dict[str, Path]: + """Every source as an exact local file whose bytes match its registration.""" + manifest = json.loads(path.read_bytes()) + if not isinstance(manifest, dict) or manifest.get("schema_version") != 1: + raise ValueError("Pinned source manifest requires schema_version 1.") + rows = manifest.get("sources") + if not isinstance(rows, dict) or set(rows) != set(SOURCES): + raise ValueError("Pinned source manifest must name exactly the tool's sources.") + paths = {} + for name, spec in SOURCES.items(): + row = rows[name] + if not isinstance(row, dict) or set(row) != {"path", "url", "sha256", "bytes"}: + raise ValueError(f"Pinned source {name} requires path/url/sha256/bytes.") + local = Path(row["path"]) + if ( + row["url"] != spec["url"] + or row["sha256"] != spec["sha256"] + or row["bytes"] != spec["size_bytes"] + or not local.is_absolute() + or local.is_symlink() + or not local.is_file() + ): + raise ValueError(f"Pinned source {name} differs from its registration.") + if ( + local.stat().st_size != spec["size_bytes"] + or _sha256(local) != spec["sha256"] + ): + raise ValueError(f"Pinned source identity mismatch for {name}.") + paths[name] = local + return paths + + +def _rank_deciles(rank: pd.Series, decile: pd.Series, *, nation: str) -> dict[int, str]: + """A within-nation rank -> decile map; a tied rank must share one decile.""" + if len(rank) != INDEX_AREAS[nation]: + raise ValueError( + f"{nation}: {len(rank):,} ranked areas, expected {INDEX_AREAS[nation]:,}." + ) + mapping: dict[int, str] = {} + for r, d in zip(rank.astype(int), decile.astype(int), strict=True): + code = str(d) + if code not in IMD_DECILES or mapping.setdefault(int(r), code) != code: + raise ValueError(f"{nation}: rank {r} has no single decile 1 to 10.") + return mapping + + +def _england(path: Path) -> dict[int, str]: + frame = pd.read_excel(path, sheet_name="IMD2019") + return _rank_deciles( + frame["Index of Multiple Deprivation (IMD) Rank"], + frame["Index of Multiple Deprivation (IMD) Decile"], + nation="E", + ) + + +def _wales(path: Path) -> dict[int, str]: + raw = pd.read_excel( + path, sheet_name="Deciles_quintiles_quartiles", header=None, engine="odf" + ) + header = next( + row for row in range(10) if str(raw.iloc[row, 0]).strip().lower() == "lsoa code" + ) + frame = raw.iloc[header + 1 :].dropna(how="all") + frame.columns = [str(column).strip() for column in raw.iloc[header]] + return _rank_deciles( + frame["WIMD 2019 overall rank"], frame["WIMD 2019 overall decile"], nation="W" + ) + + +def _scotland(path: Path) -> dict[int, str]: + frame = pd.read_excel(path, sheet_name="SIMD 2020v2 DZ lookup data") + return _rank_deciles( + frame["SIMD2020v2_Rank"], frame["SIMD2020v2_Decile"], nation="S" + ) + + +def _northern_ireland() -> dict[int, str]: + """NISRA publishes ranks only: tenths of the 890 SOAs, 89 each, rank 1 most deprived.""" + areas = INDEX_AREAS["N"] + return {rank: str((rank - 1) * 10 // areas + 1) for rank in range(1, areas + 1)} + + +def _postcodes(path: Path) -> pd.DataFrame: + """Live small-user postcodes with their small area and within-nation rank.""" + with zipfile.ZipFile(path) as archive, archive.open(NSPL_MEMBER) as handle: + frame = pd.read_csv( + handle, + usecols=["doterm", "usrtypind", "oa21cd", "imd20ind"], + dtype=str, + keep_default_na=False, + ) + live = (frame["doterm"] == "") & (frame["usrtypind"] == "0") + return frame.loc[live, ["oa21cd", "imd20ind"]].reset_index(drop=True) + + +def decile_column( + support, + postcodes: pd.DataFrame, + deciles: Mapping[str, Mapping[int, str]], + *, + system: str, +): + """The system's modal decile per area, and the postcode counts behind it.""" + areas = np.asarray(support.arrays["area"]) + mine = postcodes[postcodes["oa21cd"].isin(pd.Index(areas))] + ranked = mine[~mine["imd20ind"].isin(["", "0"])] + nation = ranked["oa21cd"].str[0].to_numpy() + rank = ranked["imd20ind"].astype(int).to_numpy() + codes = np.empty(len(ranked), dtype=object) + for prefix in NATION_PREFIXES[system]: + rows = nation == prefix + lookup = deciles[prefix] + missing = sorted({int(r) for r in rank[rows] if int(r) not in lookup}) + if missing: + raise ValueError( + f"{system}: NSPL ranks {missing[:5]} are not in the {prefix} index." + ) + codes[rows] = [lookup[int(r)] for r in rank[rows]] + modal = modal_area_codes( + areas, + np.asarray(support.arrays[PARENT_COLUMNS[system]]), + ranked["oa21cd"].to_numpy(dtype="U"), + np.asarray(codes.tolist(), dtype="U"), + domain=IMD_DECILES, + ) + receipt = { + **modal.receipt(), + "postcodes_in_areas": int(len(mine)), + "postcodes_without_rank": int(len(mine) - len(ranked)), + } + return modal.codes, receipt + + +def _voa_numerators(support, mix: Mapping) -> tuple[dict[str, np.ndarray], np.ndarray]: + """Each E&W area's band shares in millionths, from its LSOA's committed mix.""" + if mix.get("bands") != list("ABCDEFGHI"): + raise ValueError("VOA band mix must list bands A to I.") + parts = {} + for lsoa, row in mix["lsoa"].items(): + cumulative = [round(value * BAND_WEIGHT_SCALE) for value in row["cumulative"]] + steps = np.diff([0, *cumulative]) + if cumulative[-1] != BAND_WEIGHT_SCALE or np.any(steps < 0): + raise ValueError(f"VOA band mix for {lsoa} is not a partition.") + parts[lsoa] = steps + lsoas = np.asarray(support.arrays["lsoa_code"]) + unknown = sorted(set(lsoas.tolist()) - set(parts)) + if unknown: + raise ValueError(f"VOA band mix lacks LSOAs {unknown[:5]}.") + table = np.stack([parts[code] for code in lsoas.tolist()]) + columns = BAND_WEIGHT_COLUMNS[EW] + numerators = { + column: table[:, index].astype(np.int64) for index, column in enumerate(columns) + } + return numerators, np.full(len(lsoas), BAND_WEIGHT_SCALE, dtype=np.int64) + + +def _scotland_numerators( + support, counts: Mapping +) -> tuple[dict[str, np.ndarray], np.ndarray]: + """Each Scottish area's council chargeable dwellings by band A to H.""" + bands = {column: column.rsplit("_", 1)[1] for column in BAND_WEIGHT_COLUMNS[SCOT]} + by_council: dict[str, dict[str, int]] = {} + for row in counts["rows"]: + council = str(row["geography"]["id"]) + band = str(row["measure_id"]).removeprefix("band_") + value = row["value"] + if type(value) is not int or value < 0 or band in by_council.get(council, {}): + raise ValueError(f"Scottish band count {council} {band} is not one count.") + by_council.setdefault(council, {})[band] = value + councils = np.asarray(support.arrays["local_authority_code"]) + missing = sorted(set(councils.tolist()) - set(by_council)) + if missing or any(set(v) != set(bands.values()) for v in by_council.values()): + raise ValueError( + f"Scottish band counts do not cover each council A to H: {missing[:5]}." + ) + numerators = { + column: np.asarray( + [by_council[c][band] for c in councils.tolist()], dtype=np.int64 + ) + for column, band in bands.items() + } + return numerators, sum(numerators.values()) + + +def _source_tag(name: str) -> str: + spec = SOURCES[name] + return f"{spec['chronicle_package_id']}@sha256:{spec['sha256']}" + + +def _metadata(system: str, support, resources: Mapping[str, dict]) -> dict: + indices = "+".join(_source_tag(NATION_INDEX[p]) for p in NATION_PREFIXES[system]) + metadata = { + IMD_DECILE_COLUMN: { + "kind": "code", + "source": f"{_source_tag('nspl')}+{indices}#modal-live-small-user-postcode", + "vintage": DECILE_VINTAGES[system], + "relation": "inferred_modal", + } + } + households = support.metadata["columns"]["households"]["basis"] + for column in BAND_WEIGHT_COLUMNS[system]: + band = column.rsplit("_", 1)[1] + if system == EW: + resource = resources[VOA_BAND_MIX] + share = f"voa_ctsop1_1_2025_lsoa_band_{band}_share_6dp" + else: + resource = resources[SCOTLAND_BAND_COUNTS] + share = f"ctaxbase_2025_council_band_{band}_share_round_half_even" + metadata[column] = { + "kind": "weight", + "source": ( + f"{resource['publisher_package']}@sha256:{resource['publisher_sha256']}" + f"#{resource['resource']}@sha256:{resource['sha256']}" + ), + "basis": f"{households}_x_{share}_x1e6", + } + return metadata + + +def _resources(directory: Path) -> tuple[dict, dict, dict[str, dict]]: + voa_path = directory / VOA_BAND_MIX + scot_path = directory / SCOTLAND_BAND_COUNTS + voa = json.loads(voa_path.read_text(encoding="utf-8")) + scot = json.loads(scot_path.read_text(encoding="utf-8")) + raw_keys = {row["source"]["raw_r2_key"] for row in scot["rows"]} + shas = {row["source"]["source_sha256"] for row in scot["rows"]} + if len(raw_keys) != 1 or len(shas) != 1: + raise ValueError("Scottish band counts must come from one publisher file.") + identities = { + VOA_BAND_MIX: { + "resource": VOA_BAND_MIX, + "sha256": _sha256(voa_path), + "publisher_package": voa["source"]["chronicle_package_id"], + "publisher_sha256": voa["source"]["sha256"], + "publisher_file": voa["source"]["filename"], + "as_at": voa["source"]["as_at"], + }, + SCOTLAND_BAND_COUNTS: { + "resource": SCOTLAND_BAND_COUNTS, + "sha256": _sha256(scot_path), + "publisher_package": next(iter(raw_keys)).split("/")[2], + "publisher_sha256": next(iter(shas)), + "publisher_file": scot["rows"][0]["source"]["source_file"], + "as_at": scot["rows"][0]["period"]["value"], + }, + } + return voa, scot, identities + + +def condition_supports( + base_payloads: Mapping[str, bytes], + postcodes: pd.DataFrame, + deciles: Mapping[str, Mapping[int, str]], + *, + voa_mix: Mapping, + scotland_counts: Mapping, + resources: Mapping[str, dict], +) -> tuple[dict[str, bytes], dict[str, dict]]: + """The three conditioned supports and each one's receipts.""" + payloads, entries = {}, {} + for system in SYSTEMS: + base = base_payloads[system] + support = decode_atomic_support(base) + decile, decile_receipt = decile_column( + support, postcodes, deciles, system=system + ) + households = np.asarray(support.arrays["households"], dtype=np.int64) + band_receipt = None + weights: dict[str, np.ndarray] = {} + if BAND_WEIGHT_COLUMNS[system]: + numerators, denominators = ( + _voa_numerators(support, voa_mix) + if system == EW + else _scotland_numerators(support, scotland_counts) + ) + weights, band_receipt = apportion_weights( + households, numerators, denominators, scale=BAND_WEIGHT_SCALE + ) + payload = assemble_uk_conditioned_area_support( + base=base, + imd_decile=decile, + band_weights=weights, + column_metadata=_metadata(system, support, resources), + ) + if uk_conditioned_support_base(payload) != base: + raise ValueError(f"{system}: conditioned support does not extend its base.") + if len(payload) > RAW_BYTES_MAX_BYTES: + raise ValueError(f"{system}: support exceeds the raw-bytes-v1 cap.") + conditioned = decode_atomic_support(payload) + by_decile = pd.Series(households).groupby(decile).sum() + payloads[system] = payload + entries[system] = { + "imd_decile": decile_receipt, + "households_by_imd_decile": { + code: int(by_decile.get(code, 0)) for code in IMD_DECILES + }, + "band_weights": band_receipt, + "zero_mass_cells": zero_mass_cells( + conditioned, + domains={ + "frs_region": sorted( + set(conditioned.arrays["frs_region"].tolist()) + ), + IMD_DECILE_COLUMN: IMD_DECILES, + }, + levels=(("frs_region", IMD_DECILE_COLUMN), ("frs_region",)), + weights=("households", *BAND_WEIGHT_COLUMNS[system]), + ), + "column_metadata": { + column: dict(conditioned.metadata["columns"][column]) + for column in (IMD_DECILE_COLUMN, *BAND_WEIGHT_COLUMNS[system]) + }, + } + return payloads, entries + + +def _base_payloads(directory: Path) -> dict[str, bytes]: + """The registered supports, refused unless their bytes are the registered ones.""" + from microcosm.build.uk_runtime.country_adapter import uk_atomic_support_register + + register = uk_atomic_support_register() + payloads = {} + for system in SYSTEMS: + payload = (directory / f"{SUPPORT_SOURCES[system]}.npz").read_bytes() + if ( + hashlib.sha256(payload).hexdigest() != register[system]["sha256"] + or len(payload) != register[system]["size_bytes"] + ): + raise ValueError(f"{system}: support bytes are not the registered support.") + payloads[system] = payload + return payloads + + +def main(argv: list[str] | None = None) -> None: + args = _parse_args(argv) + _log("Building UK conditioned atomic-area supports") + paths = _pinned_sources(args.source_manifest) + bases = _base_payloads(args.supports_dir) + deciles = { + "E": _england(paths["iod2019"]), + "W": _wales(paths["wimd2019"]), + "S": _scotland(paths["simd2020v2"]), + "N": _northern_ireland(), + } + _log(" reading the NSPL") + postcodes = _postcodes(paths["nspl"]) + voa, scot, resources = _resources(args.resource_dir) + payloads, entries = condition_supports( + bases, + postcodes, + deciles, + voa_mix=voa, + scotland_counts=scot, + resources=resources, + ) + args.out_dir.mkdir(parents=True, exist_ok=True) + supports = {} + for system, payload in payloads.items(): + path = args.out_dir / f"{CONDITIONED_SOURCES[system]}.npz" + path.write_bytes(payload) + supports[system] = { + "filename": path.name, + "sha256": hashlib.sha256(payload).hexdigest(), + "size_bytes": len(payload), + "base": { + "source": SUPPORT_SOURCES[system], + "sha256": hashlib.sha256(bases[system]).hexdigest(), + }, + **entries[system], + } + provenance = { + "schema_version": PROVENANCE_SCHEMA_VERSION, + "kind": PROVENANCE_KIND, + "built_on": dt.date.today().isoformat(), + "tool": "tools/build_uk_conditioned_area_supports.py", + "issues": ISSUES, + "chronicle": CHRONICLE, + "publisher_files": {name: dict(spec) for name, spec in SOURCES.items()}, + "resources": resources, + "band_weight_scale": BAND_WEIGHT_SCALE, + "supports": supports, + "notes": list(NOTES), + } + args.provenance_json.write_text( + json.dumps(provenance, indent=2, sort_keys=True) + "\n", encoding="utf-8" + ) + for system, entry in supports.items(): + _log( + f" {system}: {entry['size_bytes']:,} bytes, sha256 {entry['sha256'][:16]}" + ) + _log(f" provenance written to {args.provenance_json}") + + +if __name__ == "__main__": + main() From d495d2067c6013e6fd3ae07ff07bdc8991eea8f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Thu, 5 Nov 2026 14:40:01 +0000 Subject: [PATCH 05/20] Re-pin the conditioned supports to chronicle#413's merge (#931) chronicle#413 merged as c51f40d2b. Each of its five registrations the conditioned supports read pins the same file at the merge as at the PR head (df468b8) they were built from: the same filename, URL, sha256 and size. The tool's CHRONICLE block and the provenance now name the merge commit, and the three support files regenerate byte for byte. The provenance note also no longer claims DWP has been asked to confirm the FRS decile vintage; it says the vintage is still to be confirmed. Co-Authored-By: Claude Opus 5.5 --- ...uk_atomic_area_conditioned_supports.provenance.json | 6 +++--- tools/build_uk_conditioned_area_supports.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json index ce71576a71..0cc5652aa1 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json +++ b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json @@ -2,8 +2,8 @@ "band_weight_scale": 1000000, "built_on": "2026-11-05", "chronicle": { - "commit": "df468b8911efc54701326c5b528cfbf7650f92b5", - "merged": false, + "commit": "c51f40d2bdaa66315dd63f334ede5790a8891e27", + "merged": true, "pull_request": "PolicyEngine/chronicle#413" }, "issues": { @@ -12,7 +12,7 @@ }, "kind": "uk_atomic_area_conditioned_supports_provenance", "notes": [ - "imd_decile is the 2019 vintage of each nation's index (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017): the FRS 2024-25 variables IMDE, IMDW, IMDS and IMDN carry no change note from 2023-24, which predates the 2025 indices, and on an internal comparison England's FRS decile shares by region fit IoD 2019 better than IoD 2025, as the 2023-24 FRS does. DWP has been asked to confirm.", + "imd_decile is the 2019 vintage of each nation's index (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017): the FRS 2024-25 variables IMDE, IMDW, IMDS and IMDN carry no change note from 2023-24, which predates the 2025 indices, and on an internal comparison England's FRS decile shares by region fit IoD 2019 better than IoD 2025, as the 2023-24 FRS does. The vintage is still to be confirmed with DWP.", "An area's decile is the one most of its live small-user postcodes carry in the May 2026 NSPL (oa21cd: the 2021 output area in England and Wales, the 2022 output area in Scotland, the 2021 data zone in Northern Ireland). Ranks are within-nation only.", "Northern Ireland's SOAs (2001) do not nest in its 2021 data zones, so many data zones' postcodes span deciles; the modal decile is recorded with relation inferred_modal and the counts below.", "England and Wales band weights read each area's LSOA mix as committed (shares to 6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read its council's chargeable dwellings, rounded half to even per band." diff --git a/tools/build_uk_conditioned_area_supports.py b/tools/build_uk_conditioned_area_supports.py index 5f0055fb0b..797a9e7100 100644 --- a/tools/build_uk_conditioned_area_supports.py +++ b/tools/build_uk_conditioned_area_supports.py @@ -143,12 +143,12 @@ "product": "NIMDM 2017 results by Super Output Area", }, } -#: The commit of chronicle#413 these registrations were read at. Re-pinned to -#: the merge commit once chronicle#413 lands; the file digests do not move. +#: The Chronicle commit that registers these files: chronicle#413's merge. The +#: supports were first built at its head; the file digests did not move. CHRONICLE = { "pull_request": "PolicyEngine/chronicle#413", - "commit": "df468b8911efc54701326c5b528cfbf7650f92b5", - "merged": False, + "commit": "c51f40d2bdaa66315dd63f334ede5790a8891e27", + "merged": True, } ISSUES = { "umbrella": "PolicyEngine/microcosm#931", @@ -171,7 +171,7 @@ "SIMD 2020v2, NIMDM 2017): the FRS 2024-25 variables IMDE, IMDW, IMDS and IMDN " "carry no change note from 2023-24, which predates the 2025 indices, and on an " "internal comparison England's FRS decile shares by region fit IoD 2019 better than " - "IoD 2025, as the 2023-24 FRS does. DWP has been asked to confirm.", + "IoD 2025, as the 2023-24 FRS does. The vintage is still to be confirmed with DWP.", "An area's decile is the one most of its live small-user postcodes carry in the May " "2026 NSPL (oa21cd: the 2021 output area in England and Wales, the 2022 output area " "in Scotland, the 2021 data zone in Northern Ireland). Ranks are within-nation only.", From 8fe2d003ccb38e18a95e3ac9da2d3395b501044f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Thu, 5 Nov 2026 17:11:53 +0000 Subject: [PATCH 06/20] Fold geographic clones in the SPI employment fit (#931) The SPI employment shell (#1490) trains its occupation classifier and draws its industry donors on the frame's FRS adults. As in the six fits of commit 2, it now folds each survey record's geographic clones into the record's first training row with their summed weight, and every other copy stays a row of its own. Today's spine has no geographic clones, so its rows and weights are unchanged, value for value. - Its household slice declares the support clone index its fold reads. - It joins the clone-collapse sweep's stages, which checks that slice. - A replicated-fixture test runs it on two production geographic clones: the fit, its training shares and clone 0's draws equal the frame's own, and the test fails with the fold switched off. - uk_spine.json moves only in its household slice. Co-Authored-By: Claude Opus 5.5 --- .../src/microcosm/build/uk_runtime/graph.py | 7 +++- .../build/uk_runtime/spi_employment_shell.py | 10 ++++- .../uk/test_uk_geographic_clone_collapse.py | 7 +++- .../uk/test_uk_spi_employment_shell.py | 40 +++++++++++++++++++ 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py index b953816fa5..8a52bfbf14 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py @@ -402,7 +402,9 @@ "hmrc_spi_income_spine": None, # Engine-free: the occupation predictors, the drawn-row rule and the channel # split. The rewritten occupation, industry and sector cells arrive as the - # rewrite's incumbents (microcosm#1490). + # rewrite's incumbents (microcosm#1490). The lineage live here lets the fit + # fold geographic clones into each survey record, and the receipt count + # true sources (microcosm#931). "spi_employment_shell": frozenset( { ("person", "age"), @@ -417,7 +419,8 @@ ("person", "hmrc_spi_pay"), ("household", "region"), ("household", "household_support_channel"), - ("household", "household_source_id"), + ("household", "household_support_clone_index"), + ("household", "source_household_id"), } ), # Engine-free: the sub-major predictors, the major group it nests in, the diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_employment_shell.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_employment_shell.py index 31229ca068..80a0ab927b 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_employment_shell.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_employment_shell.py @@ -38,6 +38,7 @@ integer_record_keys, stable_identity_uniforms, ) +from microcosm.build.uk_runtime.household_lineage import collapse_geographic_clones from microcosm.build.uk_runtime.occupation_constants import ( UK_OCCUPATION_STATUS_GROUP, UK_SOC2020_NO_OCCUPATION, @@ -552,6 +553,13 @@ def impute_spi_employment_shell( ) if not training.any(): raise ValueError(f"{stage} needs FRS adults with an occupation to train on.") + # The fit and the donors see each survey record once: its geographic + # clones fold into its first row with their weight, and every other copy + # stays its own row; a frame without geographic clones keeps every row + # and weight (household_lineage.collapse_geographic_clones, microcosm#931). + training, fit_weights = collapse_geographic_clones( + {"person": person, "household": household}, "person", training, weights + ) # The training rows in person_id order, so neither the fit (the early # stopping split, the folds) nor the donor ties depend on how the frame @@ -561,7 +569,7 @@ def impute_spi_employment_shell( np.argsort(table["person_id"].to_numpy()[train_rows], kind="stable") ] train = table.iloc[train_rows].reset_index(drop=True) - train_weights = weights[train_rows] + train_weights = fit_weights[train_rows] train_sources = sources[train_rows] model = occupation_model(operation, boosted_max_iter=boosted_max_iter) seed = int(operation["seed"]) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py index e5958c5416..fa08c4edf2 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py @@ -94,6 +94,7 @@ def test_only_geographic_clones_fold_into_their_survey_record() -> None: "uc_reporter_redraw": "uc_reporter_redraw", "uc_capital_coherence": "uc_capital_coherence", "salary_sacrifice": "salary_sacrifice", + "spi_employment_shell": "spi_employment_shell", } @@ -140,4 +141,8 @@ def test_every_collapsing_stage_sees_the_lineage_live_at_it() -> None: assert not missing, (node.id, missing) checked.append(node.id) live |= {(cell.entity, cell.column) for cell in node.outputs} - assert sorted(checked) == ["spi_housing_shell", "uc_capital_coherence"] + assert sorted(checked) == [ + "spi_employment_shell", + "spi_housing_shell", + "uc_capital_coherence", + ] diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_employment_shell.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_employment_shell.py index f4d218de3d..543759a92f 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_employment_shell.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_employment_shell.py @@ -10,6 +10,7 @@ import pytest from microcosm.build import load_country_spec +from microcosm.build.uk_runtime.national_frame import uk_national_frame from microcosm.build.uk_runtime.spi_employment_shell import ( UK_SPI_EMPLOYMENT_SHELL_OPERATION, UK_SPI_EMPLOYMENT_SHELL_REWRITES, @@ -18,6 +19,7 @@ impute_spi_employment_shell, ) from microcosm.build.uk_runtime.stage_health import uk_stage_health_gate +from test_support.microcosm_build.uk_geographic_clones import with_geographic_clones from test_support.microcosm_build.uk_spi_employment_shell import employment_shell_tables STAGE = "spi_employment_shell" @@ -313,3 +315,41 @@ def test_each_bound_fails_the_gate(overrides, message) -> None: result = _gate(_evidence(**overrides)) assert not result.passed assert any(message in failure for failure in result.failures) + + +def test_geographic_clones_fold_into_each_survey_record(tables, shell) -> None: + """Two production geographic clones train the shell on the frame's own + rows and weights, so clone 0 draws what the frame draws alone + (microcosm#931).""" + + person, household, weights = tables + person_out, receipt = shell + pool = with_geographic_clones( + uk_national_frame( + person=person.assign(person_benunit_id=person["person_household_id"]), + benunit=pd.DataFrame({"benunit_id": household["household_id"].to_numpy()}), + household=household, + household_weights=weights, + time_period="2024", + ) + ) + cloned, cloned_receipt = impute_spi_employment_shell( + pool.table("person"), + pool.table("household"), + pool.weights_for("household").values, + boosted_max_iter=60, + ) + # Clone 0 keeps every id, so its rows are the frame's own. + first = cloned["person_id"].isin(person["person_id"]) + columns = list(UK_SPI_EMPLOYMENT_SHELL_REWRITES) + pd.testing.assert_frame_equal( + cloned.loc[first].set_index("person_id")[columns], + person_out.set_index("person_id")[columns], + check_dtype=False, + ) + assert cloned_receipt["training"] == receipt["training"] + assert cloned_receipt["fit"] == receipt["fit"] + assert ( + cloned_receipt["category_shares"]["training"] + == receipt["category_shares"]["training"] + ) From 449ebb5d09e7e9f577365987302a787c3fa8d34b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Fri, 6 Nov 2026 09:43:21 +0000 Subject: [PATCH 07/20] Catch every form of a household-row count in the static floor scan (#931) From Vahid's review (item 4), the scan now also sees: - `len(df.drop_duplicates(key))`, with the key as an argument or `subset=`; - `groupby(key).ngroups` and `len(df.groupby(key))`; - a `.loc[rows, "column"]` tuple slice; - a column named through a module constant, such as `HOUSEHOLD_ID_COLUMN = "household_id"`. Snippet tests pin each form and a pass case for other keys. The wider scan found one more count, a structural row check in tools/verify_uk_identity_stability.py that every SPI band donor holds one carrier. It is named in `_KEPT_ROW_COUNTS` beside the two existing ones. Co-Authored-By: Claude Opus 5.5 --- .../engine_free/uk/test_uk_receipt_counts.py | 119 ++++++++++++++++-- 1 file changed, 107 insertions(+), 12 deletions(-) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_receipt_counts.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_receipt_counts.py index ad6fa1df73..c1d60be465 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_receipt_counts.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_receipt_counts.py @@ -378,10 +378,17 @@ def test_a_cell_is_counted_by_the_same_rule() -> None: _ROW_IDENTITY_COLUMNS = frozenset( {"household_id", "person_household_id", "household_source_id"} ) -#: Counts of those columns that are no floor: structural checks that every -#: benefit unit sits in one household. Each entry names the phrase holding the -#: count and how many counts it covers in its file. +#: Counts of those columns that are no floor: structural checks over rows, +#: that every benefit unit sits in one household and every SPI band donor +#: holds exactly one carrier. Each entry names the phrase holding the count +#: and how many counts it covers in its file. _KEPT_ROW_COUNTS: dict[str, tuple[tuple[str, int], ...]] = { + "tools/verify_uk_identity_stability.py": ( + ( + 'person.loc[carriers, "person_household_id"].value_counts().to_dict()', + 1, + ), + ), "uk_runtime/uc_reporter_redraw.py": ( ( 'counts = placements.groupby("person_benunit_id", sort=False)[ ' @@ -419,15 +426,33 @@ def _call_name(node) -> str | None: return None -def _row_identity(node, names: set[str]) -> bool: - """Whether ``node`` holds a row identity column's values.""" +def _names_identity_column(node, constants: frozenset[str]) -> bool: + """Whether ``node`` names a row identity column: a literal, a constant + holding one, or a list or tuple containing either.""" + + import ast + + if isinstance(node, (ast.List, ast.Tuple)): + return any(_names_identity_column(item, constants) for item in node.elts) + if isinstance(node, ast.Constant): + return node.value in _ROW_IDENTITY_COLUMNS + return isinstance(node, ast.Name) and node.id in constants + + +def _row_identity( + node, names: set[str], constants: frozenset[str] = frozenset() +) -> bool: + """Whether ``node`` holds a row identity column's values, or names one.""" import ast + if isinstance(node, (ast.Constant, ast.List, ast.Tuple)) or ( + isinstance(node, ast.Name) and node.id in constants + ): + return _names_identity_column(node, constants) while True: if isinstance(node, ast.Subscript): - key = node.slice - if isinstance(key, ast.Constant) and key.value in _ROW_IDENTITY_COLUMNS: + if _names_identity_column(node.slice, constants): return True node = node.value elif isinstance(node, ast.Attribute): @@ -448,11 +473,27 @@ def _row_identity(node, names: set[str]) -> bool: return isinstance(node, ast.Name) and node.id in names +def _key_argument(call, keyword: str): + """A call's first positional argument, or its ``keyword`` argument.""" + + if call.args: + return call.args[0] + return next((kw.value for kw in call.keywords if kw.arg == keyword), None) + + def _counted_keys(node): """The keys a distinct count counts, or None for any other node.""" import ast + # groupby(key).ngroups counts the distinct keys. + if ( + isinstance(node, ast.Attribute) + and node.attr == "ngroups" + and isinstance(node.value, ast.Call) + and _call_name(node.value) == "groupby" + ): + return _key_argument(node.value, "by") if not isinstance(node, ast.Call): return None name = _call_name(node) @@ -465,9 +506,12 @@ def _counted_keys(node): inner_name = _call_name(inner) if inner_name in {"set", "unique"} and inner.args: return inner.args[0] - if inner_name in {"unique", "drop_duplicates"} and isinstance( - inner.func, ast.Attribute - ): + if inner_name == "groupby" and isinstance(inner.func, ast.Attribute): + return _key_argument(inner, "by") + if inner_name == "drop_duplicates" and isinstance(inner.func, ast.Attribute): + # The key may be the receiver or the subset argument. + return _key_argument(inner, "subset") or inner.func.value + if inner_name == "unique" and isinstance(inner.func, ast.Attribute): return inner.func.value return None @@ -482,6 +526,16 @@ def _row_identity_counts(tree) -> list[int]: import ast found: list[int] = [] + # Module-level names bound to an identity column's name, e.g. + # ``HOUSEHOLD_ID_COLUMN = "household_id"``. + constants = frozenset( + target.id + for node in tree.body + if isinstance(node, ast.Assign) + and _names_identity_column(node.value, frozenset()) + for target in node.targets + if isinstance(target, ast.Name) + ) def own_nodes(scope): stack = list(ast.iter_child_nodes(scope)) @@ -505,7 +559,11 @@ def scan(scope, inherited: set[str]) -> None: while grew: grew = False for node in assignments: - if not _row_identity(node.value, names): + value = node.value + # A bare column name is not a column's values. + if isinstance(value, (ast.Constant, ast.List, ast.Tuple)): + continue + if not _row_identity(value, names, constants): continue targets = ( node.targets if isinstance(node, ast.Assign) else [node.target] @@ -516,7 +574,7 @@ def scan(scope, inherited: set[str]) -> None: grew = True for node in nodes: keys = _counted_keys(node) - if keys is not None and _row_identity(keys, names): + if keys is not None and _row_identity(keys, names, constants): found.append(node.lineno) if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): scan(node, names) @@ -599,3 +657,40 @@ def test_no_uk_floor_counts_rows_by_their_household_ids() -> None: for suffix, phrase in expected } assert seen == expected + + +@pytest.mark.parametrize( + "source", + [ + 'n = households["household_id"].nunique()', + 'n = len(set(person["person_household_id"]))', + 'n = len(households.drop_duplicates("household_id"))', + 'n = len(households.drop_duplicates(subset=["household_id", "region"]))', + 'n = households.groupby("household_id").ngroups', + 'n = len(person.groupby(by="person_household_id"))', + 'KEY = "household_source_id"\nn = households[KEY].nunique()', + 'KEY = "household_id"\nn = households.groupby(KEY).ngroups', + 'ids = households["household_id"].to_numpy()\nn = distinct_count(ids)', + ], +) +def test_the_static_scan_sees_every_form_of_a_row_count(source) -> None: + """Each form counts distinct household rows (#1519 review).""" + + import ast + + assert _row_identity_counts(ast.parse(source)) != [] + + +@pytest.mark.parametrize( + "source", + [ + 'n = households.groupby("region").ngroups', + 'n = len(households.drop_duplicates("region"))', + 'n = distinct_count(record_source_households(tables, "household", stage=s))', + 'KEY = "household_id"\nn = len(households)', + ], +) +def test_the_static_scan_passes_counts_of_other_keys(source) -> None: + import ast + + assert _row_identity_counts(ast.parse(source)) == [] From fc66d2c59f8542ee3907e95f57f9f10ba290c30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Fri, 6 Nov 2026 09:46:54 +0000 Subject: [PATCH 08/20] Require the sources the person draws and annual income count by (#931) From Vahid's review (item 5): `derive_is_apprentice`, `derive_frs_person_draws` (with and without its receipt) and `derive_frs_annual_income_spells` fell back to each row's household when `person_sources` was missing. On a cloned person table that counts K clones as K sources. `person_sources` is now a required keyword. The spine stages already pass true sources (`record_source_households`). The callers that did lean on the fallback now pass `own_source_households(person)` themselves: - the tests, which build raw frames where each household is its own source; - `tools/verify_uk_identity_stability.py`, which compares only the draws, never the receipt's counts. Co-Authored-By: Claude Opus 5.5 --- .../build/uk_runtime/frs_annual_income.py | 15 +++----- .../build/uk_runtime/frs_person_draws.py | 19 ++++------ .../engine_free/uk/test_uk_apprentice_draw.py | 38 ++++++++++++------- .../uk/test_uk_frs_annual_income.py | 1 + .../engine_free/uk/test_uk_frs_stochastic.py | 6 ++- tools/verify_uk_identity_stability.py | 4 ++ 6 files changed, 46 insertions(+), 37 deletions(-) diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_annual_income.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_annual_income.py index 51c8f2a375..02ded8dfb1 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_annual_income.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_annual_income.py @@ -145,7 +145,6 @@ UK_WITHHELD, distinct_carriers, extreme_count, - own_source_households, record_source_households, small_cell_share, support_band, @@ -460,7 +459,7 @@ def derive_frs_annual_income_spells( job: pd.DataFrame, interview: pd.Series, earnings_growth: float, - person_sources: np.ndarray | None = None, + person_sources: np.ndarray, ) -> tuple[pd.DataFrame, dict[str, object]]: """Person-aligned descriptors and their aggregate receipt. @@ -470,9 +469,9 @@ def derive_frs_annual_income_spells( by ``household_id``. ``person_weights`` are the household weights each person row carries, and ``person_sources`` each person's true source household, which the receipt counts support by - (``receipt_counts.record_source_households``); without them each person's - household is its own source, as every household is before the SPI support - channel. + (``receipt_counts.record_source_households``). A caller without the + frame's lineage passes ``own_source_households`` itself, so no table is + counted by its rows unawares (microcosm#931). """ person_ids = person["person_id"].to_numpy() @@ -480,11 +479,7 @@ def derive_frs_annual_income_spells( weights = np.asarray(person_weights, dtype=float) if weights.shape != (rows,): raise ValueError("person weights must align with the person table.") - household_sources = ( - own_source_households(person) - if person_sources is None - else np.asarray(person_sources) - ) + household_sources = np.asarray(person_sources) if household_sources.shape != (rows,): raise ValueError("person sources must align with the person table.") raw = adult.drop_duplicates("person_id").set_index("person_id") diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_person_draws.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_person_draws.py index 8ca52c54c1..f445f3a33d 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_person_draws.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_person_draws.py @@ -63,7 +63,6 @@ UK_DISCLOSURE_FLOOR, UK_WITHHELD, distinct_count, - own_source_households, record_source_households, support_band, ) @@ -209,7 +208,7 @@ def derive_frs_person_draws( contract: UKTakeUpContract, person_weights: np.ndarray, relief_schedule: Mapping[str, float] | None = None, - person_sources: np.ndarray | None = None, + person_sources: np.ndarray, ) -> pd.DataFrame: """Return the stage's person draws. @@ -233,7 +232,7 @@ def derive_frs_person_draws_with_receipt( contract: UKTakeUpContract, person_weights: np.ndarray, relief_schedule: Mapping[str, float] | None = None, - person_sources: np.ndarray | None = None, + person_sources: np.ndarray, ) -> tuple[pd.DataFrame, Mapping[str, object]]: """The stage's person draws and the receipt of its ``is_apprentice`` draw.""" @@ -286,7 +285,7 @@ def derive_is_apprentice( rate: float, person_weights: np.ndarray | None = None, relief_schedule: Mapping[str, float] | None = None, - person_sources: np.ndarray | None = None, + person_sources: np.ndarray, ) -> UKApprenticeDraw: """Draw ``is_apprentice`` for employees aged 21 to 24 outside full-time education. @@ -306,9 +305,9 @@ def derive_is_apprentice( so it is an estimate of the s.9B relief, not the engine's figure. The receipt counts support in ``person_sources``, each person's true - source household (``receipt_counts.record_source_households``). Without - them each person's household is its own source, as every household is - before the SPI support channel. + source household (``receipt_counts.record_source_households``). A caller + without the frame's lineage passes ``own_source_households`` itself, so + no table is counted by its rows unawares (microcosm#931). """ if "employment_status" not in person.columns: @@ -351,11 +350,7 @@ def derive_is_apprentice( ) flags = eligible & (draws < threshold) realized = float(weights[flags].sum()) - sources = ( - own_source_households(person) - if person_sources is None - else np.asarray(person_sources) - ) + sources = np.asarray(person_sources) if sources.shape != (len(person),): raise ValueError("person_sources must hold one source per person.") population_support = distinct_count(sources, in_ages, weights) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_apprentice_draw.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_apprentice_draw.py index 7fd1477831..e8e7feaf47 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_apprentice_draw.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_apprentice_draw.py @@ -18,8 +18,18 @@ derive_is_apprentice, ) from microcosm.build.uk_runtime.national_frame import uk_national_frame +from microcosm.build.uk_runtime.receipt_counts import own_source_households from test_support.microcosm_build.uk_frs_stochastic import _Contract + +def _apprentices(person, **options): + """The draw on a raw frame, where each household is its own source.""" + + return derive_is_apprentice( + person, person_sources=own_source_households(person), **options + ) + + _STATUSES = ("FT_EMPLOYED", "PT_EMPLOYED", "FT_SELF_EMPLOYED", "STUDENT") @@ -55,7 +65,7 @@ def _small(ages, statuses, *, households=None, full_time=None) -> pd.DataFrame: def test_only_employees_aged_21_to_24_are_flagged() -> None: person = _people() - flags = derive_is_apprentice(person, rate=0.06).flags + flags = _apprentices(person, rate=0.06).flags age = person["age"].to_numpy() employee = person["employment_status"].isin(["FT_EMPLOYED", "PT_EMPLOYED"]) @@ -104,7 +114,7 @@ def test_flagged_weight_is_nearest_the_per_head_target() -> None: weights = rng.uniform(100.0, 3000.0, len(person)) rate = 0.06 - draw = derive_is_apprentice(person, rate=rate, person_weights=weights) + draw = _apprentices(person, rate=rate, person_weights=weights) age = person["age"].to_numpy() in_ages = (age >= 21) & (age <= 24) @@ -138,7 +148,7 @@ def test_people_are_flagged_in_the_order_of_their_identity_uniform() -> None: ) weights = np.array([1.0, 1.0, 1.0, 1.0, 5.0, 1.0]) # Five people aged 21 to 24 at 0.4 a head: a target of two people. - draw = derive_is_apprentice(person, rate=0.4, person_weights=weights) + draw = _apprentices(person, rate=0.4, person_weights=weights) draws = stable_identity_uniforms( person["person_id"].to_numpy(), seed=0, salt=APPRENTICE_OUTPUT @@ -148,7 +158,7 @@ def test_people_are_flagged_in_the_order_of_their_identity_uniform() -> None: expected = np.zeros(len(person), dtype=bool) expected[first_two] = True np.testing.assert_array_equal(draw.flags, expected) - reordered = derive_is_apprentice( + reordered = _apprentices( person.iloc[::-1].reset_index(drop=True), rate=0.4, person_weights=weights[::-1], @@ -160,7 +170,7 @@ def test_nobody_is_flagged_when_the_target_is_nearer_zero() -> None: person = _small([22, 30], ["FT_EMPLOYED", "STUDENT"]) # A target of 0.1 people sits nearer zero than the one employee's weight. - draw = derive_is_apprentice(person, rate=0.1, person_weights=np.ones(2)) + draw = _apprentices(person, rate=0.1, person_weights=np.ones(2)) assert not draw.flags.any() assert draw.receipt["realized_mass"] == 0.0 @@ -170,7 +180,7 @@ def test_nobody_is_flagged_when_the_target_is_nearer_zero() -> None: def test_a_short_eligible_weight_flags_every_eligible_employee() -> None: person = _small([21, 22, 23], ["FT_EMPLOYED", "UNEMPLOYED", "UNEMPLOYED"]) - draw = derive_is_apprentice(person, rate=0.9) + draw = _apprentices(person, rate=0.9) np.testing.assert_array_equal(draw.flags, [True, False, False]) assert draw.receipt["cap_bound"] is True @@ -179,7 +189,7 @@ def test_a_short_eligible_weight_flags_every_eligible_employee() -> None: def test_no_eligible_employee_flags_nobody() -> None: person = _small([22, 30], ["STUDENT", "FT_EMPLOYED"]) - draw = derive_is_apprentice(person, rate=0.06) + draw = _apprentices(person, rate=0.06) assert not draw.flags.any() assert draw.receipt["eligible_support"] == 0 @@ -189,7 +199,7 @@ def test_no_eligible_employee_flags_nobody() -> None: def test_receipt_withholds_a_flagged_weight_on_fewer_than_three_households() -> None: person = _small([22] * 20, ["FT_EMPLOYED"] * 20) - draw = derive_is_apprentice(person, rate=0.1) + draw = _apprentices(person, rate=0.1) assert int(draw.flags.sum()) == 2 assert draw.receipt["flagged_support"] == "<3" @@ -206,7 +216,7 @@ def test_receipt_withholds_a_population_on_fewer_than_three_households() -> None households=[1, 1, 1, 2, 2, 2], ) - draw = derive_is_apprentice(person, rate=1 / 6) + draw = _apprentices(person, rate=1 / 6) receipt = draw.receipt assert receipt["population_support"] == "<3" @@ -224,12 +234,12 @@ def test_refuses_a_frame_without_employment_status() -> None: person = pd.DataFrame({"person_id": [1], "person_household_id": [1], "age": [22]}) with pytest.raises(ValueError, match="employment_status"): - derive_is_apprentice(person, rate=0.06) + _apprentices(person, rate=0.06) def test_refuses_a_rate_outside_the_unit_interval() -> None: with pytest.raises(ValueError, match=r"\[0, 1\]"): - derive_is_apprentice(_people(1), rate=1.5) + _apprentices(_people(1), rate=1.5) def _two_household_frame(**extra_person_columns): @@ -313,7 +323,7 @@ def test_receipt_records_the_relief_the_flags_imply() -> None: person = _small([22] * 12, ["FT_EMPLOYED"] * 12).assign(employment_income=pay) # Every employee is flagged: a rate of one a head is cap-bound. - draw = derive_is_apprentice(person, rate=1.0, relief_schedule=_SCHEDULE) + draw = _apprentices(person, rate=1.0, relief_schedule=_SCHEDULE) assert draw.flags.all() relieved = np.clip(np.minimum(pay, 50_270.0) - 9_100.0, 0.0, None) @@ -324,7 +334,7 @@ def test_receipt_records_the_relief_the_flags_imply() -> None: def test_receipt_withholds_a_relief_on_fewer_than_three_households() -> None: person = _small([22] * 2, ["FT_EMPLOYED"] * 2).assign(employment_income=20_000.0) - draw = derive_is_apprentice(person, rate=1.0, relief_schedule=_SCHEDULE) + draw = _apprentices(person, rate=1.0, relief_schedule=_SCHEDULE) assert draw.receipt["implied_relief"] == "<3" @@ -332,7 +342,7 @@ def test_receipt_withholds_a_relief_on_fewer_than_three_households() -> None: def test_receipt_records_no_relief_without_a_schedule() -> None: person = _small([22] * 12, ["FT_EMPLOYED"] * 12).assign(employment_income=1.0) - assert "implied_relief" not in derive_is_apprentice(person, rate=0.5).receipt + assert "implied_relief" not in _apprentices(person, rate=0.5).receipt def test_the_graph_node_reads_every_person_column_the_draw_needs() -> None: diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_annual_income.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_annual_income.py index 74d0a02120..53ec3365f6 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_annual_income.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_annual_income.py @@ -130,6 +130,7 @@ def _derive(people: dict[str, dict], *, growth: float = 0.0): job=job, interview=interview, earnings_growth=growth, + person_sources=own_source_households(person), ) descriptors.index = person["person_id"].to_numpy() return descriptors, receipt, index diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_stochastic.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_stochastic.py index a0b862834e..0a53373f61 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_stochastic.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_stochastic.py @@ -1,6 +1,7 @@ """Tests split from packages/microcosm-build/tests/test_uk_frs_stochastic.py.""" # ruff: noqa: F403, F405 +from microcosm.build.uk_runtime.receipt_counts import own_source_households from test_support.microcosm_build.uk_frs_stochastic import * @@ -93,7 +94,10 @@ def test_person_draws_pin_scp_age_six_boundary_and_uniform_draw() -> None: person = _frame().table("person") derived = derive_frs_person_draws( - person, contract=_Contract(), person_weights=np.ones(len(person)) + person, + contract=_Contract(), + person_weights=np.ones(len(person)), + person_sources=own_source_households(person), ) draws = stable_identity_uniforms( diff --git a/tools/verify_uk_identity_stability.py b/tools/verify_uk_identity_stability.py index e1aaba86dd..d1a8f98e1c 100644 --- a/tools/verify_uk_identity_stability.py +++ b/tools/verify_uk_identity_stability.py @@ -43,6 +43,7 @@ uk_build_identifier_frame, uk_time_period, ) +from microcosm.build.uk_runtime.receipt_counts import own_source_households from microcosm.build.uk_runtime.regional_uprating import ( load_regional_land_values_resource, uprate_household_property_by_region, @@ -152,6 +153,9 @@ def recompute(person_t, benunit_t, household_t) -> dict[str, pd.DataFrame]: person_weights=person_t["person_household_id"] .map(weight_by_household) .to_numpy(dtype=float), + # Only the draws are compared, never the receipt's support + # counts, so each row's household stands as its source. + person_sources=own_source_households(person_t), ) person_draws[UK_UNDER_TWO_USAGE_OUTPUT] = derive_under_two_childcare_usage( person_t, claiming=claiming, contract=contract From 233f7b9e34a107b760226bed77a45adab160b113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Fri, 6 Nov 2026 09:53:13 +0000 Subject: [PATCH 09/20] Refuse the artifact's bare clone_index in the SPI income stage (#931) From the planning review (item 2): the stage filtered FRS training rows on `clone_index == 0`, the artifact's column name. No spine stage writes it, since the spine names it `household_clone_index` and `expand_uk_geographic_pool` drops a bare `clone_index`, so the filter did nothing. But a frame that carried it would train clone 0 at clone 0's own weight, not at the fold's summed weight. The stage now refuses such a table, and a test checks it. The `_dead_support` fixture drops the column after its support rebuild. Its four households then all train, so: - the engine tests count four and three reference rows, not two and one; - the engine tests count the reference forest's fits from the transport's fold receipts, one per fold that scores a recipient; - the replicated test no longer drops the column itself. Co-Authored-By: Claude Opus 5.5 --- .../microcosm/build/uk_runtime/spi_income.py | 11 +++++- .../tests/engine/uk/test_uk_spi_income.py | 38 ++++++------------- .../engine_free/uk/test_uk_spi_income.py | 27 ++++++++++++- test_support/microcosm_build/uk_spi_income.py | 5 ++- 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py index 710023dafe..642d30034b 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py @@ -1512,9 +1512,16 @@ def impute_uk_spi_income_support( if SPI_STAGE1_ANALOGUE_COLUMNS.get(column) == column and column not in person: person[column] = 0.0 - base_household = household[household_channel] == BASE_FRS_SUPPORT_CHANNEL + # The spine never carries the artifact's bare clone_index: geographic + # clones are read from the lineage and folded below, so a table that + # carried it would train clone 0 at clone 0's own weight (microcosm#931). if "clone_index" in household: - base_household &= household["clone_index"] == 0 + raise ValueError( + "The SPI income stage refuses a household table carrying the " + "artifact's clone_index; geographic clones are read from the " + "household lineage and folded into their survey records." + ) + base_household = household[household_channel] == BASE_FRS_SUPPORT_CHANNEL training_household_ids = set(household.loc[base_household, "household_id"]) training_people = base_people & person["person_household_id"].isin( training_household_ids diff --git a/packages/microcosm-build/tests/engine/uk/test_uk_spi_income.py b/packages/microcosm-build/tests/engine/uk/test_uk_spi_income.py index 5b27175153..a9bd28cc85 100644 --- a/packages/microcosm-build/tests/engine/uk/test_uk_spi_income.py +++ b/packages/microcosm-build/tests/engine/uk/test_uk_spi_income.py @@ -376,11 +376,12 @@ def test_spi_qrf_stages_use_typed_weights_and_keep_isa_interest_apart( allow_in_sample_reference=True, ) - # The reference forest is fitted once per cross-fit fold in use (the - # transport receipt's ``folds``), all under its one fit record. + # The reference forest is fitted once per cross-fit fold that scores a + # recipient (the transport receipt's fold receipts), all under its one + # fit record. assert _FakeQRF.fit_weight_kinds == [ "design", - *["importance"] * result.stage1_transport["folds"], + *["importance"] * len(result.stage1_transport["fold_receipts"]), "importance", ] assert [ @@ -390,20 +391,12 @@ def test_spi_qrf_stages_use_typed_weights_and_keep_isa_interest_apart( ("uk_frs_reference_conditional", "importance"), ("uk_frs_only_spi_fill", "importance"), ] - # The reference forest trains on the clone-0 FRS claimants and partners - # with taxable income: two of the fixture's four households are clone 0. - clone_zero = support.household.loc[ - support.household["clone_index"] == 0, "household_id" - ] + # The reference forest trains on the FRS claimants and partners with + # taxable income, in every one of the fixture's four households. assert ( result.reference_training_rows - == int( - ( - (support.person[support_channel_column("person")] == "frs") - & support.person["person_household_id"].isin(clone_zero) - ).sum() - ) - == 2 + == int((support.person[support_channel_column("person")] == "frs").sum()) + == 4 ) assert result.state_pension_age == 66 assert result.stage1_transport["draw"] == "twin_conditional_quantiles" @@ -923,17 +916,10 @@ def test_undrawn_twins_keep_their_values_and_are_receipted( assert domain["recipient_rows"] == len(others) == result.spi_prediction_rows assert domain["unearned_income_floor_gbp"] == 1_000.0 assert "no tax record" in domain["income_rule"] - # The reference forest trains on the clone-0 FRS rows with taxable income - # only: two of the fixture's households are clone 0, and one twin is kept. - clone_zero = support.household.loc[ - support.household["clone_index"] == 0, "household_id" - ] - reference_rows = ( - (person[channel] == "frs") - & person["person_household_id"].isin(clone_zero) - & ~person.index.isin(twin) - ) - assert result.reference_training_rows == int(reference_rows.sum()) == 1 + # The reference forest trains on the FRS rows with taxable income only: + # every FRS row but the kept twin's. + reference_rows = (person[channel] == "frs") & ~person.index.isin(twin) + assert result.reference_training_rows == int(reference_rows.sum()) == 3 # A reserved band carrier is drawn whatever its twin reports. carrier = person.copy() carrier["person_is_spi_income_band_carrier"] = False diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py index d76f616569..3291ac47ba 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py @@ -1533,6 +1533,31 @@ def _geographic_clones_of(support): ) +def test_a_household_table_carrying_the_artifact_clone_index_is_refused( + monkeypatch, tmp_path +) -> None: + """No spine stage writes the artifact's bare clone_index, and a table + carrying it would train clone 0 at its own weight rather than the fold's + (microcosm#931).""" + + support = _dead_support() + donor_path = tmp_path / SPI_DONOR_FILENAME + _write_donor(donor_path) + monkeypatch.setattr(spi_income, "QRF", _FakeQRF) + _bypass_reviewed_donor_identity(monkeypatch) + with pytest.raises(ValueError, match="artifact's clone_index"): + impute_uk_spi_income_support( + _replace(support, household=support.household.assign(clone_index=0)), + donor_path, + seed=9, + n_estimators=3, + donor_sample_size=None, + state_pension_age=66, + allow_in_sample_reference=True, + stage1_gate_calibration="cross_fitted", + ) + + def test_geographic_clones_train_the_frs_forests_as_their_survey_records( monkeypatch, tmp_path ) -> None: @@ -1541,8 +1566,6 @@ def test_geographic_clones_train_the_frs_forests_as_their_survey_records( them alone (microcosm#931).""" support = _dead_support() - # The legacy artifact clone filter would drop rows the pool does not. - support = _replace(support, household=support.household.drop(columns="clone_index")) donor_path = tmp_path / SPI_DONOR_FILENAME _write_donor(donor_path) monkeypatch.setattr(spi_income, "QRF", _FakeQRF) diff --git a/test_support/microcosm_build/uk_spi_income.py b/test_support/microcosm_build/uk_spi_income.py index b0fdaf28eb..648d8ac2a6 100644 --- a/test_support/microcosm_build/uk_spi_income.py +++ b/test_support/microcosm_build/uk_spi_income.py @@ -252,13 +252,16 @@ def _dead_support( selected_household_ids=(1, 2, 3, 4), source_year=2023, ) - return replace_uk_spi_support_tables( + support = replace_uk_spi_support_tables( person=dead.person, benunit=dead.benunit, household=dead.household, seed=7, source_year=2023, ) + # The SPI income stage refuses the artifact's bare clone_index, which no + # spine stage writes (microcosm#931). + return replace(support, household=support.household.drop(columns="clone_index")) def _write_donor(path: Path, *, drop: str | None = None) -> None: From a7c18ec9240253908e68000ed1f0132300635479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Fri, 6 Nov 2026 10:04:07 +0000 Subject: [PATCH 10/20] Note the UC capital donor floor, Scotland's band mix and #893's doc text (#931) Three review notes, none of which changes code behaviour: - **UC capital (Vahid, item 1).** The note says `UC_CAPITAL_MINIMUM_CELL_DONORS` counts a cell's donor benefit-unit rows after the geographic fold, so a high-value copy counts as a donor of its own. It is a row threshold, not a disclosure floor. Whether it should count true sources is for the move's audit of K-sensitive constants, since switching it can move outputs. - **Scotland (Vahid, item 3).** The conditioned supports' provenance now notes that Scotland's band mix is its council's, so within a council a household is placed in proportion to households. It names a mix by 2022 data zone as the way to lift that, once one is registered in Chronicle. The support bytes are unchanged. - **The US doc passages (planning review, item 3).** `docs/geography-assignment.md` notes, at the head of each, that the US passages describe microcosm#893, which closed unmerged on 9 October 2026. Co-Authored-By: Claude Opus 5.5 --- docs/geography-assignment.md | 12 ++++++++++++ ..._atomic_area_conditioned_supports.provenance.json | 3 ++- .../build/uk_runtime/uc_capital_coherence.py | 6 ++++++ tools/build_uk_conditioned_area_supports.py | 6 ++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/geography-assignment.md b/docs/geography-assignment.md index 7d1d3b4874..e00b9248b2 100644 --- a/docs/geography-assignment.md +++ b/docs/geography-assignment.md @@ -7,6 +7,10 @@ area using identified, versioned mappings. Distinct clones may receive different areas subject to their observed source constraints. The assigned location then remains fixed through subsequent enrichment, calibration and analysis views. +> These US passages describe the work of PolicyEngine/microcosm#893, which +> closed unmerged on 9 October 2026. Its modules, graphs and receipts never +> reached main. + The earlier block-before-clone implementation and its passing controls remain historical evidence. They do not demonstrate this corrected ordering. Geographic assignment must use a stable post-clone identity, including a clone discriminator @@ -164,6 +168,10 @@ checks mapping integrity, while the executor and build own structural lineage and population-quality acceptance. The country's chosen identity still needs verification across actual sampling rungs. +> These US passages describe the work of PolicyEngine/microcosm#893, which +> closed unmerged on 9 October 2026. Its modules, graphs and receipts never +> reached main. + The US development composed graph attaches geography after harmonization, but `us_runtime/graph_geography.py` selects a joint tract/congressional-district cell and emits PUMA, county and district. It does not assign a Census block. Its prior @@ -226,6 +234,10 @@ using the modal active-postcode constituency. Review the official before choosing or replacing that approximation. Source existence is not acceptance of a particular lookup or its application to the population. +> These US passages describe the work of PolicyEngine/microcosm#893, which +> closed unmerged on 9 October 2026. Its modules, graphs and receipts never +> reached main. + The US block adapter in `us_runtime/atomic_block_support.py` now preserves each supplied block, leading zeroes, population weight and the source-labeled tract-to-PUMA and block-to-district mappings. Its declaration uses the shared diff --git a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json index 0cc5652aa1..9f854b2bbe 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json +++ b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json @@ -15,7 +15,8 @@ "imd_decile is the 2019 vintage of each nation's index (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017): the FRS 2024-25 variables IMDE, IMDW, IMDS and IMDN carry no change note from 2023-24, which predates the 2025 indices, and on an internal comparison England's FRS decile shares by region fit IoD 2019 better than IoD 2025, as the 2023-24 FRS does. The vintage is still to be confirmed with DWP.", "An area's decile is the one most of its live small-user postcodes carry in the May 2026 NSPL (oa21cd: the 2021 output area in England and Wales, the 2022 output area in Scotland, the 2021 data zone in Northern Ireland). Ranks are within-nation only.", "Northern Ireland's SOAs (2001) do not nest in its 2021 data zones, so many data zones' postcodes span deciles; the modal decile is recorded with relation inferred_modal and the counts below.", - "England and Wales band weights read each area's LSOA mix as committed (shares to 6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read its council's chargeable dwellings, rounded half to even per band." + "England and Wales band weights read each area's LSOA mix as committed (shares to 6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read its council's chargeable dwellings, rounded half to even per band.", + "Scotland's band mix is its council's, so a band moves mass only between councils: within a council a household is placed in proportion to households, where England and Wales use each LSOA's mix. A mix by 2022 data zone, in which the 2022 output areas nest (such as NRS's small area statistics on households and dwellings), would give Scotland the same within-council resolution. No such source is registered in Chronicle yet." ], "publisher_files": { "iod2019": { diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py index b1384d25fa..4c7a84d910 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py @@ -65,6 +65,12 @@ #: GBP 6,000, 16,000, 50,000 and 200,000 of capital yield at 4%, then above. UC_CAPITAL_INCOME_BAND_EDGES = (0.0, 240.0, 640.0, 2_000.0, 8_000.0) UC_CAPITAL_IMPLIED_YIELD = 0.04 +#: The donors a cell needs before it stops widening. It counts the cell's +#: donor benefit-unit rows after the geographic fold, so a high-value +#: support copy counts as a donor of its own. It is a row threshold, not a +#: disclosure floor. Whether it should count true sources is for the +#: geography-first move's audit of K-sensitive constants (microcosm#931), +#: since switching it can move outputs. UC_CAPITAL_MINIMUM_CELL_DONORS = 20 #: The declared order in which a cell short of donors widens; reporter status #: is never coarsened. diff --git a/tools/build_uk_conditioned_area_supports.py b/tools/build_uk_conditioned_area_supports.py index 797a9e7100..fcd551b894 100644 --- a/tools/build_uk_conditioned_area_supports.py +++ b/tools/build_uk_conditioned_area_supports.py @@ -181,6 +181,12 @@ "England and Wales band weights read each area's LSOA mix as committed (shares to " "6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read " "its council's chargeable dwellings, rounded half to even per band.", + "Scotland's band mix is its council's, so a band moves mass only between councils: " + "within a council a household is placed in proportion to households, where England " + "and Wales use each LSOA's mix. A mix by 2022 data zone, in which the 2022 output " + "areas nest (such as NRS's small area statistics on households and dwellings), " + "would give Scotland the same within-council resolution. No such source is " + "registered in Chronicle yet.", ) From 94befd186b453f2c10ad68f3319b266679717b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Fri, 6 Nov 2026 10:29:02 +0000 Subject: [PATCH 11/20] Fold only clones that agree on what each fit reads (#931) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From Vahid's review (item 2) and the planning review (item 1), with María's ruling to keep each variant. The fold kept a record's first clone at the clones' summed weight even when the clones differ on what the fit reads. Once the move gives clones their own ids, they will differ: a landlord's finance costs are drawn on uniforms keyed by person id, and reach the UC reporter redraw through benefit-unit investment income. The fold dropped every clone's value but the first. How the fold works now: - `collapse_replicas` takes the fit's `inputs`, one row per record, and folds replicas only where they agree on every input; a missing value agrees only with a missing value. - Replicas that differ stay rows of their own. Each distinct variant keeps its first record, with the summed weight of the replicas that share it, so the fit sees every clone's value at its share and nothing is dropped. - `collapse_geographic_clones` requires `inputs`, so no fit folds blind. The seven fits pass what they read: - the housing shell its predictors and targets; - the UC reporter redraw its predictors and the reported amount; - UC capital its cell keys and the capital it donates; - salary sacrifice its predictors and sacrifice; - the employment shell its predictors, occupation and donated industry; - the SPI stage the raw columns its two forests derive from at fold time. Today's spine has no geographic clones, so every fit's rows and weights are unchanged, value for value. Tests: - shared tests pin the variant rule, missing values and refusals; - the sweep test adds a record whose clones differ; - a replicated fixture moves one clone's property income by 500, and the UC reporter redraw then trains on both variants at half the unit's weight each, while every other unit folds. Co-Authored-By: Claude Opus 5.5 --- ...31-uk-fits-fold-geographic-clones.added.md | 19 ++++++- docs/uk-atomic-household-lineage.md | 3 +- .../src/microcosm/build/source_lineage.py | 43 +++++++++++++-- .../build/uk_runtime/household_lineage.py | 12 ++++- .../build/uk_runtime/salary_sacrifice.py | 9 ++-- .../build/uk_runtime/spi_employment_shell.py | 22 ++++++-- .../build/uk_runtime/spi_housing_shell.py | 18 +++++-- .../microcosm/build/uk_runtime/spi_income.py | 45 ++++++++++++++-- .../build/uk_runtime/uc_capital_coherence.py | 22 ++++++-- .../build/uk_runtime/uc_reporter_redraw.py | 14 +++-- .../engine_free/shared/test_source_lineage.py | 53 +++++++++++++++++++ .../uk/test_uk_geographic_clone_collapse.py | 45 ++++++++++++++-- .../uk/test_uk_uc_reporter_redraw.py | 39 ++++++++++++++ 13 files changed, 308 insertions(+), 36 deletions(-) diff --git a/changelog.d/931-uk-fits-fold-geographic-clones.added.md b/changelog.d/931-uk-fits-fold-geographic-clones.added.md index b58f0b7757..4cc44ba98e 100644 --- a/changelog.d/931-uk-fits-fold-geographic-clones.added.md +++ b/changelog.d/931-uk-fits-fold-geographic-clones.added.md @@ -1 +1,18 @@ -The UK fits trained on the frame's FRS rows now fold geographic clones into each survey record before they fit (#931): the SPI stage-2 and reference forests, the housing shell, the UC reporter redraw, the UC capital donor cells and the salary-sacrifice forest. A record keeps its first row among the training rows, with the weight of all its geographic clones summed exactly; SPI, high-value and CGT copies stay rows of their own, as now. Today's spine has no geographic clones, so every fit's rows and weights stay as they were, value for value; once the spine clones before enrichment, the fits see each record once, the reference transport no longer meets duplicate twins, and the UC capital cells' donor minimum counts records, not clones. The machinery is country-neutral: `microcosm.build.source_lineage` gains `copy_paths` (every household's ordered copy path from a declared lineage, never inferred from ids, weights or values), `replica_keys` (a key per record of any entity that only its replicas in the named branches share, a member's rank in its household telling members apart) and `collapse_replicas`; `household_lineage.collapse_geographic_clones` is the UK's entry, and `uk_household_clone_paths` now reads the clone path through `copy_paths` on `UK_COPY_LINEAGE`, with identical paths and draw keys (three identity-test messages name the shared reader's branches). The housing shell and UC capital stages declare the lineage live where they run, a test refuses a collapsing stage whose surface would hide one, and replicated-fixture tests hold each fit to the rows and weights it fits without clones. The SPI income stage also binds `spi_rank_transport` into its hash. +The UK fits trained on the frame's FRS rows now fold geographic clones into each survey record before they fit (#931). This covers the SPI stage-2 and reference forests, the housing shell, the UC reporter redraw, the UC capital donor cells, the salary-sacrifice forest and the SPI employment shell. + +- **How the fold works.** Each fit passes what it reads: its predictors and targets, or the columns they derive from. A record's clones that agree on it keep the record's first training row, with the weight of those clones summed exactly. Clones that differ, through a draw keyed on their own ids or a stage run per area, stay rows of their own, each variant with its own clones' summed weight. SPI, high-value and CGT copies stay rows of their own, as now. +- **No change today.** Today's spine has no geographic clones, so every fit's rows and weights stay as they were, value for value. +- **What changes once the spine clones before enrichment:** + - the fits see each record once wherever its clones agree, and every clone's value at its share wherever they differ; + - the reference transport meets no duplicate twins from agreeing clones; + - the UC capital cells' donor minimum counts records, not identical clones. +- **The country-neutral pieces.** `microcosm.build.source_lineage` gains three functions: + - `copy_paths`: every household's ordered copy path from a declared lineage, never inferred from ids, weights or values; + - `replica_keys`: a key per record of any entity, shared only by its replicas in the named branches, with a member's rank in its household telling members apart; + - `collapse_replicas`: the fold itself, which takes the fit's `inputs` and folds only replicas that agree on them. +- **The UK entry.** `household_lineage.collapse_geographic_clones` is the UK's entry and requires those inputs. `uk_household_clone_paths` now reads the clone path through `copy_paths` on `UK_COPY_LINEAGE`, with identical paths and draw keys; three identity-test messages name the shared reader's branches. +- **Declarations and tests.** + - The collapsing stages declare the lineage live where they run, and a test refuses one whose surface would hide it. + - Replicated-fixture tests hold each fit to the rows and weights it fits without clones. + - A fixture with differing clones (a landlord's property income drawn apart) holds the UC reporter redraw to training on both variants at half the unit's weight each. +- **Hashing.** The SPI income stage also binds `spi_rank_transport` into its hash. diff --git a/docs/uk-atomic-household-lineage.md b/docs/uk-atomic-household-lineage.md index aa69606dc5..d5c10c3f76 100644 --- a/docs/uk-atomic-household-lineage.md +++ b/docs/uk-atomic-household-lineage.md @@ -29,7 +29,8 @@ The UK's copy lineage is declared once, as data, in `uk_runtime.household_lineag - `record_sources` gives every record of any entity its true source through household membership. Every UK floor counts distinct sources through it (`receipt_counts.record_source_households`), so a household's copies and clones count once. - `copy_paths` reads every household's ordered clone path; `uk_household_clone_paths` is the UK's strict entry for the identity kernel. -- `replica_keys` and `collapse_replicas` keep one training row per true source and path without the geographic branch, with the clones' weights summed. The FRS-trained fits (the SPI stage-2 and reference forests, the housing shell, the UC reporter redraw, the UC capital donor cells and the salary-sacrifice forest) fold their training rows through `household_lineage.collapse_geographic_clones`, so once geographic clones precede enrichment each fit still sees each survey record once. A frame without geographic clones keeps its rows and weights value for value. +- `replica_keys` and `collapse_replicas` keep one training row per true source and path without the geographic branch, with the clones' weights summed. The FRS-trained fits fold their training rows through `household_lineage.collapse_geographic_clones`: the SPI stage-2 and reference forests, the housing shell, the UC reporter redraw, the UC capital donor cells, the salary-sacrifice forest and the SPI employment shell. Once geographic clones precede enrichment, each fit still sees each survey record once. A frame without geographic clones keeps its rows and weights value for value. +- Each fit passes what it reads (its predictors and targets, or the columns they derive from), and clones fold only where they agree on it. Clones that differ, through a draw keyed on their own ids or a stage run per area, stay rows of their own. Each variant carries the summed weight of the clones that share it, so the fit sees every clone's value at its share and nothing is dropped. ## Verification scope diff --git a/packages/microcosm-build/src/microcosm/build/source_lineage.py b/packages/microcosm-build/src/microcosm/build/source_lineage.py index 732183bdde..b3b48265cc 100644 --- a/packages/microcosm-build/src/microcosm/build/source_lineage.py +++ b/packages/microcosm-build/src/microcosm/build/source_lineage.py @@ -330,7 +330,11 @@ def replica_keys( def collapse_replicas( - keys: np.ndarray, rows: np.ndarray, weights: np.ndarray + keys: np.ndarray, + rows: np.ndarray, + weights: np.ndarray, + *, + inputs: pd.DataFrame | None = None, ) -> tuple[np.ndarray, np.ndarray]: """Keep the first of each key's ``rows``, carrying the key's summed weight. @@ -341,6 +345,14 @@ def collapse_replicas( replicas leave the selection. Weights off the selection are returned unchanged. When no two selected records share a key, the selection and weights are returned as they were, value for value. + + ``inputs`` holds, one row per record, what the fit reads: its predictors + and targets, or the columns they derive from. Replicas then fold only + where they agree on every one of those columns. Replicas that differ stay + rows of their own: each distinct variant keeps its first record, with + the summed weight of the replicas that share it, so the fit sees every + variant at its share and nothing is dropped (microcosm#931). A missing + value agrees only with a missing value. """ keys = np.asarray(keys, dtype=object) @@ -349,11 +361,32 @@ def collapse_replicas( if not (len(keys) == len(selected) == len(values)): raise ValueError("Replica keys, rows and weights must align.") positions = np.flatnonzero(selected) - codes, uniques = pd.factorize(pd.Series(keys[positions], dtype=object), sort=False) - if len(uniques) == len(positions): + if inputs is None: + codes, uniques = pd.factorize( + pd.Series(keys[positions], dtype=object), sort=False + ) + groups = len(uniques) + else: + if not isinstance(inputs, pd.DataFrame) or len(inputs) != len(keys): + raise ValueError("Replica inputs must be a frame with one row per record.") + if not inputs.columns.is_unique: + raise ValueError("Replica inputs must name each column once.") + table = inputs.iloc[positions].reset_index(drop=True) + table.columns = [f"input:{index}" for index in range(table.shape[1])] + for column in table.columns: + if isinstance(table[column].dtype, pd.CategoricalDtype): + table[column] = table[column].astype(object) + table.insert(0, "key", pd.Series(keys[positions], dtype=object)) + codes = ( + table.groupby(list(table.columns), sort=False, dropna=False, observed=True) + .ngroup() + .to_numpy() + ) + groups = int(codes.max()) + 1 if len(codes) else 0 + if groups == len(positions): return selected, values - first = np.full(len(uniques), -1, dtype=np.int64) - members: list[list[float]] = [[] for _ in range(len(uniques))] + first = np.full(groups, -1, dtype=np.int64) + members: list[list[float]] = [[] for _ in range(groups)] for position, code in zip(positions.tolist(), codes.tolist(), strict=True): if first[code] < 0: first[code] = position diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py index c1fead681a..2adfc71827 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/household_lineage.py @@ -159,6 +159,8 @@ def collapse_geographic_clones( entity: str, rows: np.ndarray, weights: np.ndarray, + *, + inputs: pd.DataFrame, ) -> tuple[np.ndarray, np.ndarray]: """A fit's training rows with each record's geographic clones folded in. @@ -169,7 +171,13 @@ def collapse_geographic_clones( without the geographic branch, through the shared reader (``microcosm.build.source_lineage``); a frame without geographic clones, as every spine is today, keeps ``rows`` and ``weights`` value for value. - Returns the kept rows and the weights over every row of ``entity``. + + ``inputs`` is what the fit reads, one row per row of ``entity``. Clones + fold only where they agree on it. Clones that differ, through a draw + keyed on their own ids or a stage run per area, stay rows of their own, + each variant with its clones' summed weight, so the fit sees each + clone's value at its share. Returns the kept rows and the weights over + every row of ``entity``. """ keys = replica_keys( @@ -179,7 +187,7 @@ def collapse_geographic_clones( UK_COPY_LINEAGE, merge=(GEOGRAPHIC_SUPPORT_BRANCH,), ) - return collapse_replicas(keys, rows, weights) + return collapse_replicas(keys, rows, weights, inputs=inputs) def without_geographic_branch( diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py index fd4c9c39ef..11986721a5 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/salary_sacrifice.py @@ -614,14 +614,17 @@ def impute_salary_sacrifice( ) person_weights = person_households.map(household_weights).to_numpy(dtype=float) # The forest trains on each asked respondent once: their geographic - # clones fold into their first row with their weight, and every other copy - # stays its own row; a frame without geographic clones keeps every row and - # weight (household_lineage.collapse_geographic_clones, microcosm#931). + # clones that agree on the predictors and the sacrifice fold into their + # first row with their weight, clones that differ stay rows of their own, + # and every other copy stays its own row; a frame without geographic + # clones keeps every row and weight + # (household_lineage.collapse_geographic_clones, microcosm#931). kept, fit_weights = collapse_geographic_clones( {"person": person, "household": household}, "person", training_mask.to_numpy(dtype=bool), person_weights, + inputs=numeric[[*SALSAC_PREDICTORS, SALSAC_OUTPUT]].reset_index(drop=True), ) training_mask = pd.Series(kept, index=training_mask.index) training = numeric.loc[training_mask, [*SALSAC_PREDICTORS, SALSAC_OUTPUT]].copy() diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_employment_shell.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_employment_shell.py index 80a0ab927b..e2dd08f659 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_employment_shell.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_employment_shell.py @@ -554,11 +554,25 @@ def impute_spi_employment_shell( if not training.any(): raise ValueError(f"{stage} needs FRS adults with an occupation to train on.") # The fit and the donors see each survey record once: its geographic - # clones fold into its first row with their weight, and every other copy - # stays its own row; a frame without geographic clones keeps every row - # and weight (household_lineage.collapse_geographic_clones, microcosm#931). + # clones that agree on the predictors, the occupation and the industry it + # donates fold into its first row with their weight, clones that differ + # stay rows of their own, and every other copy stays its own row; a frame + # without geographic clones keeps every row and weight + # (household_lineage.collapse_geographic_clones, microcosm#931). training, fit_weights = collapse_geographic_clones( - {"person": person, "household": household}, "person", training, weights + {"person": person, "household": household}, + "person", + training, + weights, + inputs=pd.concat( + [ + table[[*OCCUPATION_PREDICTORS, OCCUPATION_COLUMN]].reset_index( + drop=True + ), + person[list(INDUSTRY_COLUMNS)].reset_index(drop=True), + ], + axis=1, + ), ) # The training rows in person_id order, so neither the fit (the early diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_housing_shell.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_housing_shell.py index 73918be60a..6135b5c1b1 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_housing_shell.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_housing_shell.py @@ -540,15 +540,25 @@ def impute_spi_housing_shell( weights = pd.Series( np.asarray(household_weights, dtype=float), index=household["household_id"] ) + predictors = household_housing_predictors(person, household) + targets = household_housing_targets(person, household) # The model trains on each survey household once: its geographic clones - # fold into its first row with their weight, and every other copy stays - # its own row; a frame without geographic clones keeps every row and - # weight (household_lineage.collapse_geographic_clones, microcosm#931). + # that agree on the predictors and targets fold into its first row with + # their weight, clones that differ stay rows of their own, and every + # other copy stays its own row; a frame without geographic clones keeps + # every row and weight (household_lineage.collapse_geographic_clones, + # microcosm#931). training, fit_weights = collapse_geographic_clones( {"household": household}, "household", (channel == FRS_CHANNEL) & (weights.to_numpy() > 0.0), weights.to_numpy(), + inputs=pd.concat( + [predictors.add_prefix("predictor:"), targets.add_prefix("target:")], + axis=1, + ) + .reindex(household["household_id"].to_numpy()) + .reset_index(drop=True), ) fit_weights = pd.Series(fit_weights, index=household["household_id"]) training_ids = household.loc[training, "household_id"] @@ -556,8 +566,6 @@ def impute_spi_housing_shell( if training_ids.empty or recipient_ids.empty: raise ValueError("Housing shell needs FRS training rows and SPI recipients.") - predictors = household_housing_predictors(person, household) - targets = household_housing_targets(person, household) model = fit_housing_model( predictors.loc[training_ids], targets.loc[training_ids], diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py index 642d30034b..c4dd0fb27c 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spi_income.py @@ -82,6 +82,7 @@ SPI_TRANSPORT_FOLDS, SPI_TRANSPORT_KEY_COLUMN, SPI_TRANSPORT_SEED_OFFSET, + analogue_source_columns, analogue_targets, assert_analogue_map_covers, cell_fold_ids, @@ -1529,14 +1530,17 @@ def impute_uk_spi_income_support( if not training_people.any(): raise ValueError("FRS-only stage has no canonical base training rows.") # Both forests train on each survey record once: its geographic clones - # fold into its first row with their weight, and every other copy stays - # its own row; a frame without geographic clones keeps every row and - # weight (household_lineage.collapse_geographic_clones, microcosm#931). + # that agree on what the forests read fold into its first row with their + # weight, clones that differ stay rows of their own, and every other + # copy stays its own row; a frame without geographic clones keeps every + # row and weight (household_lineage.collapse_geographic_clones, + # microcosm#931). kept, training_weight_values = collapse_geographic_clones( {"person": person, "household": household}, "person", training_people.to_numpy(dtype=bool), person_weights.to_numpy(dtype=np.float64), + inputs=_forest_inputs(person, household), ) training_people = pd.Series(kept, index=person.index) training_weights = pd.Series(training_weight_values, index=person.index) @@ -3283,6 +3287,41 @@ def _hmrc_auxiliary_row_mask( return mask +def _forest_inputs(person: pd.DataFrame, household: pd.DataFrame) -> pd.DataFrame: + """What the reference and stage-2 forests read of each person, one row each. + + The columns their predictors derive from, the reference rows' rule, and + both forests' targets: a record's geographic clones fold where they + agree on these (microcosm#931). The stage's later steps derive the fit + frames from them deterministically, so clones that agree here agree + there. + """ + + columns = [ + column + for column in dict.fromkeys( + ( + "age", + "gender", + SPI_RECIPIENT_ROLE_COLUMN, + ISA_INTEREST_COLUMN, + *FRS_ONLY_SPI_FILL_INCOME_PREDICTOR_COLUMNS, + *_BRIDGE_PERSON_COLUMNS, + *_UNEARNED_INCOME_COLUMNS, + *analogue_source_columns(), + *FRS_ONLY_SPI_FILL_PERSON_COLUMNS, + ) + ) + if column in person.columns + ] + region = household.set_index("household_id")["region"] + return ( + person[columns] + .reset_index(drop=True) + .assign(household_region=person["person_household_id"].map(region).to_numpy()) + ) + + def _person_predictors( person: pd.DataFrame, household: pd.DataFrame, diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py index 4c7a84d910..07f8d44e08 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_capital_coherence.py @@ -651,10 +651,11 @@ def _redraw_spi_capital( dependent-children band. A cell with fewer than ``minimum_cell_donors`` donors widens in the declared ``UC_CAPITAL_COARSENING`` order; reporter status is never coarsened, and an empty reporter-status pool refuses. - Each survey benefit unit donates once, its geographic clones folded into - its first row with their weight, so a cell's donor count does not grow - with the clones (``household_lineage.collapse_geographic_clones``, - microcosm#931). Returns the number of redrawn units drawn at each level. + Each survey benefit unit donates once, its geographic clones that agree + on its cell and capital folded into its first row with their weight, so + a cell's donor count does not grow with identical clones + (``household_lineage.collapse_geographic_clones``, microcosm#931). + Returns the number of redrawn units drawn at each level. """ if not isinstance(minimum_cell_donors, int) or minimum_cell_donors <= 0: @@ -663,12 +664,23 @@ def _redraw_spi_capital( couple = frs_uc_couple_mask(person, benunit) income_band = _investment_income_band(investment) last_band = len(UC_CAPITAL_INCOME_BAND_EDGES) - # Domain-validated upstream: every non-sentinel value is >= 0. + # Domain-validated upstream: every non-sentinel value is >= 0. A donor's + # clones fold where they agree on its cell and the capital it donates; + # clones that differ donate apart, each with its clones' weight. donor, donor_weight = collapse_geographic_clones( {"person": person, "benunit": benunit, "household": household}, "benunit", base & (capital >= 0.0) & (weights > 0.0), weights, + inputs=pd.DataFrame( + { + "reporter": np.asarray(reporter), + "income_band": np.asarray(income_band), + "couple": np.asarray(couple), + "child_band": np.asarray(child_band), + "capital": np.asarray(capital), + } + ), ) target_ids = benunit["benunit_id"].to_numpy() draws = stable_identity_uniforms( diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_reporter_redraw.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_reporter_redraw.py index a337d42e57..3bd5cf1abb 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_reporter_redraw.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/uc_reporter_redraw.py @@ -320,15 +320,21 @@ def redraw_spi_reported_uc( "UC reporter redraw has no screened canonical FRS training rows." ) # The forest trains on each screened benefit unit once: its geographic - # clones fold into its first row with their weight, and every other copy - # stays its own row; a frame without geographic clones keeps every row - # and weight (household_lineage.collapse_geographic_clones, microcosm#931). - # The screen is each row's own engine output, so the fold follows it. + # clones that agree on the predictors and the reported amount fold into + # its first row with their weight, clones that differ (a member's + # property income drawn on its own id, say) stay rows of their own, and + # every other copy stays its own row; a frame without geographic clones + # keeps every row and weight (household_lineage.collapse_geographic_clones, + # microcosm#931). The screen is each row's own engine output, so the fold + # follows it. training, fit_weights = collapse_geographic_clones( {"person": person, "benunit": benunit, "household": household}, "benunit", training, weights, + inputs=predictors.reset_index(drop=True).assign( + **{UC_REPORTER_TARGET: np.asarray(reported_before)} + ), ) if float(fit_weights[training].sum()) <= 0.0: raise ValueError("UC reporter redraw training weights must have positive mass.") diff --git a/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py b/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py index b205bab630..1656bc9bc5 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_source_lineage.py @@ -263,3 +263,56 @@ def test_a_selection_without_replicas_keeps_its_rows_and_weights() -> None: assert summed.tobytes() == weights.tobytes() with pytest.raises(ValueError, match="align"): collapse_replicas(keys, rows[:2], weights) + + +def test_replicas_fold_only_where_they_agree_on_the_inputs() -> None: + """Each distinct variant keeps its first record and its replicas' weight + (microcosm#931).""" + + keys = np.asarray(["a", "a", "a", "a", "b", "b"], dtype=object) + rows = np.ones(6, dtype=bool) + weights = np.asarray([0.1, 0.2, 0.3, 0.4, 0.5, 0.5]) + inputs = pd.DataFrame( + { + "income": [3.0, 0.0, 3.0, np.nan, 7.0, 7.0], + "band": pd.Categorical(["x", "x", "x", "x", "y", "y"]), + } + ) + kept, summed = collapse_replicas(keys, rows, weights, inputs=inputs) + # a holds three variants (3.0 twice, 0.0, missing); b agrees and folds. + assert kept.tolist() == [True, True, False, True, True, False] + assert summed[kept].tolist() == [ + pytest.approx(0.4), + 0.2, + 0.4, + 1.0, + ] + # The record's weight is kept whole across its variants. + assert np.isclose(summed[kept][:3].sum(), 1.0) + # A missing value agrees only with a missing value. + both_missing = inputs.assign(income=[np.nan, np.nan, 3.0, 3.0, 7.0, 7.0]) + kept, _ = collapse_replicas(keys, rows, weights, inputs=both_missing) + assert kept.tolist() == [True, False, True, False, True, False] + + +def test_agreeing_inputs_fold_as_the_keys_alone_do() -> None: + keys = np.asarray(["a", "b", "a", "c", "b", "a"], dtype=object) + rows = np.asarray([True, True, True, False, True, True]) + weights = np.asarray([0.1, 0.2, 0.2, 9.0, 0.3, 0.7]) + alone = collapse_replicas(keys, rows, weights) + agreeing = collapse_replicas( + keys, rows, weights, inputs=pd.DataFrame({"value": np.ones(6)}) + ) + assert alone[0].tolist() == agreeing[0].tolist() + assert alone[1].tobytes() == agreeing[1].tobytes() + + +def test_inputs_must_align_and_name_each_column_once() -> None: + keys = np.asarray(["a", "a"], dtype=object) + rows = np.ones(2, dtype=bool) + weights = np.ones(2) + with pytest.raises(ValueError, match="one row per record"): + collapse_replicas(keys, rows, weights, inputs=pd.DataFrame({"x": [1.0]})) + duplicated = pd.DataFrame([[1.0, 2.0], [1.0, 2.0]], columns=["x", "x"]) + with pytest.raises(ValueError, match="each column once"): + collapse_replicas(keys, rows, weights, inputs=duplicated) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py index fa08c4edf2..257075a5fc 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_geographic_clone_collapse.py @@ -59,13 +59,19 @@ def _tables(frame): return {name: frame.table(name) for name in ("person", "benunit", "household")} +def _agreeing(n: int) -> pd.DataFrame: + """Inputs every clone shares: the fit reads the same values on each.""" + + return pd.DataFrame({"value": np.zeros(n)}) + + def test_only_geographic_clones_fold_into_their_survey_record() -> None: frame = _copies_frame() weights = frame.weights_for("household").values rows = np.ones(4, dtype=bool) # Without clones every copy is a row of its own, value for value. kept, summed = collapse_geographic_clones( - _tables(frame), "household", rows, weights + _tables(frame), "household", rows, weights, inputs=_agreeing(4) ) assert kept.tolist() == rows.tolist() assert summed.tobytes() == np.asarray(weights).tobytes() @@ -74,18 +80,51 @@ def test_only_geographic_clones_fold_into_their_survey_record() -> None: for entity in ("household", "person", "benunit"): n = pool.n(entity) kept, summed = collapse_geographic_clones( - _tables(pool), entity, np.ones(n, dtype=bool), np.full(n, 0.5) + _tables(pool), + entity, + np.ones(n, dtype=bool), + np.full(n, 0.5), + inputs=_agreeing(n), ) clone = pool.table(entity)[ladder_clone_index_column(entity)].to_numpy() # Each copy keeps its first clone, which carries both clones' weight. assert kept.tolist() == (clone == 0).tolist() assert summed[kept].tolist() == [1.0] * 4 kept, summed = collapse_geographic_clones( - _tables(pool), "household", np.ones(8, dtype=bool), pool_weights + _tables(pool), + "household", + np.ones(8, dtype=bool), + pool_weights, + inputs=_agreeing(8), ) assert summed[kept].tolist() == list(weights) +def test_clones_that_differ_on_what_the_fit_reads_stay_rows_of_their_own() -> None: + """A record's clones fold only where they agree on the fit's inputs: a + clone that differs (a draw keyed on its own id, say) keeps its own row at + its own weight, so nothing it carries is dropped (microcosm#931).""" + + pool = with_geographic_clones(_copies_frame()) + clone = pool.table("household")[ladder_clone_index_column("household")] + values = np.zeros(8) + differs = int(np.flatnonzero(clone.to_numpy() == 1)[0]) + values[differs] = 1.0 + kept, summed = collapse_geographic_clones( + _tables(pool), + "household", + np.ones(8, dtype=bool), + np.full(8, 0.5), + inputs=pd.DataFrame({"value": values}), + ) + # Three records fold to one row each; the fourth keeps both clones. + assert int(kept.sum()) == 5 + assert kept[differs] + assert sorted(summed[kept].tolist()) == [0.5, 0.5, 1.0, 1.0, 1.0] + assert summed[differs] == 0.5 + assert np.isclose(summed[kept].sum(), 4.0) + + #: The stages whose fits collapse clones, and the module each one's call is #: in: the SPI income stage runs its forests from spi_income. _COLLAPSING_STAGES = { diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_reporter_redraw.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_reporter_redraw.py index f499bd274d..98765b7b8b 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_reporter_redraw.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_reporter_redraw.py @@ -1,6 +1,7 @@ """Tests split from packages/microcosm-build/tests/test_uk_uc_reporter_redraw.py.""" # ruff: noqa: F403, F405 +from microcosm.build.uk_runtime.national_frame import uk_national_frame from test_support.microcosm_build.uk_geographic_clones import with_geographic_clones from test_support.microcosm_build.uk_uc_reporter_redraw import * @@ -488,3 +489,41 @@ def test_geographic_clones_fit_each_benefit_unit_once_at_its_whole_weight() -> N cloned.record["fit_groups"], alone.record["fit_groups"] ) pd.testing.assert_frame_equal(cloned.record["fit_table"], alone.record["fit_table"]) + + +def test_clones_that_differ_on_a_predictor_train_as_variants_at_their_share() -> None: + """A landlord's clones whose property income was drawn apart (on their own + person ids, as property_components draws it) reach the forest as two rows + at half the unit's weight each; clones that agree still fold, and the + unit's weight is kept whole (microcosm#931).""" + + alone = _StubQRFFactory() + redraw_spi_reported_uc(_frame(), engine=_StubEngine(), qrf_factory=alone) + pool = with_geographic_clones(_frame()) + person = pool.table("person").copy() + # Clone 1 of training unit 101's first member: ids move by 10,000 per clone. + landlord = person["person_id"] == 11011 + assert landlord.sum() == 1 + person.loc[landlord, "property_income"] += 500.0 + differing = uk_national_frame( + person=person, + benunit=pool.table("benunit"), + household=pool.table("household"), + household_weights=pool.weights_for("household").values, + weight_kind=pool.weights_for("household").kind, + time_period="2024", + ) + cloned = _StubQRFFactory() + redraw_spi_reported_uc(differing, engine=_StubEngine(), qrf_factory=cloned) + + weights = np.asarray(cloned.record["fit_weights"]) + table = cloned.record["fit_table"].reset_index(drop=True) + assert len(weights) == len(alone.record["fit_weights"]) + 1 + assert np.isclose(weights.sum(), np.asarray(alone.record["fit_weights"]).sum()) + # Unit 101 trains as its two variants, 200 and 700 of investment income, + # at half its weight of 2 each; the other units fold to one row each. + unit = table["universal_credit_reported_amount"] == 100.0 + assert sorted( + zip(table.loc[unit, "benunit_investment_income"], weights[unit], strict=True) + ) == [(200.0, 1.0), (700.0, 1.0)] + assert sorted(weights[~unit].tolist()) == [3.0, 4.0, 5.0] From 5e1d2c7d02478b590670b046e9de5aadb0b2e67b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Fri, 6 Nov 2026 11:22:13 +0000 Subject: [PATCH 12/20] Draw Scotland's band weights from each data zone's NRS mix Scotland's conditioned support took each council's CTAXBASE 2025 band mix, so within a council the band said nothing about where a household lives (Vahid's item 3 on #1519). It now takes the mix of the area's 2022 data zone from NRS's dwelling estimates by data zone, December 2024 sheet. The bytes are the ones Chronicle already registers as nrs-dwellings-data-zone-2025, pinned here by sha256. Chronicle emits only the workbook's total as facts; PolicyEngine/chronicle#419 asks for the band columns. - The tool pins the workbook beside chronicle#412's files. It checks the header, the zone count and that each zone's bands sum to its total, and keys each area to its zone through the support's own lsoa_code; all 7,392 zones match. - The Scottish support is rebuilt (0c7d7826, 1,607,702 bytes). England and Wales and Northern Ireland rebuild byte for byte, and the zero-mass cells are unchanged. - The band vintage uk_ctaxbase_2025 becomes uk_nrs_dz_dwellings_2024 in sources.yaml and vintages.yaml. - Tests cover the reader and its refusals, the band source naming the workbook, and the mounted check that each zone's areas share its mix. No output moves: only the geography-first move binds these supports. Co-Authored-By: Claude Opus 5.5 --- .../931-uk-conditioned-area-supports.added.md | 4 +- docs/geography-assignment.md | 8 +- .../src/microcosm/build/uk/spec/sources.yaml | 10 +- .../src/microcosm/build/uk/spec/vintages.yaml | 78 ++++----- ..._area_conditioned_supports.provenance.json | 80 +++++----- .../uk/test_uk_conditioned_area_supports.py | 25 +-- .../test_uk_conditioned_area_supports_tool.py | 70 ++++++-- tools/build_uk_conditioned_area_supports.py | 151 +++++++++++------- 8 files changed, 251 insertions(+), 175 deletions(-) diff --git a/changelog.d/931-uk-conditioned-area-supports.added.md b/changelog.d/931-uk-conditioned-area-supports.added.md index bf8751ff09..45f011c5ca 100644 --- a/changelog.d/931-uk-conditioned-area-supports.added.md +++ b/changelog.d/931-uk-conditioned-area-supports.added.md @@ -5,10 +5,10 @@ Each conditioned support extends its system's registered support byte for byte, - **`imd_decile`:** the area's deprivation decile within its nation, at the 2019 vintage the FRS 2024-25 deciles follow (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017). Each area takes the plurality of its live residential postcodes in the May 2026 NSPL; a tie goes to the parent area's plurality, and an area without such a postcode takes its parent's decile. - **Households by council-tax band, times 10^6, as exact integers:** - England and Wales take bands A to I from the area's LSOA mix in VOA CTSOP1.1; only Wales has band I. - - Scotland takes bands A to H from its council's CTAXBASE 2025 chargeable dwellings, rounded half to even, so there the band moves mass only between councils. + - Scotland takes bands A to H from its 2022 data zone's dwellings by band in NRS's December 2024 estimates, rounded half to even; its output areas nest in those zones. - Northern Ireland is unbanded. -`tools/build_uk_conditioned_area_supports.py` builds them from chronicle#412's raw-only registrations (PR chronicle#413), pinned by sha256. `uk/uk_atomic_area_conditioned_supports.provenance.json` records every input, the decile rule counts, the rounding and a precomputed table of zero-mass draw cells. +`tools/build_uk_conditioned_area_supports.py` builds them from publisher files pinned by sha256: chronicle#412's raw-only registrations (PR chronicle#413), and NRS's dwellings by 2022 data zone, which Chronicle registers with only their total as facts (chronicle#419 asks for the bands). `uk/uk_atomic_area_conditioned_supports.provenance.json` records every input, the decile rule counts, the rounding and a precomputed table of zero-mass draw cells. `sources.yaml` declares the supports under the new role `uk_atomic_area_conditioned_support`, with five new geography vintages. `spine.yaml` declares the FRS channel's `observed_constraints: [imd_decile]`, an optional field the shared spine schema now admits. `validate_uk_country_source_projection` refuses a spec in which the supports, their conditioned forms and that declaration disagree. diff --git a/docs/geography-assignment.md b/docs/geography-assignment.md index e00b9248b2..59e482e198 100644 --- a/docs/geography-assignment.md +++ b/docs/geography-assignment.md @@ -201,8 +201,8 @@ Each support also has a conditioned form for the geography-first draw the support it extends, and recorded in `uk/uk_atomic_area_conditioned_supports.provenance.json`; `tools/build_uk_conditioned_area_supports.py` builds it from the registered -support's bytes and chronicle#412's raw-only registrations. It adds two kinds of -column: +support's bytes, chronicle#412's raw-only registrations and NRS's dwellings by +2022 data zone. It adds two kinds of column: - **`imd_decile`**, an exact-match constraint code. It is the area's deprivation decile within its own nation, at the 2019 vintage the FRS @@ -216,8 +216,8 @@ column: stage chooses per household: - England and Wales take bands A to I from the area's LSOA mix in VOA CTSOP1.1. Only Wales has band I. - - Scotland takes bands A to H from its council's CTAXBASE 2025 chargeable - dwellings, so there the band moves mass only between councils. + - Scotland takes bands A to H from its 2022 data zone's dwellings by band in + NRS's December 2024 estimates; its output areas nest in those zones. - Northern Ireland has domestic rates, so its support carries no bands. The provenance lists every zero-mass draw cell (FRS region by decile, and diff --git a/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml b/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml index 73cf1d441d..980afffb6e 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml +++ b/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml @@ -204,8 +204,8 @@ sources: value: 2025_ctsop - id: uk_scotland_output_area_2022_conditioned_support role: uk_atomic_area_conditioned_support - sha256: 648e1a88dce6ad246aca5d09c9209f82646f48d0c3f4778955b51dcae907941a - byte_size: 1028754 + sha256: 0c7d78263c5db96d8f6dce06ac22c8e45f5fc4272297a4d16e073c964e797fea + byte_size: 1607702 loader: kernel:load_uk_atomic_area_support vintages: - vintage:uk_oa_2022 @@ -214,14 +214,14 @@ sources: - vintage:uk_pcon_2024 - vintage:uk_itl_2025 - vintage:uk_simd_2020v2 - - vintage:uk_ctaxbase_2025 + - vintage:uk_nrs_dz_dwellings_2024 vintage_authorities: - id: uk_simd_2020v2 kind: geography_vintage value: 2020v2_simd - - id: uk_ctaxbase_2025 + - id: uk_nrs_dz_dwellings_2024 kind: geography_vintage - value: 2025_ctaxbase + value: 2024_nrs_dz_dwellings - id: uk_ni_data_zone_2021_conditioned_support role: uk_atomic_area_conditioned_support sha256: 6d71f2a98f26f80d80a4671b7e37389dd92f8ff9b9a02ee35c09819763b3b450 diff --git a/packages/microcosm-build/src/microcosm/build/uk/spec/vintages.yaml b/packages/microcosm-build/src/microcosm/build/uk/spec/vintages.yaml index 60eb76119f..23d2b95838 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/spec/vintages.yaml +++ b/packages/microcosm-build/src/microcosm/build/uk/spec/vintages.yaml @@ -21,30 +21,6 @@ records: source: source:uk_scotland_output_area_2022_support authority: uk_ca_2019 compatible_with: - - vintage:uk_ctaxbase_2025 - - vintage:uk_ctsop_2025 - - vintage:uk_dea_2014 - - vintage:uk_dz_2021 - - vintage:uk_iod_wimd_2019 - - vintage:uk_itl_2025 - - vintage:uk_lad_2023 - - vintage:uk_lgd_2014 - - vintage:uk_nimdm_2017 - - vintage:uk_oa_2021 - - vintage:uk_oa_2022 - - vintage:uk_pcon_2024 - - vintage:uk_rgn_2024 - - vintage:uk_scotland_ew_2022 - - vintage:uk_simd_2020v2 - - vintage:uk_wd_2024 -- id: uk_ctaxbase_2025 - kind: geography_vintage_ref - authority_ref: - kind: source_record - source: source:uk_scotland_output_area_2022_conditioned_support - authority: uk_ctaxbase_2025 - compatible_with: - - vintage:uk_ca_2019 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -53,6 +29,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -68,7 +45,6 @@ records: authority: uk_ctsop_2025 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 - vintage:uk_iod_wimd_2019 @@ -76,6 +52,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -91,7 +68,6 @@ records: authority: uk_dea_2014 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dz_2021 - vintage:uk_iod_wimd_2019 @@ -99,6 +75,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -114,7 +91,6 @@ records: authority: uk_dz_2021 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_iod_wimd_2019 @@ -122,6 +98,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -137,7 +114,6 @@ records: authority: uk_iod_wimd_2019 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -145,6 +121,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -160,7 +137,6 @@ records: authority: uk_itl_2025 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -168,6 +144,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -183,7 +160,6 @@ records: authority: uk_lad_2023 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -191,6 +167,7 @@ records: - vintage:uk_itl_2025 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -206,7 +183,6 @@ records: authority: uk_lgd_2014 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -214,6 +190,7 @@ records: - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -229,7 +206,6 @@ records: authority: uk_nimdm_2017 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -237,6 +213,30 @@ records: - vintage:uk_itl_2025 - vintage:uk_lad_2023 - vintage:uk_lgd_2014 + - vintage:uk_nrs_dz_dwellings_2024 + - vintage:uk_oa_2021 + - vintage:uk_oa_2022 + - vintage:uk_pcon_2024 + - vintage:uk_rgn_2024 + - vintage:uk_scotland_ew_2022 + - vintage:uk_simd_2020v2 + - vintage:uk_wd_2024 +- id: uk_nrs_dz_dwellings_2024 + kind: geography_vintage_ref + authority_ref: + kind: source_record + source: source:uk_scotland_output_area_2022_conditioned_support + authority: uk_nrs_dz_dwellings_2024 + compatible_with: + - vintage:uk_ca_2019 + - vintage:uk_ctsop_2025 + - vintage:uk_dea_2014 + - vintage:uk_dz_2021 + - vintage:uk_iod_wimd_2019 + - vintage:uk_itl_2025 + - vintage:uk_lad_2023 + - vintage:uk_lgd_2014 + - vintage:uk_nimdm_2017 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -252,7 +252,6 @@ records: authority: uk_oa_2021 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -261,6 +260,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 @@ -275,7 +275,6 @@ records: authority: uk_oa_2022 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -284,6 +283,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_pcon_2024 - vintage:uk_rgn_2024 @@ -298,7 +298,6 @@ records: authority: uk_pcon_2024 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -307,6 +306,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_rgn_2024 @@ -321,7 +321,6 @@ records: authority: uk_rgn_2024 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -330,6 +329,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -344,7 +344,6 @@ records: authority: uk_scotland_ew_2022 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -353,6 +352,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -367,7 +367,6 @@ records: authority: uk_simd_2020v2 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -376,6 +375,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 @@ -390,7 +390,6 @@ records: authority: uk_wd_2024 compatible_with: - vintage:uk_ca_2019 - - vintage:uk_ctaxbase_2025 - vintage:uk_ctsop_2025 - vintage:uk_dea_2014 - vintage:uk_dz_2021 @@ -399,6 +398,7 @@ records: - vintage:uk_lad_2023 - vintage:uk_lgd_2014 - vintage:uk_nimdm_2017 + - vintage:uk_nrs_dz_dwellings_2024 - vintage:uk_oa_2021 - vintage:uk_oa_2022 - vintage:uk_pcon_2024 diff --git a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json index 9f854b2bbe..eeea053cc3 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json +++ b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json @@ -7,6 +7,7 @@ "pull_request": "PolicyEngine/chronicle#413" }, "issues": { + "chronicle_band_facts": "PolicyEngine/chronicle#419", "chronicle_registration": "PolicyEngine/chronicle#412", "umbrella": "PolicyEngine/microcosm#931" }, @@ -15,8 +16,8 @@ "imd_decile is the 2019 vintage of each nation's index (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017): the FRS 2024-25 variables IMDE, IMDW, IMDS and IMDN carry no change note from 2023-24, which predates the 2025 indices, and on an internal comparison England's FRS decile shares by region fit IoD 2019 better than IoD 2025, as the 2023-24 FRS does. The vintage is still to be confirmed with DWP.", "An area's decile is the one most of its live small-user postcodes carry in the May 2026 NSPL (oa21cd: the 2021 output area in England and Wales, the 2022 output area in Scotland, the 2021 data zone in Northern Ireland). Ranks are within-nation only.", "Northern Ireland's SOAs (2001) do not nest in its 2021 data zones, so many data zones' postcodes span deciles; the modal decile is recorded with relation inferred_modal and the counts below.", - "England and Wales band weights read each area's LSOA mix as committed (shares to 6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read its council's chargeable dwellings, rounded half to even per band.", - "Scotland's band mix is its council's, so a band moves mass only between councils: within a council a household is placed in proportion to households, where England and Wales use each LSOA's mix. A mix by 2022 data zone, in which the 2022 output areas nest (such as NRS's small area statistics on households and dwellings), would give Scotland the same within-council resolution. No such source is registered in Chronicle yet." + "England and Wales band weights read each area's LSOA mix as committed (shares to 6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read its 2022 data zone's dwellings by band, rounded half to even per band.", + "Scotland's band mix is its 2022 data zone's, in which its 2022 output areas nest, from NRS's December 2024 sheet: nearest the FRS 2024-25 year and VOA's stock at 31 March 2025. NRS counts dwellings on the valuation list, as VOA does in England and Wales. Chronicle registers the workbook (nrs-dwellings-data-zone-2025) with only its total as facts; until chronicle#419 adds the band columns, this tool reads them from the registered bytes." ], "publisher_files": { "iod2019": { @@ -41,6 +42,17 @@ "size_bytes": 1772032, "url": "https://www.nisra.gov.uk/files/nisra/publications/NIMDM17_SOAresults.xls" }, + "nrs_dz_dwellings": { + "chronicle_package_id": "nrs-dwellings-data-zone-2025", + "chronicle_source_id": "nrs", + "chronicle_year": 2025, + "filename": "dwelling-estimates-by-2022-data-zones-24-25.xlsx", + "product": "Dwelling estimates by 2022 data zone, December 2024 and 2025", + "publisher": "NRS", + "sha256": "5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033", + "size_bytes": 1223284, + "url": "https://nrscotland.gov.uk/media/43tfx3zo/dwelling-estimates-by-2022-data-zones-24-25.xlsx" + }, "nspl": { "chronicle_package_id": "ons-nspl-may-2026", "chronicle_source_id": "ons", @@ -76,14 +88,6 @@ } }, "resources": { - "scotgov_chargeable_dwellings_by_band.json": { - "as_at": "2025-09", - "publisher_file": "CTAXBASE_2025_Tables_Chargeable_Dwellings.xlsx", - "publisher_package": "scotgov-council-tax-bands-2025", - "publisher_sha256": "8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f", - "resource": "scotgov_chargeable_dwellings_by_band.json", - "sha256": "7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" - }, "voa_council_tax_band_mix_lsoa.json": { "as_at": "2025-03-31", "publisher_file": "CTSOP1.1.zip", @@ -830,21 +834,21 @@ }, "uk_scotland_output_area_2022": { "band_weights": { - "areas_with_rounding": 24812, + "areas_with_rounding": 19887, "column_totals": { - "households_band_a": 477656371974, - "households_band_b": 558484112506, - "households_band_c": 407475622303, - "households_band_d": 353516527279, - "households_band_e": 350498043811, - "households_band_f": 211364523185, - "households_band_g": 135864913826, - "households_band_h": 13854884024 + "households_band_a": 495138998397, + "households_band_b": 563897865725, + "households_band_c": 406542930927, + "households_band_d": 347792158855, + "households_band_e": 345917815311, + "households_band_f": 205185630632, + "households_band_g": 130816965379, + "households_band_h": 13422634794 }, "largest_area_deviation": 3, "rounding": "round_half_even", "scale": 1000000, - "total_deviation": -1092 + "total_deviation": 20 }, "base": { "sha256": "1649fa831315e6fac80caa4af7f68e837fd985b7f59c2831bb0db8cbfeeee443", @@ -852,44 +856,44 @@ }, "column_metadata": { "households_band_a": { - "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_a_share_round_half_even_x1e6", + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_a_share_round_half_even_x1e6", "kind": "weight", - "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" }, "households_band_b": { - "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_b_share_round_half_even_x1e6", + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_b_share_round_half_even_x1e6", "kind": "weight", - "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" }, "households_band_c": { - "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_c_share_round_half_even_x1e6", + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_c_share_round_half_even_x1e6", "kind": "weight", - "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" }, "households_band_d": { - "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_d_share_round_half_even_x1e6", + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_d_share_round_half_even_x1e6", "kind": "weight", - "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" }, "households_band_e": { - "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_e_share_round_half_even_x1e6", + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_e_share_round_half_even_x1e6", "kind": "weight", - "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" }, "households_band_f": { - "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_f_share_round_half_even_x1e6", + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_f_share_round_half_even_x1e6", "kind": "weight", - "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" }, "households_band_g": { - "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_g_share_round_half_even_x1e6", + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_g_share_round_half_even_x1e6", "kind": "weight", - "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" }, "households_band_h": { - "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_ctaxbase_2025_council_band_h_share_round_half_even_x1e6", + "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_h_share_round_half_even_x1e6", "kind": "weight", - "source": "scotgov-council-tax-bands-2025@sha256:8e431837aa37ee298c9a2b9b010b8ecbc7e3a817573a3a84f6251e6db00a591f#scotgov_chargeable_dwellings_by_band.json@sha256:7a2c01e0d1f4504b92858552108acb3ae65a3ad779b5dbea1c9055941f98827a" + "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" }, "imd_decile": { "kind": "code", @@ -924,8 +928,8 @@ "postcodes_without_rank": 0, "records": 156932 }, - "sha256": "648e1a88dce6ad246aca5d09c9209f82646f48d0c3f4778955b51dcae907941a", - "size_bytes": 1028754, + "sha256": "0c7d78263c5db96d8f6dce06ac22c8e45f5fc4272297a4d16e073c964e797fea", + "size_bytes": 1607702, "zero_mass_cells": [ { "cells": [], diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py index 1b2ed159a7..65acb38f5e 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py @@ -51,7 +51,10 @@ #: The vintage authorities each conditioned support adds to its base's. CONDITIONING_VINTAGES = { EW: {"uk_iod_wimd_2019": "2019_iod_wimd", "uk_ctsop_2025": "2025_ctsop"}, - SCOT: {"uk_simd_2020v2": "2020v2_simd", "uk_ctaxbase_2025": "2025_ctaxbase"}, + SCOT: { + "uk_simd_2020v2": "2020v2_simd", + "uk_nrs_dz_dwellings_2024": "2024_nrs_dz_dwellings", + }, NI: {"uk_nimdm_2017": "2017_nimdm_soa"}, } #: The authority behind each system's decile column. @@ -257,9 +260,15 @@ def test_column_metadata_names_every_input_and_its_vintage(provenance, system) - item = entry["column_metadata"][column] assert item["kind"] == "weight" and item["basis"].endswith("_x1e6") publisher, _, resource = item["source"].partition("#") + package, _, publisher_digest = publisher.partition("@sha256:") + if system == SCOT: + # Scotland reads one sheet of the registered NRS workbook itself. + assert package == "nrs-dwellings-data-zone-2025" + assert sha_by_package[package] == publisher_digest + assert resource == "sheet-2024" + continue name, _, digest = resource.partition("@sha256:") assert resources[name]["sha256"] == digest - package, _, publisher_digest = publisher.partition("@sha256:") assert ( resources[name]["publisher_package"], resources[name]["publisher_sha256"], @@ -386,13 +395,11 @@ def test_mounted_conditioned_support_extends_the_registered_support( ) -def test_mounted_scottish_band_weights_move_mass_only_between_councils( - provenance, -) -> None: +def test_mounted_scottish_band_weights_follow_each_data_zone(provenance) -> None: support = decode_atomic_support(_mounted(SCOT)) frame = pd.DataFrame( { - "council": np.asarray(support.arrays["local_authority_code"]), + "zone": np.asarray(support.arrays["lsoa_code"]), "households": np.asarray(support.arrays["households"], dtype=np.int64), **{ c: np.asarray(support.arrays[c], dtype=np.int64) @@ -400,9 +407,9 @@ def test_mounted_scottish_band_weights_move_mass_only_between_councils( }, } ) - totals = frame.groupby("council").sum() + totals = frame.groupby("zone").sum() for column in BAND_WEIGHT_COLUMNS[SCOT]: - # Within a council every area holds the council's band share of its + # Within a data zone every area holds the zone's band share of its # households, so its weight is that share times households, rounded. - share = frame["council"].map(totals[column] / totals["households"]) + share = frame["zone"].map(totals[column] / totals["households"]) assert np.all(np.abs(frame[column] - frame["households"] * share) <= 1.0) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py index b4ebaf2e1d..d6ea89a562 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py @@ -39,7 +39,7 @@ def tool(): def _invented_inputs(bases: dict[str, bytes]): - """Three postcodes per area, two of them at rank 1; band mixes per LSOA and council.""" + """Three postcodes per area, two of them at rank 1; band mixes per LSOA and zone.""" postcodes = [] for payload in bases.values(): for area in decode_atomic_support(payload).arrays["area"].tolist(): @@ -58,28 +58,17 @@ def _invented_inputs(bases: dict[str, bytes]): ) lsoa[code] = {"all_properties": 40, "cumulative": cumulative} voa = {"bands": list("ABCDEFGHI"), "lsoa": lsoa} - council = decode_atomic_support(bases[SCOT]).arrays["local_authority_code"][0] scot = { - "rows": [ - { - "geography": {"id": str(council)}, - "measure_id": f"band_{band}", - "value": value, - } - for band, value in zip("abcdefgh", (1, 2, 1, 1, 1, 1, 1, 1), strict=True) - ] + str(zone): dict(zip("abcdefgh", (1, 2, 1, 1, 1, 1, 1, 1), strict=True)) + for zone in decode_atomic_support(bases[SCOT]).arrays["lsoa_code"].tolist() } resources = { - name: { - "resource": name, + "voa_council_tax_band_mix_lsoa.json": { + "resource": "voa_council_tax_band_mix_lsoa.json", "sha256": "1" * 64, "publisher_package": "invented-package", "publisher_sha256": "2" * 64, } - for name in ( - "voa_council_tax_band_mix_lsoa.json", - "scotgov_chargeable_dwellings_by_band.json", - ) } return frame, deciles, voa, scot, resources @@ -149,6 +138,55 @@ def test_rank_deciles_refuse_a_split_tie_and_a_short_index(tool, monkeypatch) -> tool._rank_deciles(pd.Series([1, 2]), pd.Series([1, 2]), nation="E") +def _nrs_workbook(tool, path, rows): + """NRS's layout: four title rows, the header on row 5, zones, then a footnote.""" + openpyxl = pytest.importorskip("openpyxl") + workbook = openpyxl.Workbook() + sheet = workbook.active + sheet.title = tool.NRS_SHEET + for _ in range(tool.NRS_HEADER_ROW): + sheet.append(["Dwelling estimates by 2022 Data Zone"]) + sheet.append( + [ + tool.NRS_ZONE_COLUMN, + "Data zone name", + tool.NRS_TOTAL_COLUMN, + *tool.NRS_BAND_COLUMNS.values(), + ] + ) + for zone, total, *bands in rows: + sheet.append([zone, f"{zone} name", total, *bands]) + sheet.append(["Source: Scottish Assessors' Portal data"]) + workbook.save(path) + return path + + +def test_nrs_band_counts_read_each_zone_and_refuse_a_broken_sum( + tool, tmp_path, monkeypatch +) -> None: + monkeypatch.setattr(tool, "NRS_DATA_ZONES", 2) + rows = [ + ["S01013482", 9, 1, 2, 1, 1, 1, 1, 1, 1], + ["S01013483", 8, 0, 0, 0, 0, 0, 0, 0, 8], + ] + path = tmp_path / "zones.xlsx" + assert tool._nrs_band_counts(_nrs_workbook(tool, path, rows)) == { + "S01013482": dict(zip("abcdefgh", (1, 2, 1, 1, 1, 1, 1, 1), strict=True)), + "S01013483": {**dict.fromkeys("abcdefg", 0), "h": 8}, + } + with pytest.raises(ValueError, match="expected 2"): + tool._nrs_band_counts(_nrs_workbook(tool, path, rows[:1])) + rows[1][1] = 9 + with pytest.raises(ValueError, match="miss its total"): + tool._nrs_band_counts(_nrs_workbook(tool, path, rows)) + + +def test_scotland_numerators_refuse_a_zone_without_counts(tool) -> None: + support = decode_atomic_support(toy_support_payloads()[SCOT]) + with pytest.raises(ValueError, match="each data zone A to H"): + tool._scotland_numerators(support, {"S01999999": dict.fromkeys("abcdefgh", 1)}) + + def test_northern_ireland_deciles_are_tenths_of_its_soas(tool) -> None: deciles = tool._northern_ireland() assert len(deciles) == 890 diff --git a/tools/build_uk_conditioned_area_supports.py b/tools/build_uk_conditioned_area_supports.py index fcd551b894..c3debef9c8 100644 --- a/tools/build_uk_conditioned_area_supports.py +++ b/tools/build_uk_conditioned_area_supports.py @@ -17,15 +17,16 @@ Ireland's are its 890 SOA ranks in tenths of 89. - ``households_band_a`` ... : the area's households by council-tax band, times 10^6. England and Wales use the VOA CTSOP1.1 mix of the area's LSOA - (``voa_council_tax_band_mix_lsoa.json``); Scotland uses its council's - CTAXBASE 2025 chargeable dwellings (``scotgov_chargeable_dwellings_by_band.json``), - so there the band moves mass only between councils. Northern Ireland has - domestic rates and no bands. + (``voa_council_tax_band_mix_lsoa.json``); Scotland uses the dwellings by + band of the area's 2022 data zone, in which its 2022 output areas nest, from + NRS's December 2024 sheet. Northern Ireland has domestic rates and no bands. -The publisher files are chronicle#412's raw-only registrations (PR -chronicle#413), pinned here by sha256; the band mixes are committed package -resources. The provenance register records every input's identity, each -nation's decile rule counts, the rounding, and every zero-mass draw cell. +The publisher files are pinned here by sha256: chronicle#412's raw-only +registrations (PR chronicle#413), and NRS's dwelling estimates by 2022 data +zone, which Chronicle registers with only their total as facts (chronicle#419 +asks for the band columns). The VOA band mix is a committed package resource. +The provenance register records every input's identity, each nation's decile +rule counts, the rounding, and every zero-mass draw cell. Example (odfpy reads the Welsh Government's ODS; nothing else here needs it): uv run --no-sync --with odfpy python tools/build_uk_conditioned_area_supports.py \\ @@ -79,13 +80,13 @@ _UK_PACKAGE = _REPOSITORY_ROOT / "packages/microcosm-build/src/microcosm/build/uk" _DEFAULT_PROVENANCE = _UK_PACKAGE / CONDITIONED_PROVENANCE_RESOURCE VOA_BAND_MIX = "voa_council_tax_band_mix_lsoa.json" -SCOTLAND_BAND_COUNTS = "scotgov_chargeable_dwellings_by_band.json" PROVENANCE_SCHEMA_VERSION = 1 PROVENANCE_KIND = "uk_atomic_area_conditioned_supports_provenance" EW, SCOT, NI = SYSTEMS -#: chronicle#412's raw-only registrations, as PR chronicle#413 pins them. +#: chronicle#412's raw-only registrations, as PR chronicle#413 pins them, and +#: NRS's dwellings by 2022 data zone, registered with its total as facts. SOURCES: dict[str, dict[str, str | int]] = { "nspl": { "chronicle_source_id": "ons", @@ -142,9 +143,21 @@ "publisher": "NISRA", "product": "NIMDM 2017 results by Super Output Area", }, + "nrs_dz_dwellings": { + "chronicle_source_id": "nrs", + "chronicle_package_id": "nrs-dwellings-data-zone-2025", + "chronicle_year": 2025, + "filename": "dwelling-estimates-by-2022-data-zones-24-25.xlsx", + "url": "https://nrscotland.gov.uk/media/43tfx3zo/dwelling-estimates-by-2022-data-zones-24-25.xlsx", + "sha256": "5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033", + "size_bytes": 1_223_284, + "publisher": "NRS", + "product": "Dwelling estimates by 2022 data zone, December 2024 and 2025", + }, } -#: The Chronicle commit that registers these files: chronicle#413's merge. The -#: supports were first built at its head; the file digests did not move. +#: The Chronicle commit that registers these files: chronicle#413's merge, which +#: also carries the NRS registration. The supports were first built at #413's +#: head; the file digests did not move. CHRONICLE = { "pull_request": "PolicyEngine/chronicle#413", "commit": "c51f40d2bdaa66315dd63f334ede5790a8891e27", @@ -153,6 +166,7 @@ ISSUES = { "umbrella": "PolicyEngine/microcosm#931", "chronicle_registration": "PolicyEngine/chronicle#412", + "chronicle_band_facts": "PolicyEngine/chronicle#419", } NSPL_MEMBER = "Data/NSPL_MAY_2026_UK.csv" #: Small areas each index ranks, within its own nation only. @@ -162,9 +176,17 @@ NATION_PREFIXES = {EW: ("E", "W"), SCOT: ("S",), NI: ("N",)} #: The vintage each system's decile column declares. DECILE_VINTAGES = {EW: "2019_iod_wimd", SCOT: "2020v2_simd", NI: "2017_nimdm_soa"} -BAND_VINTAGES = {EW: "2025_ctsop", SCOT: "2025_ctaxbase"} +BAND_VINTAGES = {EW: "2025_ctsop", SCOT: "2024_nrs_dz_dwellings"} #: Each area's parent for ties and areas without a residential postcode. PARENT_COLUMNS = {EW: "lsoa_code", SCOT: "lsoa_code", NI: "msoa_code"} +#: NRS's December 2024 sheet: nearest the FRS 2024-25 year and VOA's stock at +#: 31 March 2025. Its header is row 5. +NRS_SHEET = "2024" +NRS_HEADER_ROW = 4 +NRS_DATA_ZONES = 7_392 +NRS_ZONE_COLUMN = "Data Zone code" +NRS_TOTAL_COLUMN = "Total number of dwellings" +NRS_BAND_COLUMNS = {band.lower(): f"Council Tax band:\n{band}" for band in "ABCDEFGH"} NOTES = ( "imd_decile is the 2019 vintage of each nation's index (IoD 2019, WIMD 2019, " @@ -180,13 +202,13 @@ "inferred_modal and the counts below.", "England and Wales band weights read each area's LSOA mix as committed (shares to " "6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read " - "its council's chargeable dwellings, rounded half to even per band.", - "Scotland's band mix is its council's, so a band moves mass only between councils: " - "within a council a household is placed in proportion to households, where England " - "and Wales use each LSOA's mix. A mix by 2022 data zone, in which the 2022 output " - "areas nest (such as NRS's small area statistics on households and dwellings), " - "would give Scotland the same within-council resolution. No such source is " - "registered in Chronicle yet.", + "its 2022 data zone's dwellings by band, rounded half to even per band.", + "Scotland's band mix is its 2022 data zone's, in which its 2022 output areas nest, " + "from NRS's December 2024 sheet: nearest the FRS 2024-25 year and VOA's stock at " + "31 March 2025. NRS counts dwellings on the valuation list, as VOA does in England " + "and Wales. Chronicle registers the workbook (nrs-dwellings-data-zone-2025) with " + "only its total as facts; until chronicle#419 adds the band columns, this tool " + "reads them from the registered bytes.", ) @@ -307,6 +329,33 @@ def _postcodes(path: Path) -> pd.DataFrame: return frame.loc[live, ["oa21cd", "imd20ind"]].reset_index(drop=True) +def _nrs_band_counts(path: Path) -> dict[str, dict[str, int]]: + """Each 2022 data zone's dwellings by band a to h; bands must sum to its total.""" + frame = pd.read_excel(path, sheet_name=NRS_SHEET, header=NRS_HEADER_ROW) + columns = [NRS_ZONE_COLUMN, NRS_TOTAL_COLUMN, *NRS_BAND_COLUMNS.values()] + missing = [column for column in columns if column not in frame.columns] + if missing: + raise ValueError(f"NRS sheet {NRS_SHEET} lacks columns {missing}.") + zones = frame.loc[ + frame[NRS_ZONE_COLUMN].astype(str).str.fullmatch(r"S01\d{6}"), columns + ] + if len(zones) != NRS_DATA_ZONES or zones[NRS_ZONE_COLUMN].duplicated().any(): + raise ValueError( + f"NRS sheet {NRS_SHEET}: {len(zones):,} data zones, " + f"expected {NRS_DATA_ZONES:,}." + ) + counts = zones[columns[1:]].apply(pd.to_numeric, errors="coerce").to_numpy(float) + if not np.all(np.isfinite(counts) & (counts >= 0) & (counts == np.floor(counts))): + raise ValueError(f"NRS sheet {NRS_SHEET} has a count that is not one count.") + counts = counts.astype(np.int64) + if not np.array_equal(counts[:, 1:].sum(axis=1), counts[:, 0]): + raise ValueError(f"NRS sheet {NRS_SHEET}: a zone's bands miss its total.") + return { + str(zone): dict(zip(NRS_BAND_COLUMNS, map(int, row[1:]), strict=True)) + for zone, row in zip(zones[NRS_ZONE_COLUMN], counts, strict=True) + } + + def decile_column( support, postcodes: pd.DataFrame, @@ -369,28 +418,19 @@ def _voa_numerators(support, mix: Mapping) -> tuple[dict[str, np.ndarray], np.nd def _scotland_numerators( - support, counts: Mapping + support, counts: Mapping[str, Mapping[str, int]] ) -> tuple[dict[str, np.ndarray], np.ndarray]: - """Each Scottish area's council chargeable dwellings by band A to H.""" + """Each Scottish area's 2022 data zone dwellings by band A to H.""" bands = {column: column.rsplit("_", 1)[1] for column in BAND_WEIGHT_COLUMNS[SCOT]} - by_council: dict[str, dict[str, int]] = {} - for row in counts["rows"]: - council = str(row["geography"]["id"]) - band = str(row["measure_id"]).removeprefix("band_") - value = row["value"] - if type(value) is not int or value < 0 or band in by_council.get(council, {}): - raise ValueError(f"Scottish band count {council} {band} is not one count.") - by_council.setdefault(council, {})[band] = value - councils = np.asarray(support.arrays["local_authority_code"]) - missing = sorted(set(councils.tolist()) - set(by_council)) - if missing or any(set(v) != set(bands.values()) for v in by_council.values()): + # The Scottish support's lsoa_code is the area's 2022 data zone. + zones = np.asarray(support.arrays["lsoa_code"]).tolist() + missing = sorted(set(zones) - set(counts)) + if missing or any(set(row) != set(bands.values()) for row in counts.values()): raise ValueError( - f"Scottish band counts do not cover each council A to H: {missing[:5]}." + f"Scottish band counts do not cover each data zone A to H: {missing[:5]}." ) numerators = { - column: np.asarray( - [by_council[c][band] for c in councils.tolist()], dtype=np.int64 - ) + column: np.asarray([counts[zone][band] for zone in zones], dtype=np.int64) for column, band in bands.items() } return numerators, sum(numerators.values()) @@ -416,30 +456,25 @@ def _metadata(system: str, support, resources: Mapping[str, dict]) -> dict: band = column.rsplit("_", 1)[1] if system == EW: resource = resources[VOA_BAND_MIX] + source = ( + f"{resource['publisher_package']}@sha256:{resource['publisher_sha256']}" + f"#{resource['resource']}@sha256:{resource['sha256']}" + ) share = f"voa_ctsop1_1_2025_lsoa_band_{band}_share_6dp" else: - resource = resources[SCOTLAND_BAND_COUNTS] - share = f"ctaxbase_2025_council_band_{band}_share_round_half_even" + source = f"{_source_tag('nrs_dz_dwellings')}#sheet-{NRS_SHEET}" + share = f"nrs_dz2022_{NRS_SHEET}_band_{band}_share_round_half_even" metadata[column] = { "kind": "weight", - "source": ( - f"{resource['publisher_package']}@sha256:{resource['publisher_sha256']}" - f"#{resource['resource']}@sha256:{resource['sha256']}" - ), + "source": source, "basis": f"{households}_x_{share}_x1e6", } return metadata -def _resources(directory: Path) -> tuple[dict, dict, dict[str, dict]]: +def _resources(directory: Path) -> tuple[dict, dict[str, dict]]: voa_path = directory / VOA_BAND_MIX - scot_path = directory / SCOTLAND_BAND_COUNTS voa = json.loads(voa_path.read_text(encoding="utf-8")) - scot = json.loads(scot_path.read_text(encoding="utf-8")) - raw_keys = {row["source"]["raw_r2_key"] for row in scot["rows"]} - shas = {row["source"]["source_sha256"] for row in scot["rows"]} - if len(raw_keys) != 1 or len(shas) != 1: - raise ValueError("Scottish band counts must come from one publisher file.") identities = { VOA_BAND_MIX: { "resource": VOA_BAND_MIX, @@ -449,16 +484,8 @@ def _resources(directory: Path) -> tuple[dict, dict, dict[str, dict]]: "publisher_file": voa["source"]["filename"], "as_at": voa["source"]["as_at"], }, - SCOTLAND_BAND_COUNTS: { - "resource": SCOTLAND_BAND_COUNTS, - "sha256": _sha256(scot_path), - "publisher_package": next(iter(raw_keys)).split("/")[2], - "publisher_sha256": next(iter(shas)), - "publisher_file": scot["rows"][0]["source"]["source_file"], - "as_at": scot["rows"][0]["period"]["value"], - }, } - return voa, scot, identities + return voa, identities def condition_supports( @@ -467,7 +494,7 @@ def condition_supports( deciles: Mapping[str, Mapping[int, str]], *, voa_mix: Mapping, - scotland_counts: Mapping, + scotland_counts: Mapping[str, Mapping[str, int]], resources: Mapping[str, dict], ) -> tuple[dict[str, bytes], dict[str, dict]]: """The three conditioned supports and each one's receipts.""" @@ -558,13 +585,13 @@ def main(argv: list[str] | None = None) -> None: } _log(" reading the NSPL") postcodes = _postcodes(paths["nspl"]) - voa, scot, resources = _resources(args.resource_dir) + voa, resources = _resources(args.resource_dir) payloads, entries = condition_supports( bases, postcodes, deciles, voa_mix=voa, - scotland_counts=scot, + scotland_counts=_nrs_band_counts(paths["nrs_dz_dwellings"]), resources=resources, ) args.out_dir.mkdir(parents=True, exist_ok=True) From b19a6d3b37ab54d2b4def5fe20e5d309261538e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Fri, 6 Nov 2026 18:25:41 +0000 Subject: [PATCH 13/20] Keep only the graph versions the caller reads (#931) run_graph kept every structural population version until the run ended and attached all of them to the manifest. Nothing serializes them, and the spine reads only its final version, but holding every one is what keeps a 15-clone spine from fitting in 32 GiB. A caller can now name the versions it reads, and the run frees every other one as soon as its last reader has run. - run_graph takes retain_populations. None, the default, keeps today's behaviour: every version is kept and attached. - Given a collection, a name that is not a version of the graph, or is not a name, is refused before any source is read. Each version's last reader comes from the compiled graph: its ordinary members read it as their incumbent, and each structural node built on it reads it as its base. Once that node has run, reached or not, the version leaves the run. Only the named versions and their mass ledgers are attached. - The UK opts in. The spine names its final version. Each dense and national phase names what it reads from its own manifest: the export the installed population, the national checkpoint and solve their own populations, the numerical phase the pool only when it writes a size checkpoint from a graph with a size search, and every other phase nothing. The atomic-assignment measurement names uk.full.expand. The transport CLI and the parity tools keep the default. No output moves. The keyword enters no key, receipt or cache record, and each node reads the same population as before. The new graph tests run a structural chain cold, warm and under resume="require", with and without the keyword: the store objects are byte-identical and the manifests agree on every field but the attached populations. Weak references show each dead version's tables freed right after its last reader and not before, for a version read by two members and two boundaries too, and when the last reader is unreached. The synthetic spine and dense builds keep only the versions they read. No kernel source hash binds an edited module, so no node key moves. Co-Authored-By: Claude Opus 5.5 --- .../build/uk_runtime/full_build_cli.py | 49 +- .../microcosm/build/uk_runtime/spine_build.py | 5 +- .../tests/engine_free/uk/test_uk_frs_spine.py | 53 ++ .../engine_free/uk/test_uk_full_build_cli.py | 56 ++ .../src/microcosm/graph/executor.py | 81 ++- .../src/microcosm/graph/manifest.py | 4 +- .../shared/test_graph_population_retention.py | 589 ++++++++++++++++++ tools/measure_uk_atomic_assignment.py | 1 + 8 files changed, 828 insertions(+), 10 deletions(-) create mode 100644 packages/microcosm-graph/tests/engine_free/shared/test_graph_population_retention.py diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/full_build_cli.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/full_build_cli.py index 7c442c56cb..53143b2aa0 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/full_build_cli.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/full_build_cli.py @@ -62,6 +62,7 @@ from microcosm.build.termination import BuildTerminatedError, raise_on_sigterm from microcosm.graph import ( ArtifactInput, + CompiledGraph, ContentStore, Graph, KernelRegistry, @@ -290,9 +291,13 @@ ) -def _run_graph_with_progress(compiled, *, execution=None, **kwargs): +def _run_graph_with_progress(compiled, *, retain_populations, execution=None, **kwargs): """Run a graph and emit one lightweight update per completed node. + ``retain_populations`` names the versions the caller reads from the + returned manifest, often none. The run frees every other version once + nothing reads it, so each phase says what it keeps. + ``execution`` (node id to cache hit) collects how this attempt reached each node. The first run to reach a node decides: a later run in the same attempt reports a hit for a node this attempt itself just computed. @@ -316,6 +321,7 @@ def observe(node_id, _population) -> None: manifest = run_graph( compiled, + retain_populations=retain_populations, _population_observer=observe, _population_observer_detach=False, **kwargs, @@ -2315,6 +2321,28 @@ def _close_staging( ) +def _writes_size_checkpoint(args: argparse.Namespace) -> bool: + """Whether the build writes the size checkpoint after the solve.""" + return ( + args.dataset_households is not None + and not args.no_size_checkpoint + and args.resume_size_checkpoint is None + ) + + +def _size_checkpoint_populations( + args: argparse.Namespace, compiled: CompiledGraph +) -> tuple[str, ...]: + """The versions :func:`_materialize_size_checkpoint` reads from this run. + + It reads the pool, and only when the build writes the checkpoint and the + graph runs the size search. + """ + if _writes_size_checkpoint(args) and "uk.full.size_search" in compiled.order: + return ("uk.full.pool",) + return () + + def _materialize_size_checkpoint( manifest, store, *, args: argparse.Namespace, pins: dict, source_year: int ) -> dict | None: @@ -2440,6 +2468,7 @@ def _execute_full_build( checkpoint = _run_solve_phase( compile_graph(_through(graph, endpoint)), required=reuse, + retain_populations=(), sources=sources, store=store, kernels=kernels, @@ -2456,6 +2485,7 @@ def _execute_full_build( preflight = _run_solve_phase( compile_graph(preflight_graph), required=reuse, + retain_populations=(), sources=sources, store=store, kernels=kernels, @@ -2512,6 +2542,7 @@ def _execute_full_build( _run_solve_phase( compile_graph(_solve_subgraph(graph)), required=True, + retain_populations=(), sources=sources, store=store, kernels=kernels, @@ -2527,8 +2558,10 @@ def _execute_full_build( epoch_every=staging_epoch_every(args), resumed_from_checkpoint=args.resume_size_checkpoint is not None, ) + numerical = compile_graph(_through(graph, "uk.full.gates.calibrated")) manifest = _run_graph_with_progress( - compile_graph(_through(graph, "uk.full.gates.calibrated")), + numerical, + retain_populations=_size_checkpoint_populations(args, numerical), sources=sources, store=store, kernels=kernels, @@ -2571,11 +2604,7 @@ def _execute_full_build( n_nonzero=diagnostics.get("n_nonzero"), realized_households=diagnostics.get("n_records"), ) - if ( - args.dataset_households is not None - and not args.no_size_checkpoint - and args.resume_size_checkpoint is None - ): + if _writes_size_checkpoint(args): receipt = _materialize_size_checkpoint( manifest, store, @@ -2645,6 +2674,7 @@ def _execute_full_build( stage(telemetry, "output_bundle", "started") manifest = _run_graph_with_progress( compile_graph(graph), + retain_populations=(full.population,), sources=sources, store=store, kernels=kernels, @@ -2727,6 +2757,7 @@ def _execute_full_build( ) final = _run_graph_with_progress( compile_graph(graph), + retain_populations=(), sources={ **sources, "exported_dataset": dataset, @@ -3154,6 +3185,7 @@ def _execute_national_build( stage(telemetry, "input_loading", "started") checkpoint = _run_graph_with_progress( compile_graph(_through(graph, "uk.full.spine_checkpoint")), + retain_populations=("uk.full.spine_checkpoint",), sources=sources, store=store, kernels=kernels, @@ -3182,6 +3214,7 @@ def _execute_national_build( stage(telemetry, "target_compilation", "started") targets = _run_graph_with_progress( compile_graph(_through(graph, NATIONAL_TARGETS_NODE)), + retain_populations=(), sources=sources, store=store, kernels=kernels, @@ -3239,6 +3272,7 @@ def _execute_national_build( ) manifest = _run_graph_with_progress( compile_graph(_through(graph, NATIONAL_GATES_NODE)), + retain_populations=(national.population,), sources=sources, store=store, kernels=kernels, @@ -3431,6 +3465,7 @@ def _execute_national_build( ) final = _run_graph_with_progress( compile_graph(continued), + retain_populations=(), sources={**sources, "exported_dataset": paths["dataset"]}, store=store, kernels=kernels, diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spine_build.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spine_build.py index a0879c8efd..f5e055e2f9 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spine_build.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spine_build.py @@ -2257,6 +2257,9 @@ def _main(argv: list[str] | None = None) -> int: else args.spine_h5.parent / f".{args.spine_h5.stem}.checkpoints" ) compiled_graph = compile_graph(graph) + # The spine reads only its final version from the manifest, so the run + # frees every other version once nothing reads it. + final_version = compiled_graph.versions[stage_names[-1]] graph_store = ContentStore(checkpoint_root / "node-graph") graph_manifest = run_graph( compiled_graph, @@ -2265,6 +2268,7 @@ def _main(argv: list[str] | None = None) -> int: kernels=prepared.kernels, resume="auto", decisions=(), + retain_populations=(final_version,), _population_observer=_graph_progress_observer( _ACTIVE_EMITTER, total=len(compiled_graph.order) ), @@ -2317,7 +2321,6 @@ def _main(argv: list[str] | None = None) -> int: graph_schema_path = save_uk_graph_schema( graph, graph_evidence_path.parent, scope="raw_spine", spec=spec ) - final_version = compiled_graph.versions[stage_names[-1]] frame = graph_manifest.population(final_version) records = _graph_stage_records( manifest=graph_manifest, diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_spine.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_spine.py index de75accc87..72eaa98d36 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_spine.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_spine.py @@ -3325,6 +3325,59 @@ def test_driver_writes_payload_identical_h5s( ) +def test_driver_keeps_only_the_final_graph_version( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + """The spine reads one version from its graph manifest and keeps only it. + + The graph run frees every other version once nothing reads it (#931), so + the manifest attaches the final stage's version and nothing else. + """ + pytest.importorskip("tables") + raw_dir = tmp_path / "raw" + stage = _write_fixture(raw_dir) + output = tmp_path / "spine.h5" + tool = _load_tool() + monkeypatch.setattr( + tool, "load_country_spec", lambda country: _synthetic_spec(stage) + ) + monkeypatch.setattr(tool, "_rules_engine", lambda: _FakeUKEngine()) + _stub_policy_readers(monkeypatch) + spi_tab, hmrc_ods = _patch_spi_spine_driver_runtime(tool, monkeypatch, tmp_path) + runs = [] + run_graph = tool.run_graph + + def recorded(compiled, **kwargs): + manifest = run_graph(compiled, **kwargs) + runs.append((compiled, kwargs["retain_populations"], manifest)) + return manifest + + monkeypatch.setattr(tool, "run_graph", recorded) + + assert ( + tool.main( + [ + "--frs-raw-dir", + str(raw_dir), + "--spine-h5", + str(output), + "--spi-tab", + str(spi_tab), + "--hmrc-ods", + str(hmrc_ods), + "--no-staging", + ] + ) + == 0 + ) + [(compiled, retained, manifest)] = runs + stage_names = tool._uk_spine_stage_names(_synthetic_spec(stage)) + final = compiled.versions[stage_names[-1]] + assert retained == (final,) + assert set(manifest.populations) == set(manifest.mass_ledgers) == {final} + assert len(set(compiled.versions.values())) > 1 + + def test_driver_refuses_missing_spi_tab(tmp_path: Path) -> None: tool = _load_tool() raw_dir = tmp_path / "raw" diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_full_build_cli.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_full_build_cli.py index 24b9d485d4..0d5e8ae379 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_full_build_cli.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_full_build_cli.py @@ -501,6 +501,62 @@ def forbidden(*args): assert not (out / "microcosm_uk_2025.h5").exists() +@pytest.mark.parametrize("sized", (False, True), ids=("unsized", "sized")) +def test_each_graph_phase_keeps_only_the_versions_it_reads( + tmp_path, monkeypatch, sized +): + """Only the export phase keeps a population: the one the H5 is written from. + + A graph run frees every version its caller does not name (#931). A sized + request writes the size checkpoint, but this graph runs no size search, so + the numerical phase keeps no pool. + """ + pytest.importorskip("tables") + extra = ("--dataset-households", "2") if sized else () + args = arguments(tmp_path, *extra) + build = prepared(tmp_path, size_households=2 if sized else None) + runs = [] + run_graph = cli.run_graph + + def recorded(compiled, **kwargs): + manifest = run_graph(compiled, **kwargs) + runs.append((kwargs["retain_populations"], set(manifest.populations))) + return manifest + + monkeypatch.setattr(cli, "run_graph", recorded) + assert cli.execute_full_build(build, args) == 0 + assert cli._writes_size_checkpoint(args) is sized + # The preflight, the numerical phase, the export and the certification run. + assert [retained for retained, _ in runs] == [ + (), + (), + (build.full.population,), + (), + ] + assert all(set(retained) == attached for retained, attached in runs) + + +@pytest.mark.parametrize( + ("extra", "searched", "kept"), + [ + (("--dataset-households", "2"), True, ("uk.full.pool",)), + (("--dataset-households", "2"), False, ()), + (("--dataset-households", "2", "--no-size-checkpoint"), True, ()), + ((), True, ()), + ], + ids=("checkpointed", "no-size-search", "no-checkpoint", "unsized"), +) +def test_the_numerical_phase_keeps_the_pool_only_for_the_size_checkpoint( + tmp_path, extra, searched, kept +): + """The size checkpoint reads the pool, so that phase keeps it when it runs.""" + args = arguments(tmp_path, *extra) + compiled = SimpleNamespace( + order=("uk.full.pool", *(("uk.full.size_search",) if searched else ())) + ) + assert cli._size_checkpoint_populations(args, compiled) == kept + + def test_the_dense_gate_replay_signs_a_bound_attempt_the_contract_accepts( tmp_path, monkeypatch ): diff --git a/packages/microcosm-graph/src/microcosm/graph/executor.py b/packages/microcosm-graph/src/microcosm/graph/executor.py index 91462ddf4b..8053f67eaf 100644 --- a/packages/microcosm-graph/src/microcosm/graph/executor.py +++ b/packages/microcosm-graph/src/microcosm/graph/executor.py @@ -8,7 +8,7 @@ import socket import stat import time -from collections.abc import Callable, Iterable, Mapping +from collections.abc import Callable, Collection, Iterable, Mapping from copy import deepcopy from dataclasses import dataclass, fields, replace from datetime import UTC, datetime @@ -2502,6 +2502,60 @@ def _preflight_expand_declarations(compiled: CompiledGraph) -> None: ) from error +def _retained_versions( + compiled: CompiledGraph, retain_populations: Collection[str] | None +) -> frozenset[str] | None: + """Check ``run_graph``'s ``retain_populations`` before the run does any work. + + ``None`` keeps every version, as before. A bare string is refused rather + than read as a collection of one-letter names, and so is a name that is + not a population version of this graph. + """ + + if retain_populations is None: + return None + if isinstance(retain_populations, str | bytes) or not isinstance( + retain_populations, Collection + ): + raise TypeError("retain_populations must be a collection of version names.") + names = tuple(retain_populations) + if not all(isinstance(name, str) for name in names): + raise TypeError("retain_populations must name each version as a string.") + unknown = sorted(set(names) - set(compiled.versions.values())) + if unknown: + raise ValueError( + f"retain_populations names {unknown!r}, which are not population " + "versions of this graph." + ) + return frozenset(names) + + +def _population_releases( + compiled: CompiledGraph, retained: frozenset[str] +) -> dict[str, tuple[str, ...]]: + """Map each node to the versions it is the last to use. + + The node that creates a version writes it. Each ordinary member reads the + version as its incumbent and writes its successor, and each structural + node built on it reads it as its base. Nothing else in a run reads a + version, so once the last of these nodes has run the executor holds the + version only for the manifest. A version that is not retained can go then. + """ + + last: dict[str, str] = {} + for node_id in compiled.order: + node = compiled.graph.node(node_id) + last[compiled.versions[node_id]] = node_id + if node.structural not in (StructuralDelta.NONE, StructuralDelta.CREATE): + assert node.base is not None + last[node.base] = node_id + releases: dict[str, list[str]] = {} + for version, node_id in last.items(): + if version not in retained: + releases.setdefault(node_id, []).append(version) + return {node_id: tuple(versions) for node_id, versions in releases.items()} + + def _evict_run_writes(store: ContentStore, written: Iterable[str]) -> list[str]: """Take back every object a refusing run published, and report what stayed. @@ -2609,12 +2663,23 @@ def run_graph( kernels: KernelRegistry, resume: ResumePolicy = "auto", decisions: tuple[Decision, ...] = (), + retain_populations: Collection[str] | None = None, _population_observer: Callable[[str, Population], None] | None = None, _population_observer_detach: bool = True, _verification_epoch: Mapping[str, object] | None = None, ) -> RunManifest: """Execute a compiled graph with content-addressed reuse and receipts. + ``retain_populations`` names the population versions the caller will read + from the manifest. The default, ``None``, keeps every version until the + run ends and attaches all of them. Given a collection, the run drops each + version it does not name once the last node that reads that version has + run, so its frame can be freed, and attaches only the named versions and + their mass ledgers. A version is read by its ordinary members and by every + structural node built on it. A name that is not a version of the graph is + refused before any work. Each node reads the same population with or + without the keyword, and it enters no key, no receipt and no cache record. + The private population observer exposes a detached snapshot of each node's admitted population, design anchors included, to an integrating verifier. It runs for cold execution and for restored cache hits alike, before the @@ -2676,6 +2741,7 @@ def run_graph( kernels=kernels, resume=resume, decisions=decisions, + retain_populations=retain_populations, written=written, run_sources=run_sources, _population_observer=_population_observer, @@ -2695,6 +2761,7 @@ def _execute_graph( kernels: KernelRegistry, resume: ResumePolicy, decisions: tuple[Decision, ...], + retain_populations: Collection[str] | None, written: set[str], run_sources: _RunSources, _population_observer: Callable[[str, Population], None] | None, @@ -2712,6 +2779,7 @@ def _execute_graph( raise ValueError("resume must be 'auto', 'require', or 'forbid'.") if type(_population_observer_detach) is not bool: raise TypeError("_population_observer_detach must be a bool.") + retained = _retained_versions(compiled, retain_populations) normalized_decisions: list[Decision] = [] for decision in decisions: if isinstance(decision, Decision): @@ -2742,6 +2810,10 @@ def _execute_graph( if resume == "require": _preflight_require(compiled, store, keys, implementations, kernels) + # Node id to the versions it is the last to use. Each leaves + # ``populations`` once that node has run, so its frame can be freed. + # Without ``retain_populations`` none leaves, and the manifest attaches all. + releases = {} if retained is None else _population_releases(compiled, retained) populations: dict[str, Population] = {} # Each structural version's ``Frame`` mass log as that version was # admitted. ``populations`` cannot answer this: an ordinary member @@ -2777,6 +2849,11 @@ def _execute_graph( resume=resume, ) receipt_payloads[node_id] = receipts[node_id].receipt + # An unreached node reads nothing, but it can still be a version's + # last reader. That version may never have been admitted, so its + # absence is not an error here. + for version in releases.get(node_id, ()): + populations.pop(version, None) continue if node.structural is StructuralDelta.CREATE: @@ -3126,6 +3203,8 @@ def _execute_graph( opaque_artifacts=MappingProxyType(receipt_opaque), ) receipt_payloads[node_id] = receipts[node_id].receipt + for version in releases.get(node_id, ()): + del populations[version] # Every source is re-derived in full, cache bypassed, before any caller # receives a manifest. This closes the two cases a stat signature cannot diff --git a/packages/microcosm-graph/src/microcosm/graph/manifest.py b/packages/microcosm-graph/src/microcosm/graph/manifest.py index 48ec44d233..9bb1d8eb18 100644 --- a/packages/microcosm-graph/src/microcosm/graph/manifest.py +++ b/packages/microcosm-graph/src/microcosm/graph/manifest.py @@ -680,7 +680,9 @@ def population(self, version_id: str) -> PopulationView: Population frames are deliberately not serialized in manifest JSON; a manifest restored from JSON therefore raises this explicit error - until a loader attaches them again. + until a loader attaches them again. A run that named the versions it + retains (``run_graph``'s ``retain_populations``) attaches only those, + and raises the same error for any other. """ try: diff --git a/packages/microcosm-graph/tests/engine_free/shared/test_graph_population_retention.py b/packages/microcosm-graph/tests/engine_free/shared/test_graph_population_retention.py new file mode 100644 index 0000000000..10854327d5 --- /dev/null +++ b/packages/microcosm-graph/tests/engine_free/shared/test_graph_population_retention.py @@ -0,0 +1,589 @@ +"""A run that names the versions it retains frees every other one. + +``run_graph(retain_populations=...)`` lets a caller say which population +versions it will read from the manifest. The default, ``None``, keeps every +version to the end of the run and attaches all of them, as before. Given a +collection, each version it does not name leaves the executor once the last +node that reads it has run, so its frame can be freed. These tests pin that +contract: + +- the store, the node keys, the receipts and the portable manifest are the + same with and without the keyword, cold, warm and under ``resume="require"``; +- only the named versions, and their mass ledgers, are attached; +- a dead version's tables are released after its last reader, and not before; +- a version read by several members and several structural nodes is kept + until the last of them has run; +- an unreached last reader still releases its version; +- a name that is not a version of the graph is refused before the run reads a + source, runs a kernel or writes to the store. + +Synthetic toy graph only: no data file, no country package, no engine. +""" + +from __future__ import annotations + +import hashlib +import json +import weakref +from collections.abc import Collection +from pathlib import Path + +import numpy as np +import pandas as pd +import pytest + +from microcosm.frame import EntitySchema, Frame, WeightKind, Weights +from microcosm.graph.decl import ( + ArtifactInput, + ArtifactOutput, + ArtifactType, + Graph, + Node, + Owned, + Slice, + SourceRef, + StructuralDelta, + compile_graph, +) +from microcosm.graph.executor import run_graph +from microcosm.graph.kernel import ( + Capabilities, + Determinism, + KernelContext, + KernelRegistry, + KernelResult, + KernelRole, +) +from microcosm.graph.manifest import NodeReceipt, PopulationView, RunManifest +from microcosm.graph.population import Population +from microcosm.graph.store import ContentStore + +SOURCE = SourceRef("survey", "csv-tables") +EVIDENCE = ArtifactType("gate.evidence", 1) + + +class _Kernel: + def __init__(self, ref: str, capabilities: Capabilities, compute) -> None: + self.ref = ref + self.capabilities = capabilities + self.compute = compute + self.calls = 0 + + def implementation_hash(self) -> str: + return hashlib.sha256(self.ref.encode()).hexdigest() + + def run(self, context: KernelContext) -> KernelResult: + self.calls += 1 + return self.compute(context) + + +def _source_path(root: Path) -> Path: + root.mkdir() + (root / "value.txt").write_text("0", encoding="utf-8") + return root + + +def _source_frame() -> Frame: + person = pd.DataFrame( + { + "person_id": np.asarray([1, 2, 3], dtype=np.int64), + "person_household_id": np.asarray([10, 10, 20], dtype=np.int64), + "age": np.asarray([10, 20, 30], dtype=np.int64), + "selected": pd.Series([True, False, True], dtype="boolean"), + } + ) + household = pd.DataFrame( + { + "household_id": np.asarray([10, 20], dtype=np.int64), + "size": np.asarray([2, 1], dtype=np.int64), + } + ) + return Frame( + {"person": person, "household": household}, + EntitySchema(group_entities=("household",)), + {"household": Weights(np.asarray([1.0, 2.0]), WeightKind.DESIGN)}, + pd.Series(["a", "a", "b"], name="stratum"), + ) + + +def _source(context: KernelContext) -> KernelResult: + return KernelResult(frame=_source_frame()) + + +def _double(context: KernelContext) -> KernelResult: + table = context.tables["person"] + values = table[str(context.params["source"])].to_numpy(dtype=np.float64) + return KernelResult( + columns={ + ("person", str(context.params["target"])): pd.Series( + values * 2.0, + index=pd.Index(table["person_id"], name="person_id"), + dtype="float64", + ) + } + ) + + +def _keep(context: KernelContext) -> KernelResult: + table = context.tables["person"] + if context.params["keep"] == "selected": + keep = table["selected"].to_numpy(dtype=np.bool_) + else: + keep = np.ones(len(table), dtype=np.bool_) + return KernelResult(keep=pd.Series(keep, index=table["person_id"], dtype="bool")) + + +def _refuse(context: KernelContext) -> KernelResult: + raise RuntimeError("evidence unavailable") + + +def _registry() -> KernelRegistry: + deterministic = Capabilities(Determinism.DETERMINISTIC) + registry = KernelRegistry() + for kernel in ( + _Kernel( + "source@1", + Capabilities(Determinism.DETERMINISTIC, structural=StructuralDelta.CREATE), + _source, + ), + _Kernel("double@1", deterministic, _double), + _Kernel( + "keep@1", + Capabilities(Determinism.DETERMINISTIC, structural=StructuralDelta.FILTER), + _keep, + ), + _Kernel( + "gate@1", + Capabilities(Determinism.DETERMINISTIC, role=KernelRole.GATE), + _refuse, + ), + _Kernel("use@1", deterministic, _double), + ): + registry.register(kernel) + return registry + + +CREATE = Node( + "survey", + "source@1", + sources=("survey",), + structural=StructuralDelta.CREATE, + outputs=( + Owned("person", "age", "int64"), + Owned("person", "selected", "boolean"), + Owned("household", "size", "int64"), + ), +) + + +def _member(node_id: str, version: str, source: str) -> Node: + """An ordinary member of ``version`` that writes the column named ``node_id``.""" + + return Node( + node_id, + "double@1", + inputs=(Slice("person", (source,)),), + outputs=(Owned("person", node_id, "float64"),), + params={"source": source, "target": node_id}, + population=version, + ) + + +def _boundary( + node_id: str, base: str, reads: str, *, keep_selected: bool = False +) -> Node: + """A FILTER on ``base``: an identity boundary, or one that drops a person.""" + + return Node( + node_id, + "keep@1", + structural=StructuralDelta.FILTER, + base=base, + inputs=(Slice("person", (reads,)),), + params={"keep": "selected" if keep_selected else "all"}, + mass="free" if keep_selected else "conserve", + ) + + +def _chain() -> Graph: + """``survey`` -> ``kept`` -> ``final``, with one member on each version. + + ``kept`` drops a person, so the versions differ in rows as well as in + columns; ``final`` keeps everyone, as an identity boundary does. The run + order is survey, a, kept, b, final, c. + """ + + return Graph( + "toy", + (SOURCE,), + ( + CREATE, + _member("a", "survey", "age"), + _boundary("kept", "survey", "selected", keep_selected=True), + _member("b", "kept", "a"), + _boundary("final", "kept", "b"), + _member("c", "final", "b"), + ), + ) + + +def _shared_base() -> Graph: + """``survey`` read by two members and by two structural nodes. + + ``first`` and ``second`` both build on ``survey`` at one depth, so + ``second`` is the last of its four readers. The run order is survey, a, b, + first, second, c, d. + """ + + return Graph( + "toy", + (SOURCE,), + ( + CREATE, + _member("a", "survey", "age"), + _member("b", "survey", "age"), + _boundary("first", "survey", "a"), + _boundary("second", "survey", "selected", keep_selected=True), + _member("c", "first", "a"), + _member("d", "second", "b"), + ), + ) + + +def _unreached_reader() -> Graph: + """``survey``'s last reader is a boundary that never runs. + + The gate raises, so the bytes ``use`` reads are never produced: ``use`` is + unreached, and so is ``boundary``, which reads ``use``'s column. ``beside`` + runs. The run order is survey, beside, gate, use, boundary. + """ + + gate = Node( + "gate", + "gate@1", + inputs=(Slice("person", ("age",)),), + outputs=(Owned("household", "gate_verdict", "string"),), + population="survey", + artifact_outputs=(ArtifactOutput("evidence", EVIDENCE),), + ) + use = Node( + "use", + "use@1", + inputs=(Slice("person", ("age",)),), + outputs=(Owned("person", "use", "float64"),), + params={"source": "age", "target": "use"}, + population="survey", + artifact_inputs=(ArtifactInput("evidence", "gate", "evidence", EVIDENCE),), + ) + return Graph( + "toy", + (SOURCE,), + ( + CREATE, + gate, + use, + _boundary("boundary", "survey", "use"), + _member("beside", "survey", "age"), + ), + ) + + +class _Liveness: + """An observer that records which versions' tables are still alive. + + It holds only weak references, to the tables of the latest population + admitted in each version, so it never keeps a version alive itself. At each + node it first records which of the versions seen so far are alive. By then + the executor has made its releases for every earlier node, and the node + being admitted still holds its own incumbent. The executor must hand it the + live population (``_population_observer_detach=False``): a detached + snapshot is a copy that dies at once. + + It runs no garbage collection. A released version's tables die by + reference counting alone, so they are freed at once, not at some later + collection. + """ + + def __init__(self) -> None: + self.tables: dict[str, dict[str, weakref.ref[pd.DataFrame]]] = {} + self.alive: dict[str, dict[str, bool]] = {} + + def __call__(self, node_id: str, population: Population) -> None: + self.alive[node_id] = self.alive_now() + self.tables[population.version] = { + entity: weakref.ref(population.frame.table(entity)) + for entity in population.frame.entities + } + + def alive_now(self) -> dict[str, bool]: + return { + version: any(table() is not None for table in tables.values()) + for version, tables in self.tables.items() + } + + +def _run( + graph: Graph, + source: Path, + store: ContentStore, + *, + retain: Collection[str] | None = None, + resume: str = "auto", + observer: _Liveness | None = None, + registry: KernelRegistry | None = None, +) -> RunManifest: + return run_graph( + compile_graph(graph), + sources={"survey": source}, + store=store, + kernels=_registry() if registry is None else registry, + resume=resume, # type: ignore[arg-type] + retain_populations=retain, + _population_observer=observer, + _population_observer_detach=observer is None, + ) + + +def _object_bytes(store: ContentStore) -> dict[str, bytes]: + return { + path.relative_to(store.objects).as_posix(): path.read_bytes() + for path in sorted(store.objects.rglob("*")) + if path.is_file() + } + + +def _portable(manifest: RunManifest) -> dict[str, object]: + """The manifest's JSON less the fields that move between two runs. + + Those are the two timestamps, the host, and the run-level fields of each + receipt (``NodeReceipt.RUN_LEVEL_FIELDS``). None of them reaches the key. + """ + + payload = json.loads(manifest.to_json()) + for name in ("started_at", "finished_at", "host"): + del payload[name] + for receipt in payload["nodes"].values(): + for name in sorted(NodeReceipt.RUN_LEVEL_FIELDS): + del receipt[name] + return payload + + +def _assert_same_version(actual: PopulationView, expected: PopulationView) -> None: + assert actual.entities == expected.entities + for entity in expected.entities: + pd.testing.assert_frame_equal(actual.table(entity), expected.table(entity)) + assert actual.weighted_entities == expected.weighted_entities + for entity in expected.weighted_entities: + assert actual.weights_for(entity).kind is expected.weights_for(entity).kind + np.testing.assert_array_equal( + actual.weights_for(entity).values, expected.weights_for(entity).values + ) + pd.testing.assert_series_equal(actual.strata, expected.strata) + assert actual.metadata == expected.metadata + assert actual.mass_log == expected.mass_log + + +# -------------------------------------------------------------------------- +# What retention must not move. +# -------------------------------------------------------------------------- + + +@pytest.mark.parametrize( + "retain", + [("final",), ("survey", "final"), frozenset({"kept"}), ()], + ids=("final", "survey-and-final", "kept", "none"), +) +@pytest.mark.parametrize( + ("warm", "resume"), + [(False, "auto"), (True, "auto"), (True, "require")], + ids=("cold", "warm", "require"), +) +def test_retention_moves_no_store_object_key_receipt_or_manifest_field( + tmp_path: Path, warm: bool, resume: str, retain: Collection[str] +) -> None: + """Two runs of one graph, with and without the keyword, into two stores.""" + + source = _source_path(tmp_path / "source") + every_store = ContentStore(tmp_path / "every") + named_store = ContentStore(tmp_path / "named") + if warm: + for store in (every_store, named_store): + _run(_chain(), source, store) + every = _run(_chain(), source, every_store, resume=resume) + named = _run(_chain(), source, named_store, resume=resume, retain=retain) + + assert _object_bytes(named_store) == _object_bytes(every_store) + assert all(receipt.hit is warm for receipt in named.nodes.values()) + assert named.key == every.key + assert _portable(named) == _portable(every) + assert dict(named.source_identities) == dict(every.source_identities) + assert dict(named.verification_epoch) == dict(every.verification_epoch) == {} + + +@pytest.mark.parametrize( + "retain", + [("final",), ("survey", "final"), ["kept"], ()], + ids=("final", "survey-and-final", "kept", "none"), +) +def test_only_the_named_versions_and_their_mass_ledgers_are_attached( + tmp_path: Path, retain: Collection[str] +) -> None: + """A named version is attached exactly as the default run attaches it.""" + + source = _source_path(tmp_path / "source") + every = _run(_chain(), source, ContentStore(tmp_path / "every")) + named = _run(_chain(), source, ContentStore(tmp_path / "named"), retain=retain) + + versions = {"survey", "kept", "final"} + assert set(every.populations) == set(every.mass_ledgers) == versions + assert set(named.populations) == set(named.mass_ledgers) == set(retain) + for version in retain: + _assert_same_version(named.population(version), every.population(version)) + assert named.mass_ledger(version) == every.mass_ledger(version) + for version in versions - set(retain): + with pytest.raises(KeyError, match="is not attached to this manifest"): + named.population(version) + with pytest.raises(KeyError, match="is not attached to this manifest"): + named.mass_ledger(version) + + +# -------------------------------------------------------------------------- +# When a version is released. +# -------------------------------------------------------------------------- + + +@pytest.mark.parametrize("warm", (False, True), ids=("cold", "warm")) +def test_a_dead_version_is_released_after_its_last_reader( + tmp_path: Path, warm: bool +) -> None: + """On a structural chain each version goes once the next boundary has run. + + ``survey`` is last read by ``kept`` and ``kept`` by ``final``. With + ``final`` retained, ``survey`` is gone by the time ``b`` is admitted and + ``kept`` by the time ``c`` is. The default run keeps both to the end. + """ + + source = _source_path(tmp_path / "source") + every_store = ContentStore(tmp_path / "every") + named_store = ContentStore(tmp_path / "named") + if warm: + for store in (every_store, named_store): + _run(_chain(), source, store) + + every = _Liveness() + _run(_chain(), source, every_store, observer=every) + named = _Liveness() + manifest = _run(_chain(), source, named_store, observer=named, retain=("final",)) + + assert all(receipt.hit is warm for receipt in manifest.nodes.values()) + assert list(named.alive) == list(compile_graph(_chain()).order) + assert named.alive["kept"] == {"survey": True} + assert named.alive["b"] == {"survey": False, "kept": True} + assert named.alive["final"] == {"survey": False, "kept": True} + assert named.alive["c"] == {"survey": False, "kept": False, "final": True} + assert every.alive["c"] == {"survey": True, "kept": True, "final": True} + assert named.alive_now() == {"survey": False, "kept": False, "final": True} + # What is still alive is the attached version itself. + attached = manifest.population("final") + for entity, table in named.tables["final"].items(): + assert table() is attached.table(entity) + + +@pytest.mark.parametrize("warm", (False, True), ids=("cold", "warm")) +def test_a_version_read_by_several_nodes_is_kept_until_the_last( + tmp_path: Path, warm: bool +) -> None: + """Two members and two structural nodes read ``survey``; it waits for all four. + + Dropping it after a member or after ``first`` would leave ``second`` with + no base, and the run would fail. + """ + + source = _source_path(tmp_path / "source") + every_store = ContentStore(tmp_path / "every") + named_store = ContentStore(tmp_path / "named") + if warm: + for store in (every_store, named_store): + _run(_shared_base(), source, store) + + every = _Liveness() + _run(_shared_base(), source, every_store, observer=every) + named = _Liveness() + manifest = _run( + _shared_base(), source, named_store, observer=named, retain=("first", "second") + ) + + assert all(receipt.hit is warm for receipt in manifest.nodes.values()) + assert list(named.alive) == list(compile_graph(_shared_base()).order) + assert named.alive["first"]["survey"] is True + assert named.alive["second"]["survey"] is True + assert named.alive["c"]["survey"] is False + assert named.alive["d"] == {"survey": False, "first": True, "second": True} + assert every.alive["d"]["survey"] is True + assert set(manifest.populations) == {"first", "second"} + assert manifest.population("second").table("person")["person_id"].tolist() == [ + 1, + 3, + ] + + +@pytest.mark.parametrize( + "retain", [(), ("boundary",)], ids=("none", "the-unreached-version") +) +def test_an_unreached_last_reader_still_releases_its_version( + tmp_path: Path, retain: Collection[str] +) -> None: + """``boundary`` never runs, but it is ``survey``'s last reader all the same. + + The default run attaches ``survey`` and has no ``boundary`` to attach. A run + that does not retain ``survey`` attaches nothing, even when it names the + version ``boundary`` would have opened. + """ + + source = _source_path(tmp_path / "source") + every = _run(_unreached_reader(), source, ContentStore(tmp_path / "every")) + named = _run( + _unreached_reader(), source, ContentStore(tmp_path / "named"), retain=retain + ) + + assert named.nodes["boundary"].receipt["execution"]["state"] == "unreached" + assert set(every.populations) == {"survey"} + assert dict(named.populations) == {} + assert dict(named.mass_ledgers) == {} + assert named.key == every.key + + +# -------------------------------------------------------------------------- +# What is refused. +# -------------------------------------------------------------------------- + + +@pytest.mark.parametrize( + ("retain", "error", "message"), + [ + (("missing",), ValueError, r"\['missing'\], which are not population"), + (("final", "a"), ValueError, r"\['a'\], which are not population"), + ("final", TypeError, "a collection of version names"), + (b"final", TypeError, "a collection of version names"), + (iter(("final",)), TypeError, "a collection of version names"), + (("final", 1), TypeError, "each version as a string"), + ], + ids=("unknown", "a-member", "a-string", "bytes", "an-iterator", "not-a-string"), +) +def test_a_name_that_is_not_a_version_is_refused_before_any_work( + tmp_path: Path, retain: object, error: type[Exception], message: str +) -> None: + """The source does not exist, so a refusal after any read would differ.""" + + registry = _registry() + store = ContentStore(tmp_path / "store") + with pytest.raises(error, match=message): + _run( + _chain(), + tmp_path / "absent", + store, + retain=retain, # type: ignore[arg-type] + registry=registry, + ) + assert _object_bytes(store) == {} + assert all(kernel.calls == 0 for kernel in registry.as_mapping().values()) diff --git a/tools/measure_uk_atomic_assignment.py b/tools/measure_uk_atomic_assignment.py index 280dca2b3c..f4a888de8d 100644 --- a/tools/measure_uk_atomic_assignment.py +++ b/tools/measure_uk_atomic_assignment.py @@ -238,6 +238,7 @@ def run_cell(args: argparse.Namespace, *, law: str, k: int): store=ContentStore(args.graph_store), kernels=prepared.kernels, resume="auto", + retain_populations=("uk.full.expand",), ) wall = time.perf_counter() - started population = manifest.population("uk.full.expand") From 6745bed143ffb642570f17988fbba84549b2af30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Fri, 6 Nov 2026 23:29:07 +0000 Subject: [PATCH 14/20] Release each stage's result once its evidence is captured (#931) Each UK stage keeps its last result, output Frame included, in last_result, and the stage transforms live for the whole run. Only the evidence snapshot each kernel takes right after its stage runs reads that result, so on a 15-clone spine the retained frames are memory nothing reads (an upper bound of about 45-50 GiB). - stage_evidence gains release_stage_results. It walks the same wrappers as the fit-weight probe, now through one shared walk, and clears last_result wherever an object holds one itself. It writes through object.__setattr__, so frozen stages are cleared too. It never writes on a wrapper that only proxies the attribute, and it keeps the wrapped objects, fit-weight records, receipts and sampling. - The UK create, stage and expand kernels call it right after they encode their evidence, when the registry asks. build_uk_registry and uk_registry take release_stage_results, False by default, so a caller or test that reads last_result after a run is unchanged. - prepare_uk_spine_execution turns it on. That covers the spine and the full build's --spine-request route, which prepares its spine through it. The full build's --input-h5 route and the national line bind no stage transforms. Nothing reads a live transform after its snapshot. Inside the stages, last_result is read only by checkpoint_metadata and by the SPI income stage's fit_weight_records, both reached only from the snapshot. The spine driver, its gates, the sidecar, the weights audit and the dense and national lines read stored evidence. The graph source transform keeps the stage it built. Without its result that stage holds only small evidence, and a late read still reaches it: most stages' checkpoint hooks then refuse, where a dropped stage would read as no evidence at all. The release changes no stored byte. A truncated spine run, with stages of every shape that keeps a result, stores the same objects under the same keys, byte for byte, with and without it. Each result it frees dies at once, by reference counting alone, so no wrapper still holds one. A synthetic run of the spine driver's own graph, with and without main's observation wrappers, leaves no stage result held, the expanding SPI support stage's included. Fit-weight records read from a result are still captured. Against the previous code, the same truncated run stores identical column and stage-evidence payloads and kernel receipts, node for node. Keys move, though no payload does. Every UK create and stage kernel's hash binds stage_evidence, so an edit there re-keys the whole spine, wherever the switch lives. Every kernel in graph_kernels.py hashes that file, so its claim and identity kernels move too. All 79 declared spine node keys move, and the gate nodes' with them. So does every record that carries a key: store metadata and cache records, receipt keys and kernel hashes, the manifests, the graph evidence and the spine sidecar. In-graph spine caches go cold. A full build re-keys from its spine on its --spine-request route, and from uk.full.expand.owned onward when it starts from an --input-h5 checkpoint. The national graph binds none of these kernels, and no committed pin binds their hashes. Co-Authored-By: Claude Opus 5.5 --- .../src/microcosm/build/stage_evidence.py | 45 +++- .../src/microcosm/build/uk_runtime/graph.py | 8 +- .../build/uk_runtime/graph_kernels.py | 89 ++++++- .../microcosm/build/uk_runtime/spine_build.py | 5 +- .../engine_free/shared/test_stage_evidence.py | 131 ++++++++++ .../tests/engine_free/uk/test_uk_frs_spine.py | 68 +++++ .../engine_free/uk/test_uk_graph_evidence.py | 243 +++++++++++++++++- 7 files changed, 569 insertions(+), 20 deletions(-) diff --git a/packages/microcosm-build/src/microcosm/build/stage_evidence.py b/packages/microcosm-build/src/microcosm/build/stage_evidence.py index 2bffe3ef06..8dd224a1b5 100644 --- a/packages/microcosm-build/src/microcosm/build/stage_evidence.py +++ b/packages/microcosm-build/src/microcosm/build/stage_evidence.py @@ -2,19 +2,36 @@ Capture only their declared checkpoint/evidence hooks after computation. Model objects, closures and execution timestamps never become numerical artifacts. -Consumers need only this data contract, not a live fitting instance. +Consumers need only this data contract, not a live fitting instance. Once a +stage's evidence is captured, :func:`release_stage_results` lets a run drop +the result the stage kept, output Frame included. """ from __future__ import annotations import json -from collections.abc import Mapping +from collections.abc import Iterator, Mapping from microcosm.graph import ArtifactType STAGE_EVIDENCE_TYPE = ArtifactType("microcosm.stage-evidence", 1) +def _proxy_chain(transform: object | None) -> Iterator[object]: + """The object a staged run holds, then each object it wraps. + + A wrapper keeps the object it wraps under ``transform`` in its own + ``__dict__``. The walk follows that entry and stops at a repeat. + """ + + seen: set[int] = set() + candidate: object | None = transform + while candidate is not None and id(candidate) not in seen: + seen.add(id(candidate)) + yield candidate + candidate = getattr(candidate, "__dict__", {}).get("transform") + + def _fit_weight_hook_holder(transform: object | None) -> object | None: """The object declaring ``fit_weight_records``, seen through the proxies. @@ -27,14 +44,10 @@ def _fit_weight_hook_holder(transform: object | None) -> object | None: release-cut weights audit finds no evidence. """ - seen: set[int] = set() - candidate: object | None = transform - while candidate is not None and id(candidate) not in seen: - seen.add(id(candidate)) + for candidate in _proxy_chain(transform): declared = getattr(type(candidate), "fit_weight_records", None) is not None if declared or "fit_weight_records" in getattr(candidate, "__dict__", {}): return candidate - candidate = getattr(candidate, "__dict__", {}).get("transform") return None @@ -88,6 +101,24 @@ def snapshot_stage_evidence(stage: str, transform: object | None) -> dict[str, o return payload +def release_stage_results(transform: object | None) -> None: + """Drop the result a stage kept from its last run, once it is snapshotted. + + Call it only after :func:`snapshot_stage_evidence` has read the stage. + The snapshot is then all a consumer reads, yet a stage keeps its + ``last_result``, output Frame included, until the run ends. This walks + the same wrappers as the snapshot and clears ``last_result`` wherever an + object holds one in its own ``__dict__``. It writes through + ``object.__setattr__``, so a frozen dataclass is cleared too. A wrapper + that only proxies the attribute is never written, and everything else + stays: the wrapped objects, fit-weight records, receipts and sampling. + """ + + for candidate in _proxy_chain(transform): + if getattr(candidate, "__dict__", {}).get("last_result") is not None: + object.__setattr__(candidate, "last_result", None) + + def encode_stage_evidence(payload: Mapping[str, object]) -> bytes: """Encode finite JSON; reject nonportable state rather than pickling it.""" diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py index 8a52bfbf14..91e41365c0 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py @@ -1954,14 +1954,20 @@ def uk_registry( implementations: Mapping[str, object] | None = None, *, graph: Graph | None = None, + release_stage_results: bool = False, ) -> KernelRegistry: - """Return kernels for ``graph``, optionally bound to real stage transforms.""" + """Return kernels for ``graph``, optionally bound to real stage transforms. + + ``release_stage_results`` has each stage drop its retained result once + its evidence is captured; the default keeps it. + """ from .graph_kernels import build_uk_registry return build_uk_registry( uk_spine_graph() if graph is None else graph, {} if implementations is None else implementations, + release_stage_results=release_stage_results, ) diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py index 143426861e..a64c3773bf 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py @@ -419,7 +419,12 @@ def _mass_log_payload(before: Frame, after: Frame) -> list[dict[str, object]]: def _stage_artifacts( - stage: str, transform: object | None, before: Frame | None, after: Frame + stage: str, + transform: object | None, + before: Frame | None, + after: Frame, + *, + release: bool = False, ) -> dict[str, bytes]: document = stage_evidence.snapshot_stage_evidence(stage, transform) document["frame_mass_log_append"] = ( @@ -438,7 +443,12 @@ def _stage_artifacts( ) if before is None: document["frame_context"] = {"metadata": dict(after.metadata)} - return {"stage_evidence": stage_evidence.encode_stage_evidence(document)} + artifacts = {"stage_evidence": stage_evidence.encode_stage_evidence(document)} + if release: + # The bytes above are all that later steps read of this stage, so the + # result it kept, output Frame included, need not live for the run. + stage_evidence.release_stage_results(transform) + return artifacts def _invoke_transform(transform: object, frame: Frame, context: KernelContext): @@ -1156,8 +1166,14 @@ class UKCreateKernel(KernelBase): ref = "uk.create@1" capabilities = _CREATE - def __init__(self, transform: object | None = None) -> None: + def __init__( + self, + transform: object | None = None, + *, + release_stage_results: bool = False, + ) -> None: self.transform = transform + self.release_stage_results = release_stage_results def implementation_hash(self) -> str: return _implementation_hash(self, "frs_spine", self.transform) @@ -1178,7 +1194,13 @@ def run(self, context: KernelContext) -> KernelResult: ) return KernelResult( frame=_normalize_create_frame(frame, context), - artifacts=_stage_artifacts("frs_spine", self.transform, None, frame), + artifacts=_stage_artifacts( + "frs_spine", + self.transform, + None, + frame, + release=self.release_stage_results, + ), ) @@ -1232,10 +1254,13 @@ def __init__( stage: str, transform: object | None = None, fixture_resolver: _FixtureTransformResolver | None = None, + *, + release_stage_results: bool = False, ) -> None: self.stage = stage self.transform = transform self.fixture_resolver = fixture_resolver + self.release_stage_results = release_stage_results self.ref = f"uk.stage.{stage}@1" def implementation_hash(self) -> str: @@ -1267,7 +1292,13 @@ def run(self, context: KernelContext) -> KernelResult: } return KernelResult( columns=MappingProxyType(columns), - artifacts=_stage_artifacts(self.stage, transform, before, after), + artifacts=_stage_artifacts( + self.stage, + transform, + before, + after, + release=self.release_stage_results, + ), receipt={ "stage": self.stage, "frame_mass_log_append": _mass_log_payload(before, after), @@ -1359,10 +1390,13 @@ def __init__( stage: str, transform: object | None = None, fixture_resolver: _FixtureTransformResolver | None = None, + *, + release_stage_results: bool = False, ) -> None: self.stage = stage self.transform = transform self.fixture_resolver = fixture_resolver + self.release_stage_results = release_stage_results self.ref = f"uk.stage.expand.{stage}@1" def implementation_hash(self) -> str: @@ -1438,7 +1472,13 @@ def run(self, context: KernelContext) -> KernelResult: columns=MappingProxyType(columns), expand=MappingProxyType(expand), weights=after_weights, - artifacts=_stage_artifacts(self.stage, transform, before, after), + artifacts=_stage_artifacts( + self.stage, + transform, + before, + after, + release=self.release_stage_results, + ), receipt=receipt, ) @@ -1491,8 +1531,18 @@ def _declared_mass_receipt( def build_uk_registry( graph: Graph, implementations: Mapping[str, object], + *, + release_stage_results: bool = False, ) -> KernelRegistry: - """Bind graph refs to supplied transforms or the hermetic H2 descriptor.""" + """Bind graph refs to supplied transforms or the hermetic H2 descriptor. + + With ``release_stage_results``, each stage kernel drops the result its + transform kept as soon as the stage's evidence is captured + (:func:`~microcosm.build.stage_evidence.release_stage_results`). The + default keeps it, for a caller that reads ``last_result`` after the run. + The setting enters no key: it changes what a live transform holds, never + what a node computes or stores. + """ stage_names = { str(node.params["stage"]) for node in graph.nodes if "stage" in node.params @@ -1508,7 +1558,12 @@ def build_uk_registry( ) registry = KernelRegistry() - registry.register(UKCreateKernel(implementations.get("frs_spine"))) + registry.register( + UKCreateKernel( + implementations.get("frs_spine"), + release_stage_results=release_stage_results, + ) + ) registry.register(UKIdentityKernel()) registry.register(UKClaimKernel()) fixture_resolver = _FixtureTransformResolver() @@ -1523,9 +1578,23 @@ def build_uk_registry( "cgt_incidence_anchor", "cgt_residential_split", }: - registry.register(UKExpandStageKernel(stage, transform, fixture_resolver)) + registry.register( + UKExpandStageKernel( + stage, + transform, + fixture_resolver, + release_stage_results=release_stage_results, + ) + ) else: - registry.register(UKStageKernel(stage, transform, fixture_resolver)) + registry.register( + UKStageKernel( + stage, + transform, + fixture_resolver, + release_stage_results=release_stage_results, + ) + ) # Gate bindings carry the live rules engine and are registered separately # after population-stage construction by the composing build. diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/spine_build.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/spine_build.py index f5e055e2f9..c967ed0585 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/spine_build.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/spine_build.py @@ -2106,7 +2106,10 @@ def prepare_uk_spine_execution( release_candidate=args.release_candidate, synthetic_smoke=args.synthetic_fixture_dir is not None, ) - kernels = uk_registry(implementations, graph=graph) + # The spine and the full build read each stage's evidence from the store, + # never from a live transform, so each stage frees its result once its + # evidence is captured. + kernels = uk_registry(implementations, graph=graph, release_stage_results=True) register_spine_gate_kernel( kernels, spec=spec, engine=engine, engine_identity=engine_identity ) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_stage_evidence.py b/packages/microcosm-build/tests/engine_free/shared/test_stage_evidence.py index 7832b0a4e0..400a902128 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_stage_evidence.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_stage_evidence.py @@ -1,13 +1,16 @@ """Stored evidence is independent of the transform instance that produced it.""" import json +from dataclasses import dataclass, field from types import SimpleNamespace import pytest +from microcosm.build.observation import ObservedTransform from microcosm.build.stage_evidence import ( decode_stage_evidence, encode_stage_evidence, + release_stage_results, snapshot_stage_evidence, ) @@ -51,3 +54,131 @@ def test_stage_evidence_refuses_wrong_identity_and_nonportable_data(): decode_stage_evidence(json.dumps(mutated).encode(), stage="one") with pytest.raises(ValueError): encode_stage_evidence({"value": float("nan")}) + + +@dataclass(frozen=True) +class _FrozenStage: + """Keeps its result as the UK stages do, in a frozen field set per run.""" + + last_result: object | None = field(default=None, init=False) + + def __call__(self, frame): + result = SimpleNamespace(frame=frame, rows=len(frame.person)) + object.__setattr__(self, "last_result", result) + return frame + + def checkpoint_metadata(self): + if self.last_result is None: + raise RuntimeError("checkpoint metadata requires a completed stage run.") + return {"evidence": {"rows": self.last_result.rows}} + + +class _SourceBuilt: + """A graph source transform: it keeps the stage it built in its own + ``__dict__`` and proxies every other read to it.""" + + def __init__(self, transform): + self.transform = transform + + def run_with_sources(self, frame, sources): + return self.transform(frame) + + def __getattr__(self, name): + return getattr(self.__dict__["transform"], name) + + +def test_release_clears_a_frozen_result_through_the_run_wrappers(small_frame): + stage = _FrozenStage() + source = _SourceBuilt(stage) + wrapped = ObservedTransform( + source, stage_id="wealth", produced_column_count=1, observer=None + ) + wrapped.run_with_sources(small_frame, {}) + payload = encode_stage_evidence(snapshot_stage_evidence("wealth", wrapped)) + + release_stage_results(wrapped) + + assert stage.last_result is None + assert decode_stage_evidence(payload, stage="wealth")["evidence"] == {"rows": 4} + # Neither wrapper gained an attribute of its own, so both still proxy the + # stage, and a later run's result reads through them. + assert "last_result" not in vars(wrapped) + assert "last_result" not in vars(source) + assert source.transform is stage + wrapped.run_with_sources(small_frame, {}) + assert wrapped.last_result is stage.last_result is not None + # The stage itself stays, so a read after the release fails loudly. + release_stage_results(wrapped) + with pytest.raises(RuntimeError, match="completed stage run"): + wrapped.checkpoint_metadata() + + +def test_release_keeps_the_fit_weight_evidence_snapshotted_before_it(): + record = SimpleNamespace(fit_name="wealth", weight_kind="design") + + @dataclass(frozen=True) + class ResultRecords: + """Reads its records from its result, as the SPI income stage does.""" + + last_result: object | None = field(default=None, init=False) + + @property + def fit_weight_records(self): + return () if self.last_result is None else self.last_result.records + + @dataclass + class KeptRecords: + """Keeps its records beside its result, as the WAS stage does.""" + + last_fit_weight_records: tuple = () + last_result: object | None = None + + @property + def fit_weight_records(self): + return tuple(self.last_fit_weight_records) + + from_result = ResultRecords() + object.__setattr__(from_result, "last_result", SimpleNamespace(records=(record,))) + beside = KeptRecords((record,), SimpleNamespace()) + for name, stage in (("from_result", from_result), ("beside", beside)): + payload = encode_stage_evidence(snapshot_stage_evidence(name, stage)) + release_stage_results(stage) + recovered = decode_stage_evidence(payload, stage=name) + assert recovered["fit_weight_records"] == [ + {"fit_name": "wealth", "weight_kind": "design"} + ] + assert recovered["fit_weight_records_status"] == "present" + assert stage.last_result is None + # Records read from the result go with it, so only the snapshot taken + # before the release carries them; records kept beside it stay. + assert from_result.fit_weight_records == () + assert beside.fit_weight_records == (record,) + + +def test_release_writes_only_a_result_an_object_holds_itself(): + class NeverRan: + last_result = None + + class Derived: + @property + def last_result(self): + return "derived" + + class Loop: + def __init__(self): + self.transform = self + self.last_result = SimpleNamespace() + self.last_receipt = {"rows": 1} + self.sampling = {"fraction": 1.0} + + release_stage_results(None) + never_ran = NeverRan() + release_stage_results(never_ran) + assert "last_result" not in vars(never_ran) + derived = Derived() + release_stage_results(derived) + assert derived.last_result == "derived" + loop = Loop() + release_stage_results(loop) + assert loop.last_result is None + assert (loop.last_receipt, loop.sampling) == ({"rows": 1}, {"fraction": 1.0}) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_spine.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_spine.py index 72eaa98d36..70f0a881e7 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_spine.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_frs_spine.py @@ -3263,6 +3263,74 @@ def test_driver_writes_spine_h5_sidecars_and_logbook( assert rows[0].disposition == "iterating" +@pytest.mark.parametrize("observed", [False, True]) +def test_driver_kernels_free_each_stage_result_once_its_evidence_is_captured( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, observed: bool +) -> None: + """The spine driver, and the full build that prepares its spine through + it, read stage evidence only from the store. So every stage kernel the + preparation binds frees its transform's result once that evidence is + captured, an expanding stage's too. ``main`` wraps each stage in an + observation wrapper and the full build does not, so the run is checked + both ways (microcosm#931).""" + + from microcosm.build.stage_evidence import _proxy_chain + from microcosm.graph import ContentStore, compile_graph, run_graph + + raw_dir = tmp_path / "raw" + stage = _write_fixture(raw_dir) + tool = _load_tool() + monkeypatch.setattr( + tool, "load_country_spec", lambda country: _synthetic_spec(stage) + ) + monkeypatch.setattr(tool, "_rules_engine", lambda: _FakeUKEngine()) + _stub_policy_readers(monkeypatch) + spi_tab, hmrc_ods = _patch_spi_spine_driver_runtime(tool, monkeypatch, tmp_path) + + prepared = tool.prepare_uk_spine_execution( + tool.parse_uk_spine_args( + [ + "--frs-raw-dir", + str(raw_dir), + "--spine-h5", + str(tmp_path / "spine.h5"), + "--spi-tab", + str(spi_tab), + "--hmrc-ods", + str(hmrc_ods), + "--no-staging", + ] + ), + observer=(lambda observation: None) if observed else None, + ) + + kernels = prepared.kernels.as_mapping() + stage_refs = { + ref for ref in kernels if ref == "uk.create@1" or ref.startswith("uk.stage.") + } + assert "uk.stage.expand.spi_support_channel@1" in stage_refs + assert all(kernels[ref].release_stage_results is True for ref in stage_refs) + run_graph( + compile_graph(prepared.graph), + sources=prepared.sources, + store=ContentStore(tmp_path / "store"), + kernels=prepared.kernels, + resume="forbid", + decisions=(), + ) + # Every object behind a stage's wrappers that keeps a result holds none + # now. The SPI support stage expands its rows; the relationships stage is + # built by a graph source transform. + kept = { + name: candidate.__dict__["last_result"] + for name, transform in prepared.implementations.items() + for candidate in _proxy_chain(transform) + if "last_result" in getattr(candidate, "__dict__", {}) + } + assert {"spi_support_channel", "frs_relationships"} <= kept.keys() + assert {name for name, result in kept.items() if result is not None} == set() + + def test_driver_writes_payload_identical_h5s( tmp_path: Path, monkeypatch: pytest.MonkeyPatch ) -> None: diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_graph_evidence.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_graph_evidence.py index 79ad0ad60f..d32f639d07 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_graph_evidence.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_graph_evidence.py @@ -1,9 +1,11 @@ """Spine evidence survives cached execution and a completely fresh process.""" +import gc import json import subprocess import sys -from dataclasses import replace +import weakref +from dataclasses import dataclass, field, replace from types import SimpleNamespace import pytest @@ -96,6 +98,245 @@ def checkpoint_metadata(self): assert sidecar["fit_weight_records"]["frs_spine"][0]["weight_kind"] == "design" +def _with_outputs(frame, outputs): + """``frame`` with a zero in each declared output it does not yet carry.""" + + from microcosm.frame import Frame + + tables = {entity: frame.table(entity).copy() for entity in frame.entities} + for owned in outputs: + if owned.column not in tables[owned.entity]: + tables[owned.entity][owned.column] = 0 + return Frame( + tables, + frame.schema, + {entity: frame.weights_for(entity) for entity in frame.weighted_entities}, + frame.strata, + mass_log=frame.mass_log, + metadata=frame.metadata, + ) + + +def _object_bytes(store): + """Every file the store holds, by its path under the store's objects.""" + + return { + path.relative_to(store.objects).as_posix(): path.read_bytes() + for path in sorted(store.objects.rglob("*")) + if path.is_file() + } + + +def _result_keeping_stages(graph): + """Fresh transforms of each shape that keeps a result, with their holders. + + The root and the age stage are frozen dataclasses written through + ``object.__setattr__``, as the UK stages are. A graph source transform + builds the relationships stage. The employment stage reads its fit-weight + records from its result, as the SPI income stage does. The council tax + stage has no checkpoint hook, so the snapshot reads its result itself. + Every stage but that one sits behind an observation wrapper. A weak + reference to each result a stage keeps shows whether anything holds it. + """ + + from microcosm.build.observation import ObservedTransform + from microcosm.build.uk_runtime.spine_build import _GraphSourceTransform + + record = SimpleNamespace(fit_name="fixture-fit", weight_kind="design") + outputs = {node.id: node.outputs for node in graph.nodes} + results = [] + + class Result(SimpleNamespace): + """A stage's result. Unlike a bare namespace, it takes a weak reference.""" + + def kept(**fields): + result = Result(**fields) + results.append(weakref.ref(result)) + return result + + def unrun(): + return RuntimeError("checkpoint metadata requires a completed stage run.") + + @dataclass(frozen=True) + class Root: + sampling = {"fraction": 1.0, "seed": 7} + last_result: object | None = field(default=None, init=False) + + def run_with_sources(self, frame, sources): + loaded = load_source("csv-tables", sources["frs"]) + object.__setattr__(self, "last_result", kept(frame=loaded)) + return loaded + + def checkpoint_metadata(self): + if self.last_result is None: + raise unrun() + households = len(self.last_result.frame.table("household")) + return {"evidence": {"households": households}} + + @dataclass(frozen=True) + class Stage: + outputs: tuple + last_result: object | None = field(default=None, init=False) + + def __call__(self, frame): + result = kept(frame=_with_outputs(frame, self.outputs)) + object.__setattr__(self, "last_result", result) + return result.frame + + def checkpoint_metadata(self): + if self.last_result is None: + raise unrun() + return {"evidence": {"people": len(self.last_result.frame.person)}} + + @dataclass + class ResultRecords: + outputs: tuple + last_result: object | None = None + + @property + def fit_weight_records(self): + return () if self.last_result is None else self.last_result.records + + def __call__(self, frame): + self.last_result = kept( + frame=_with_outputs(frame, self.outputs), records=(record,) + ) + return self.last_result.frame + + def checkpoint_metadata(self): + if self.last_result is None: + raise unrun() + return {"evidence": {"fits": len(self.last_result.records)}} + + class ResultEvidence: + def __init__(self, outputs): + self.outputs = outputs + self.last_result = None + + def __call__(self, frame): + result = _with_outputs(frame, self.outputs) + households = len(result.table("household")) + self.last_result = kept( + frame=result, evidence=lambda: {"households": households} + ) + return result + + def observed(transform, stage): + return ObservedTransform( + transform, stage_id=stage, produced_column_count=1, observer=None + ) + + built = [] + + def build_relationships(sources): + built.append(ResultRecords(outputs["frs_relationships"])) + return built[-1] + + root = Root() + age = Stage(outputs["age_tail"]) + relationships = _GraphSourceTransform(build_relationships) + employment = ResultRecords(outputs["frs_employment"]) + council_tax = ResultEvidence(outputs["frs_council_tax"]) + implementations = { + "frs_spine": observed(root, "frs_spine"), + "age_tail": observed(age, "age_tail"), + "frs_relationships": observed(relationships, "frs_relationships"), + "frs_employment": observed(employment, "frs_employment"), + "frs_council_tax": council_tax, + } + + def holders(): + # The relationships stage is the one the source transform built. + [relationships_stage] = built + return { + "frs_spine": root, + "age_tail": age, + "frs_relationships": relationships_stage, + "frs_employment": employment, + "frs_council_tax": council_tax, + } + + return implementations, holders, relationships, results + + +def test_released_stage_results_leave_every_stored_byte_and_no_result(tmp_path): + """A run that frees each stage's kept result once its evidence is captured + stores what a run that keeps them stores, byte for byte, and each result + it frees dies at once (microcosm#931).""" + + country = load_country_spec("uk") + country = replace( + country, sources=replace(country.sources, stages=country.sources.stages[:5]) + ) + graph = uk_spine_graph(country) + compiled = compile_graph(graph) + source = ( + paths_for("microcosm-graph").tests + / "fixtures" + / "parity" + / "uk_spine" + / "sources" + ) + runs = {} + for release in (False, True): + stages = _result_keeping_stages(graph) + implementations, result_holders, source_built, results = stages + run_store = ContentStore(tmp_path / f"release-{release}") + # No garbage collection runs, so a result is dead only once nothing + # references it, not after some collection. + collecting = gc.isenabled() + gc.disable() + try: + manifest = run_graph( + compiled, + sources={"frs": source}, + store=run_store, + kernels=uk_registry( + implementations, graph=graph, release_stage_results=release + ), + resume="forbid", + ) + alive = [result() is not None for result in results] + finally: + if collecting: + gc.enable() + runs[release] = (manifest, run_store, result_holders(), source_built, alive) + kept, kept_store, kept_holders, _, kept_alive = runs[False] + released, store, holders, relationships, released_alive = runs[True] + + # Both runs store the same objects under the same keys, byte for byte. + assert released.key == kept.key + assert released.nodes.keys() == kept.nodes.keys() + for node_id, receipt in kept.nodes.items(): + assert released.nodes[node_id].key == receipt.key + assert _object_bytes(store) == _object_bytes(kept_store) + # Each stage keeps its result unless the run frees it, frozen ones too. + # A freed result dies at once, so no wrapper holds it either. + assert all(holder.last_result is not None for holder in kept_holders.values()) + assert all(holder.last_result is None for holder in holders.values()) + assert len(kept_alive) == len(released_alive) == len(implementations) + assert all(kept_alive) + assert not any(released_alive) + # The source transform keeps the stage it built and the records it read + # from it; only the result goes. + assert relationships.transform is holders["frs_relationships"] + assert relationships.fit_weight_records + # The fit-weight records were captured before the release, including + # those the employment stage could read only from its result. + stored = load_spine_stage_artifacts( + released, store, stage_names=uk_spine_endpoint(graph).stage_names + ) + for stage in ("frs_relationships", "frs_employment"): + assert stored[stage]["fit_weight_records"] == [ + {"fit_name": "fixture-fit", "weight_kind": "design"} + ] + assert stored[stage]["fit_weight_records_status"] == "present" + assert holders["frs_employment"].fit_weight_records == () + assert stored["frs_council_tax"]["evidence"] == { + "households": stored["frs_spine"]["evidence"]["households"] + } + + def test_spine_inventory_is_roster_derived_and_gates_bind_checkpoint_versions(): country = load_country_spec("uk") spine = uk_spine_graph(country) From 2d67333c27f6450fb390f9db8e64799baa3573e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Sat, 7 Nov 2026 03:49:11 +0000 Subject: [PATCH 15/20] Write and reuse structural graph versions one column at a time (#931) A structural node stores every column of its version, then the whole frame. _write_node first built a copy of every column, each with its own copy of the entity's ids, and only then wrote the first one. On a late 15-clone spine frame that is a second frame plus one id array per column, about 10 GiB held at every structural write on top of the version itself. A cache hit on a structural node did the same the other way round: it loaded every stored column, each with its own ids, and held them all while it loaded the frame, though it returns only the frame. The spine runs on a persistent node store with resume="auto", so a spine restarted after a failure meets that at every structural node it already stored. - The structural write now streams. Every dtype token is still taken first, so an unsupported dtype is refused before anything is written. Then each entity's ids are copied once, each column is copied only when it is written, and each copy goes before the next is made. The order is the same sorted (entity, column) order, so the record lists the same entries. - put_column only reads the series and its ids. It wraps the ids in a new index without copying them, writes them and keeps nothing once it returns, so one id array shared by an entity's columns writes the same bytes as one copy per column. - A structural hit still loads every column, in the record's order, and still refuses a damaged or repeated one, but it keeps none of them: its version comes from the frame. An ordinary hit still returns the columns it loads. - The ordinary-node write and the frame, weight, opaque and record writes are unchanged. Integration layer 02 (69b94b4a5) once wrote this per column too, taking each dtype token only when it reached the column, so an unsupported dtype would have been refused after earlier columns were stored. The #893 reconciliation (80fef2217) dropped it for want of a consumer. This version takes every token first and shares one id index per entity, and the 15-clone UK spine is its consumer. No output moves. The new graph tests keep the old structural column copies verbatim but for their names, and only those stand in for the new ones, so the rest of the write is shared. A toy graph with CREATE, FILTER, REWEIGHT and EXPAND nodes stores byte-identical objects under the same keys with either, cold, warm and rewritten under resume="forbid", every node's artifacts match in order, and the warm run, where every node hits, reports what the cold run did. A direct write of a frame with every graph dtype, nulls, and entities and columns out of sorted order returns the same artifacts and record, and an unsupported dtype still leaves the store empty. Weak references show each column copy gone before the next is made, and each entity's columns share one id index. They show a structural hit loading each column in the record's order and holding none once it loads the next one or the frame, and a damaged or repeated column is still refused. On a synthetic frame with 10 MB of columns, tracemalloc puts the write's peak at 2.1 MB, against 22.3 MB before, and a structural hit's at 34.9 MB, against 55.1 MB before. What remains of the hit is the frame load itself. No kernel source hash or committed pin binds the executor, so no node key moves. Co-Authored-By: Claude Opus 5.5 --- .../src/microcosm/graph/executor.py | 63 +- .../test_graph_executor_structural_columns.py | 846 ++++++++++++++++++ 2 files changed, 896 insertions(+), 13 deletions(-) create mode 100644 packages/microcosm-graph/tests/engine_free/shared/test_graph_executor_structural_columns.py diff --git a/packages/microcosm-graph/src/microcosm/graph/executor.py b/packages/microcosm-graph/src/microcosm/graph/executor.py index 8053f67eaf..0c2986a4de 100644 --- a/packages/microcosm-graph/src/microcosm/graph/executor.py +++ b/packages/microcosm-graph/src/microcosm/graph/executor.py @@ -8,7 +8,7 @@ import socket import stat import time -from collections.abc import Callable, Collection, Iterable, Mapping +from collections.abc import Callable, Collection, Iterable, Iterator, Mapping from copy import deepcopy from dataclasses import dataclass, fields, replace from datetime import UTC, datetime @@ -1637,17 +1637,46 @@ def _apply_result( raise NodeRejected(f"Node {node.id!r} patch rejected: {error}") from error -def _series_for_column(frame: Frame, entity: str, column: str) -> pd.Series: - table = frame.table(entity) - id_column = frame.schema.entity_id_column(entity) +def _series_for_column(table: pd.DataFrame, column: str, ids: pd.Index) -> pd.Series: return pd.Series( table[column].array.copy(), - index=pd.Index(table[id_column].to_numpy(copy=True), name=id_column), + index=ids, name=column, dtype=table[column].dtype, ) +def _version_series( + frame: Frame, +) -> Iterator[tuple[tuple[str, str], tuple[pd.Series, str]]]: + """Yield the columns a structural version stores, one copy at a time. + + They come sorted by entity and then by column, the order of the node's + record. Each column is copied only when it is reached. Each entity's ids + are copied once and shared by its columns: the store only reads them, so + sharing them changes no stored byte. Holding every copy at once, each + with its own ids, would cost about twice the frame at every structural + write. Every dtype token is taken first, so an unsupported dtype is + still refused before anything is written. + """ + + tokens = { + entity: { + column: _dtype_token(frame.table(entity)[column]) + for column in frame.table(entity).columns + } + for entity in frame.entities + } + for entity in sorted(tokens): + table = frame.table(entity) + id_column = frame.schema.entity_id_column(entity) + ids = pd.Index(table[id_column].to_numpy(copy=True), name=id_column) + for column, token in sorted(tokens[entity].items()): + # The copy is never bound to a name here, so once the write lets + # it go nothing holds it. + yield (entity, column), (_series_for_column(table, column, ids), token) + + def _write_node( store: ContentStore, node: Node, @@ -1662,20 +1691,21 @@ def _write_node( verify_existing: bool, typed_artifacts: Mapping[str, object] | None = None, ) -> tuple[dict[tuple[str, str], str], dict[str, object]]: - columns: dict[tuple[str, str], tuple[pd.Series, str]] = {} + written: Iterable[tuple[tuple[str, str], tuple[pd.Series, str]]] if node.structural is StructuralDelta.NONE: declared = {(owned.entity, owned.column): owned for owned in node.outputs} + columns: dict[tuple[str, str], tuple[pd.Series, str]] = {} for coordinate, series in result.columns.items(): columns[coordinate] = (series, declared[coordinate].dtype) + written = sorted(columns.items()) else: - for entity in population.frame.entities: - for column in population.frame.table(entity).columns: - series = _series_for_column(population.frame, entity, column) - columns[(entity, column)] = (series, _dtype_token(series)) + # A structural version stores every column it carries, so they are + # copied and written one at a time rather than all held at once. + written = _version_series(population.frame) column_entries: list[dict[str, str]] = [] manifest_artifacts: dict[tuple[str, str], str] = {} - for (entity, column), (series, token) in sorted(columns.items()): + for (entity, column), (series, token) in written: output_key = artifact_key(key, entity, column) store.put_column( output_key, @@ -1687,6 +1717,8 @@ def _write_node( ) column_entries.append({"entity": entity, "column": column, "key": output_key}) manifest_artifacts[(entity, column)] = output_key + # A structural column's copy goes before the next one is made. + del series stored_frame_key: str | None = None if node.structural is not StructuralDelta.NONE: @@ -2024,9 +2056,14 @@ def _load_cached_result( except KeyError as error: raise StoreCorrupt("Cached node column entry is malformed.") from error coordinate = (entity, column) - if coordinate in stored_columns: + if coordinate in manifest_artifacts: raise StoreCorrupt(f"Cached node repeats column {entity}.{column}.") - stored_columns[coordinate] = store.load_column(output_key) + if node.structural is StructuralDelta.NONE: + stored_columns[coordinate] = store.load_column(output_key) + else: + # A structural version comes back whole from its frame below, so + # each of its columns is only checked here and none is kept. + store.load_column(output_key) manifest_artifacts[coordinate] = output_key result_columns: dict[tuple[str, str], pd.Series] = {} diff --git a/packages/microcosm-graph/tests/engine_free/shared/test_graph_executor_structural_columns.py b/packages/microcosm-graph/tests/engine_free/shared/test_graph_executor_structural_columns.py new file mode 100644 index 0000000000..a0dcb0bb95 --- /dev/null +++ b/packages/microcosm-graph/tests/engine_free/shared/test_graph_executor_structural_columns.py @@ -0,0 +1,846 @@ +"""A structural version's columns pass through the store one at a time. + +A structural node stores every column of its population version as its own +id-indexed column object, and then the whole frame. ``_write_node`` used to +copy every column, each with its own copied id index, before it wrote the +first one, so a write held a second frame and one id array per column. It now +copies each column only when it writes it, copies each entity's ids once, and +lets each copy go before the next. A cache hit on a structural node used to +load every stored column and hold them all while it loaded the frame, though +it returns only the frame. It now checks each column and lets it go. These +tests pin that nothing written or returned moves: + +- every store object, key and bytes, and every node's artifacts, in order, + equal those written from ``_reference_version_series`` below, the old + structural branch kept verbatim but for its names, for CREATE, FILTER, + REWEIGHT and EXPAND nodes and the ordinary nodes between them, cold, warm + and rewritten under ``resume="forbid"``, and a warm run reports what the + cold run did; +- a direct write of a frame with every graph dtype, nulls, and entities and + columns out of sorted order returns the reference's artifacts and record + and stores the reference's objects; +- an unsupported dtype is still refused before anything is written; +- each column copy is gone before the next is made, each entity's columns + share one id index, and the write's traced peak is a small part of the + reference's; +- a structural hit still loads every column, in the record's order, and + refuses a damaged or repeated one, but it holds none of them, so its traced + peak is its frame load's. + +Synthetic frames only: no data file, no country package, no engine. +""" + +from __future__ import annotations + +import gc +import hashlib +import json +import re +import tracemalloc +import weakref +from collections.abc import Callable, Iterator, Mapping +from contextlib import contextmanager +from pathlib import Path + +import numpy as np +import pandas as pd +import pytest + +import microcosm.graph.executor as graph_executor +from microcosm.frame import EntitySchema, Frame, WeightKind, Weights +from microcosm.graph.decl import ( + Graph, + Node, + Owned, + Slice, + SourceRef, + StructuralDelta, + WeightTransition, + compile_graph, +) +from microcosm.graph.executor import ( + NodeRejected, + _dtype_token, + _structural_columns, + run_graph, +) +from microcosm.graph.kernel import ( + Capabilities, + Determinism, + KernelContext, + KernelRegistry, + KernelResult, +) +from microcosm.graph.manifest import NodeReceipt, RunManifest +from microcosm.graph.population import Population +from microcosm.graph.store import ContentStore, StoreCorrupt + +SOURCE = SourceRef("survey", "csv-tables") + + +# -------------------------------------------------------------------------- +# The pre-change column copies, kept as the reference. +# -------------------------------------------------------------------------- + + +def _reference_series_for_column(frame: Frame, entity: str, column: str) -> pd.Series: + """The pre-change column copy, kept verbatim: a new id index every call.""" + + table = frame.table(entity) + id_column = frame.schema.entity_id_column(entity) + return pd.Series( + table[column].array.copy(), + index=pd.Index(table[id_column].to_numpy(copy=True), name=id_column), + name=column, + dtype=table[column].dtype, + ) + + +def _reference_version_series( + frame: Frame, +) -> list[tuple[tuple[str, str], tuple[pd.Series, str]]]: + """The pre-change structural branch of ``_write_node``, verbatim but for names. + + It copies every column, each with its own id index, and takes each copy's + dtype token before the first is written. The write then walks the copies + in sorted order. Only this step changed, so the reference stands in for + ``_version_series`` alone and the rest of the write is shared. It returns + the sorted list itself, so the write holds every copy until it returns, + as the old dict did. + """ + + columns: dict[tuple[str, str], tuple[pd.Series, str]] = {} + for entity in frame.entities: + for column in frame.table(entity).columns: + series = _reference_series_for_column(frame, entity, column) + columns[(entity, column)] = (series, _dtype_token(series)) + return sorted(columns.items()) + + +@contextmanager +def _column_copies(*, reference: bool) -> Iterator[None]: + """Have ``_write_node`` take the reference's column copies when asked.""" + + with pytest.MonkeyPatch.context() as patch: + if reference: + patch.setattr(graph_executor, "_version_series", _reference_version_series) + yield + + +@contextmanager +def _without_collection() -> Iterator[None]: + """No garbage collection runs, so an object is dead once nothing holds it.""" + + collecting = gc.isenabled() + gc.disable() + try: + yield + finally: + if collecting: + gc.enable() + + +def _object_bytes(store: ContentStore) -> dict[str, bytes]: + return { + path.relative_to(store.objects).as_posix(): path.read_bytes() + for path in sorted(store.objects.rglob("*")) + if path.is_file() + } + + +def _all_coordinates(frame: Frame) -> list[tuple[str, str]]: + """Every (entity, column) a frame carries, in its own order.""" + + return [ + (entity, column) + for entity in frame.entities + for column in frame.table(entity).columns + ] + + +def _column_entries(record: Mapping[str, object]) -> list[dict[str, str]]: + """A node record's column entries, in its order.""" + + entries = record["columns"] + assert isinstance(entries, list) + return entries + + +# -------------------------------------------------------------------------- +# A toy graph with every structural delta. +# -------------------------------------------------------------------------- + + +class _Kernel: + def __init__(self, ref: str, capabilities: Capabilities, compute) -> None: + self.ref = ref + self.capabilities = capabilities + self.compute = compute + + def implementation_hash(self) -> str: + return hashlib.sha256(self.ref.encode()).hexdigest() + + def run(self, context: KernelContext) -> KernelResult: + return self.compute(context) + + +def _source_path(root: Path) -> Path: + root.mkdir() + (root / "value.txt").write_text("0", encoding="utf-8") + return root + + +def _survey_frame() -> Frame: + """Columns out of sorted order, one of every graph dtype, nulls included.""" + + person = pd.DataFrame( + { + "person_id": np.asarray([1, 2, 3, 4], dtype=np.int64), + "zeta": np.asarray([-0.0, np.nan, np.inf, 5e-324], dtype=np.float64), + "person_household_id": np.asarray([10, 10, 20, 20], dtype=np.int64), + "selected": np.asarray([True, True, True, False]), + "age": np.asarray([40, 12, 70, 35], dtype=np.int64), + "maybe": pd.array([True, None, False, True], dtype="boolean"), + "count": np.asarray([1, -2, 3, 0], dtype=np.int32), + "nullable": pd.array([None, 2, -3, 4], dtype="Int64"), + "ratio": np.asarray([0.5, 1.5, -0.25, 3.0], dtype=np.float32), + "label": pd.array(["a", "", None, "é\U0001f600"], dtype="string"), + } + ) + household = pd.DataFrame( + { + "size": np.asarray([2, 2], dtype=np.int64), + "household_id": np.asarray([10, 20], dtype=np.int64), + "region": pd.array(["north", None], dtype="string"), + } + ) + return Frame( + {"person": person, "household": household}, + EntitySchema(group_entities=("household",)), + {"household": Weights(np.asarray([1.0, 2.0]), WeightKind.DESIGN)}, + pd.Series(["a", "a", "b", "b"], name="stratum"), + ) + + +def _source(context: KernelContext) -> KernelResult: + return KernelResult(frame=_survey_frame()) + + +def _double(context: KernelContext) -> KernelResult: + table = context.tables["person"] + return KernelResult( + columns={ + ("person", "a"): pd.Series( + table["age"].to_numpy(dtype=np.float64) * 2.0, + index=pd.Index(table["person_id"], name="person_id"), + dtype="float64", + ) + } + ) + + +def _keep(context: KernelContext) -> KernelResult: + table = context.tables["person"] + return KernelResult( + keep=pd.Series( + table["selected"].to_numpy(dtype=np.bool_), + index=table["person_id"], + dtype="bool", + ) + ) + + +def _reweight(context: KernelContext) -> KernelResult: + before = context.weights["household"].values + return KernelResult(weights=Weights(before * 2.0, WeightKind.IMPORTANCE)) + + +def _clone(context: KernelContext) -> KernelResult: + """Household 10 and its two people are cloned as household 30. + + The clone and its source share the source's doubled weight. + """ + + return KernelResult( + expand={ + "person": pd.Series( + [1, 2], index=pd.Index([5, 6], name="person_id"), dtype="int64" + ), + "household": pd.Series( + [10], index=pd.Index([30], name="household_id"), dtype="int64" + ), + }, + columns={ + ("household", "is_clone"): pd.Series( + [False, False, True], + index=pd.Index([10, 20, 30], name="household_id"), + dtype="bool", + ) + }, + weights=Weights(np.asarray([1.0, 4.0, 1.0]), WeightKind.IMPORTANCE), + ) + + +def _claim(context: KernelContext) -> KernelResult: + household = context.tables["household"] + return KernelResult( + columns={ + ("household", "is_clone"): pd.Series( + household["is_clone"].array.copy(), + index=pd.Index(household["household_id"], name="household_id"), + dtype="bool", + ) + } + ) + + +def _registry() -> KernelRegistry: + deterministic = Capabilities(Determinism.DETERMINISTIC) + registry = KernelRegistry() + for ref, structural, compute in ( + ("source@1", StructuralDelta.CREATE, _source), + ("double@1", StructuralDelta.NONE, _double), + ("keep@1", StructuralDelta.FILTER, _keep), + ("reweight@1", StructuralDelta.REWEIGHT, _reweight), + ("clone@1", StructuralDelta.EXPAND, _clone), + ("claim@1", StructuralDelta.NONE, _claim), + ): + capabilities = ( + deterministic + if structural is StructuralDelta.NONE + else Capabilities(Determinism.DETERMINISTIC, structural=structural) + ) + registry.register(_Kernel(ref, capabilities, compute)) + return registry + + +def _graph() -> Graph: + """survey -> kept -> pool -> clone, with an ordinary node on two versions. + + ``kept`` drops person 4, ``pool`` doubles the household weights and + ``clone`` adds household 30 with two people and a new column. + """ + + return Graph( + "toy", + (SOURCE,), + ( + Node( + "survey", + "source@1", + sources=("survey",), + structural=StructuralDelta.CREATE, + outputs=( + Owned("person", "zeta", "float64"), + Owned("person", "selected", "bool"), + Owned("person", "age", "int64"), + Owned("person", "maybe", "boolean"), + Owned("person", "count", "int32"), + Owned("person", "nullable", "Int64"), + Owned("person", "ratio", "float32"), + Owned("person", "label", "string"), + Owned("household", "size", "int64"), + Owned("household", "region", "string"), + ), + ), + Node( + "a", + "double@1", + inputs=(Slice("person", ("age",)),), + outputs=(Owned("person", "a", "float64"),), + population="survey", + ), + Node( + "kept", + "keep@1", + structural=StructuralDelta.FILTER, + base="survey", + inputs=(Slice("person", ("selected",)),), + mass="free", + ), + Node( + "pool", + "reweight@1", + structural=StructuralDelta.REWEIGHT, + base="kept", + inputs=(Slice("household", ("size",)),), + weights=WeightTransition("household", "importance", mass="free"), + mass="free", + ), + Node( + "clone", + "clone@1", + structural=StructuralDelta.EXPAND, + base="pool", + params={ + "expand_cells": (("household", "is_clone", "bool"),), + "expand_weight_entity": "household", + "expand_weight_kind": "importance", + }, + mass="free", + entrants=True, + ), + Node( + "claim_clone", + "claim@1", + outputs=(Owned("household", "is_clone", "bool"),), + params={"materialized_expand_outputs": ("household.is_clone",)}, + population="clone", + ), + ), + ) + + +STRUCTURAL = ("survey", "kept", "pool", "clone") + + +def _run( + source: Path, + store: ContentStore, + *, + resume: str = "auto", + reference: bool = False, +) -> RunManifest: + with _column_copies(reference=reference): + return run_graph( + compile_graph(_graph()), + sources={"survey": source}, + store=store, + kernels=_registry(), + resume=resume, # type: ignore[arg-type] + ) + + +def _portable(manifest: RunManifest) -> dict[str, object]: + """The manifest's JSON less the fields that move between two runs. + + Those are the two timestamps, the host, and the run-level fields of each + receipt (``NodeReceipt.RUN_LEVEL_FIELDS``). None of them reaches the key. + """ + + payload = json.loads(manifest.to_json()) + for name in ("started_at", "finished_at", "host"): + del payload[name] + for receipt in payload["nodes"].values(): + for name in sorted(NodeReceipt.RUN_LEVEL_FIELDS): + del receipt[name] + return payload + + +@pytest.mark.parametrize( + "resume", ("cold", "warm", "forbid"), ids=("cold", "warm", "forbid-over-warm") +) +def test_every_structural_node_stores_the_reference_objects( + tmp_path: Path, resume: str +) -> None: + """The live and the reference column copies, each into its own store. + + A warm run writes nothing and every node hits, so it shows the streamed + objects load back as the reference's do, and that a hit reports what the + cold run computed. ``resume="forbid"`` rewrites every object over the warm + store, through the store's write-only replacement. + """ + + source = _source_path(tmp_path / "source") + live_store = ContentStore(tmp_path / "live") + reference_store = ContentStore(tmp_path / "reference") + cold: RunManifest | None = None + if resume != "cold": + cold = _run(source, live_store) + _run(source, reference_store, reference=True) + policy = "forbid" if resume == "forbid" else "auto" + live = _run(source, live_store, resume=policy) + reference = _run(source, reference_store, resume=policy, reference=True) + + assert _object_bytes(live_store) == _object_bytes(reference_store) + assert all(receipt.hit is (resume == "warm") for receipt in live.nodes.values()) + assert live.key == reference.key + assert _portable(live) == _portable(reference) + if cold is not None: + assert _portable(live) == _portable(cold) + for node_id, receipt in live.nodes.items(): + expected = reference.nodes[node_id] + assert list(receipt.artifacts.items()) == list(expected.artifacts.items()) + assert receipt.frame_key == expected.frame_key + assert receipt.weight_key == expected.weight_key + for node_id in STRUCTURAL: + receipt = live.nodes[node_id] + assert receipt.frame_key is not None + written = live_store.load_frame(receipt.frame_key) + artifacts = list(receipt.artifacts) + assert artifacts == sorted(_all_coordinates(written)) + # The frame lists the person first, and the record the household. + assert written.entities[0] == "person" + assert artifacts[0][0] == "household" + + +# -------------------------------------------------------------------------- +# One direct write, against the reference. +# -------------------------------------------------------------------------- + + +KEY = hashlib.sha256(b"a structural write").hexdigest() + + +def _every_dtype_frame(*, benunit_membership: str = "int64") -> Frame: + """Three entities, which sort as benunit, household, person. + + The person ids are not in order, every graph dtype is present with its + nulls, and each table lists its columns out of sorted order. + """ + + person = pd.DataFrame( + { + "person_id": np.asarray([30, 10, 20, 40], dtype=np.int64), + "zeta": np.asarray([-0.0, np.nan, np.inf, 5e-324], dtype=np.float64), + "person_household_id": np.asarray([100, 100, 200, 200], dtype=np.int64), + "person_benunit_id": np.asarray([7, 7, 8, 9], dtype=benunit_membership), + "flag": np.asarray([True, False, True, False]), + "maybe": pd.array([True, None, False, None], dtype="boolean"), + "count": np.asarray([1, -2, 3, 0], dtype=np.int32), + "nullable": pd.array([None, 2, None, -4], dtype="Int64"), + "ratio": np.asarray([0.5, 1.5, -0.25, 3.0], dtype=np.float32), + "label": pd.array( + ["a", "", None, "é\U0001f600"], dtype=pd.StringDtype("python") + ), + "age": np.asarray([40, 12, 70, 35], dtype=np.int64), + "code": pd.array(["x", None, "y\0z", ""], dtype="string"), + } + ) + household = pd.DataFrame( + { + "size": np.asarray([2, 2], dtype=np.int64), + "household_id": np.asarray([100, 200], dtype=np.int64), + "region": pd.array(["north", None], dtype=pd.StringDtype("python")), + } + ) + benunit = pd.DataFrame( + { + "zz": np.asarray([1.0, -1.0, 0.0], dtype=np.float64), + "benunit_id": np.asarray([7, 8, 9], dtype=np.int64), + "aa": pd.array([None, 1, 2], dtype="Int64"), + } + ) + return Frame( + {"person": person, "household": household, "benunit": benunit}, + EntitySchema(group_entities=("household", "benunit")), + {"household": Weights(np.asarray([1.0, 2.0]), WeightKind.DESIGN)}, + pd.Series(["a", "a", "b", "b"], name="stratum"), + ) + + +def _create_node(frame: Frame) -> Node: + return Node( + "survey", + "source@1", + sources=("survey",), + structural=StructuralDelta.CREATE, + outputs=tuple( + Owned(entity, column, _dtype_token(frame.table(entity)[column])) + for entity in frame.entities + for column in frame.table(entity).columns + if column not in _structural_columns(frame, entity) + ), + ) + + +def _write( + store: ContentStore, frame: Frame, *, reference: bool = False +) -> tuple[dict[tuple[str, str], str], dict[str, object]]: + """Write ``frame`` as a CREATE node's version, from either column copies.""" + + node = _create_node(frame) + with _column_copies(reference=reference): + return graph_executor._write_node( + store, + node, + key=KEY, + kernel_impl_hash=hashlib.sha256(b"source@1").hexdigest(), + capabilities=Capabilities( + Determinism.DETERMINISTIC, structural=StructuralDelta.CREATE + ), + result=KernelResult(frame=frame), + population=Population.from_frame(frame, node.id), + receipt={"rows": frame.n("person")}, + opaque_artifacts={"diagnostic": b"created"}, + verify_existing=True, + ) + + +def test_a_direct_write_returns_and_stores_what_the_reference_does( + tmp_path: Path, +) -> None: + frame = _every_dtype_frame() + live_store = ContentStore(tmp_path / "live") + reference_store = ContentStore(tmp_path / "reference") + + live_artifacts, live_record = _write(live_store, frame) + reference_artifacts, reference_record = _write( + reference_store, frame, reference=True + ) + + assert list(live_artifacts.items()) == list(reference_artifacts.items()) + assert live_record == reference_record + assert _object_bytes(live_store) == _object_bytes(reference_store) + coordinates = [ + (entry["entity"], entry["column"]) for entry in _column_entries(live_record) + ] + assert coordinates == list(live_artifacts) == sorted(_all_coordinates(frame)) + assert frame.entities == ("person", "household", "benunit") + assert coordinates[0] == ("benunit", "aa") + # Each column reads back with its entity's ids, in table order. + for (entity, column), output_key in live_artifacts.items(): + table = frame.table(entity) + id_column = frame.schema.entity_id_column(entity) + loaded = live_store.load_column(output_key) + assert loaded.index.name == id_column + assert loaded.index.tolist() == table[id_column].tolist() + pd.testing.assert_series_equal( + loaded, table[column], check_index=False, check_names=False + ) + + +def test_an_unsupported_dtype_is_refused_before_anything_is_written( + tmp_path: Path, +) -> None: + """``person_benunit_id`` sorts after every benunit and household column. + + A write that took each column's dtype token only as it reached it would + store those first. + """ + + frame = _every_dtype_frame(benunit_membership="int8") + for name, reference in (("live", False), ("reference", True)): + store = ContentStore(tmp_path / name) + with pytest.raises(NodeRejected, match="unsupported dtype int8"): + _write(store, frame, reference=reference) + assert _object_bytes(store) == {} + + +# -------------------------------------------------------------------------- +# What the write holds. +# -------------------------------------------------------------------------- + + +def test_each_copy_goes_before_the_next_and_each_entity_shares_one_id_index( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + """Weak references to every column copy the write makes. + + The write holds no copy it has stored once it makes the next one. Each + entity's columns are indexed by the first id index the write made for + that entity. That index is held here, so an index rebuilt for a later + column could not reuse its memory and pass for it. + """ + + frame = _every_dtype_frame() + copies: list[weakref.ref[pd.Series]] = [] + alive: list[int] = [] + first_ids: dict[str, pd.Index] = {} + copy = graph_executor._series_for_column + + def watched(table: pd.DataFrame, column: str, ids: pd.Index) -> pd.Series: + alive.append(sum(earlier() is not None for earlier in copies)) + series = copy(table, column, ids) + copies.append(weakref.ref(series)) + assert ids is first_ids.setdefault(str(ids.name), ids) + assert series.index is ids + return series + + monkeypatch.setattr(graph_executor, "_series_for_column", watched) + with _without_collection(): + _write(ContentStore(tmp_path / "store"), frame) + dead = [earlier() is None for earlier in copies] + + assert len(copies) == len(_all_coordinates(frame)) + assert alive == [0] * len(copies) + assert all(dead) + assert set(first_ids) == {"benunit_id", "household_id", "person_id"} + + +def _wide_frame(*, households: int, people_each: int, columns: int) -> Frame: + """A frame of float columns, wide enough for the write's copies to show.""" + + generator = np.random.default_rng(20261107) + people = households * people_each + person = pd.DataFrame( + { + "person_id": np.arange(people, dtype=np.int64), + "person_household_id": np.repeat( + np.arange(households, dtype=np.int64), people_each + ), + **{ + f"x{index:02d}": generator.normal(size=people) + for index in range(columns) + }, + } + ) + household = pd.DataFrame( + { + "household_id": np.arange(households, dtype=np.int64), + **{ + f"h{index:02d}": generator.normal(size=households) + for index in range(columns) + }, + } + ) + return Frame( + {"person": person, "household": household}, + EntitySchema(group_entities=("household",)), + {"household": Weights(np.ones(households), WeightKind.DESIGN)}, + ) + + +def _column_bytes(frame: Frame) -> int: + return sum( + frame.table(entity)[column].to_numpy().nbytes + for entity, column in _all_coordinates(frame) + ) + + +def _traced_peak(action: Callable[[], object]) -> int: + """Bytes traced at the action's peak, above what was held when it began.""" + + tracing = tracemalloc.is_tracing() + if not tracing: + tracemalloc.start() + try: + tracemalloc.reset_peak() + before = tracemalloc.get_traced_memory()[0] + action() + return tracemalloc.get_traced_memory()[1] - before + finally: + if not tracing: + tracemalloc.stop() + + +def test_a_structural_write_holds_one_column_at_a_time_not_a_second_frame( + tmp_path: Path, +) -> None: + """Small sizes: 20,000 people and 5,000 households, 48 float columns each. + + The reference holds a copy of every column and one id array per column, + about twice the frame's column bytes. The streamed write holds one column + copy and one id array at a time, beside what the frame write itself + needs. + """ + + frame = _wide_frame(households=5_000, people_each=4, columns=48) + column_bytes = _column_bytes(frame) + + reference = _traced_peak( + lambda: _write(ContentStore(tmp_path / "reference"), frame, reference=True) + ) + live = _traced_peak(lambda: _write(ContentStore(tmp_path / "live"), frame)) + + assert reference > 2 * column_bytes + assert reference - live > column_bytes + assert live < column_bytes / 2 + + +# -------------------------------------------------------------------------- +# What a cache hit holds. +# -------------------------------------------------------------------------- + + +def test_a_structural_hit_loads_every_column_in_order_and_keeps_none( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + """Weak references to every column a structural hit loads. + + The hit loads each column its record lists, in the record's order, and + then the frame. It holds no column once it loads the next one, or the + frame, and it returns only the frame and the record's artifacts. + """ + + frame = _every_dtype_frame() + store = ContentStore(tmp_path / "store") + artifacts, record = _write(store, frame) + loads: list[str] = [] + loaded: list[weakref.ref[pd.Series]] = [] + alive: list[int] = [] + load_column = store.load_column + load_frame = store.load_frame + + def watched_column(key: str) -> pd.Series: + alive.append(sum(earlier() is not None for earlier in loaded)) + loads.append(key) + series = load_column(key) + loaded.append(weakref.ref(series)) + return series + + def watched_frame(key: str) -> Frame: + alive.append(sum(earlier() is not None for earlier in loaded)) + loads.append(key) + return load_frame(key) + + monkeypatch.setattr(store, "load_column", watched_column) + monkeypatch.setattr(store, "load_frame", watched_frame) + with _without_collection(): + result, hit_artifacts = graph_executor._load_cached_result( + store, _create_node(frame), None, record + ) + dead = [earlier() is None for earlier in loaded] + + entries = _column_entries(record) + assert loads == [*(entry["key"] for entry in entries), record["frame_key"]] + assert len(loaded) == len(_all_coordinates(frame)) + assert alive == [0] * len(loads) + assert all(dead) + assert dict(result.columns) == {} + assert list(hit_artifacts.items()) == list(artifacts.items()) + assert result.frame is not None + for entity in frame.entities: + pd.testing.assert_frame_equal(result.frame.table(entity), frame.table(entity)) + + +def test_a_structural_hit_still_refuses_a_damaged_or_repeated_column( + tmp_path: Path, +) -> None: + """The hit keeps no structural column, but it still checks every one. + + The frame is stored whole and stays intact, so only the column's own + check can refuse the hit. + """ + + frame = _every_dtype_frame() + node = _create_node(frame) + store = ContentStore(tmp_path / "store") + artifacts, record = _write(store, frame) + entries = _column_entries(record) + + repeated = {**record, "columns": [*entries, entries[0]]} + with pytest.raises(StoreCorrupt, match=r"repeats column benunit\.aa"): + graph_executor._load_cached_result(store, node, None, repeated) + + payload = store.object_path(artifacts[("person", "zeta")]) / "values.npy" + damaged = bytearray(payload.read_bytes()) + damaged[-1] ^= 1 + payload.write_bytes(damaged) + failed = f"{payload.parent.name}: payload 'values.npy' failed" + with pytest.raises(StoreCorrupt, match=re.escape(failed)): + graph_executor._load_cached_result(store, node, None, record) + # The frame still loads, so the refusal is the damaged column's. + store.load_frame(str(record["frame_key"])) + + +def test_a_structural_hit_holds_no_column_beside_its_frame(tmp_path: Path) -> None: + """Small sizes: the write test's frame, 10 MB of float columns. + + A hit that kept each column it loaded, each with its own ids, would hold + about twice the frame's column bytes while it loads the frame. This one's + peak is its frame load's, give or take one column. + """ + + frame = _wide_frame(households=5_000, people_each=4, columns=48) + column_bytes = _column_bytes(frame) + store = ContentStore(tmp_path / "store") + _, record = _write(store, frame) + node = _create_node(frame) + + frame_load = _traced_peak(lambda: store.load_frame(str(record["frame_key"]))) + hit = _traced_peak( + lambda: graph_executor._load_cached_result(store, node, None, record) + ) + + assert hit - frame_load < column_bytes / 2 From 55ef3246051748329cfc02f186f94380ff19f5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Sat, 7 Nov 2026 03:54:20 +0000 Subject: [PATCH 16/20] Free what each graph node no longer needs, and record amendment 30 (#931) Review follow-ups to keeping only the versions a caller reads. A version left the run only once its last reader had finished, and the executor's own locals kept the dead base and the node's copies alive until the next node rebound them. - A version now leaves once its last reader has applied its result, before that node is observed or written. An unreached last reader still drops it at its turn. - The executor lets go of what a node no longer needs: the incumbent once the node's result is admitted, the context and decoded artifacts once the kernel has run, and the node's population, result and opaque payloads once its receipt is built. A structural node's dead base is gone before its own frame is written, and nothing a node held is left for the run-end source pass. - The dense build drops the numerical manifest before the export run, and the national build drops its loaded checkpoint before the targets run. The size-checkpoint pool name lives in one constant read by both helpers. - Charter amendment 30 records retain_populations (main took 29 for a kernel's changed identity while this branch was open). The graph explorer notes that a retaining run attaches only the versions it names. No output moves. The graph tests run a FILTER chain and the toy country's REWEIGHT, gate, release and entrant EXPAND graphs cold, warm and under resume="require", with and without the keyword. The store objects are byte-identical and the manifests agree on every portable field. With the cyclic collector off, weak references show each dead version freed by its last reader before that reader writes. That holds for a version read by two members and three boundaries, for one nothing reads, and for one whose last reader is unreached. No kernel source hash binds an edited module, so no node key moves. Co-Authored-By: Claude Opus 5.5 --- docs/graph-acceptance.md | 20 ++ docs/graph-explorer.md | 9 +- .../build/uk_runtime/full_build_cli.py | 39 ++- .../engine_free/uk/test_uk_full_build_cli.py | 67 ++++- .../engine_free/uk/test_uk_national_graph.py | 23 ++ .../src/microcosm/graph/executor.py | 41 ++- .../shared/test_graph_population_retention.py | 271 +++++++++++++++--- 7 files changed, 392 insertions(+), 78 deletions(-) diff --git a/docs/graph-acceptance.md b/docs/graph-acceptance.md index 06b4602431..3f3889ae5f 100644 --- a/docs/graph-acceptance.md +++ b/docs/graph-acceptance.md @@ -748,6 +748,26 @@ lock unchanged: independent review of #1125 (finding 1, Subfleet job 20261007-081708); adopted with the fix in #1140. +30. **A caller may name the versions it retains.** `run_graph(..., + retain_populations=...)` names the population versions the caller will + read from the manifest. `None`, the default, keeps every version to the + end of the run and attaches all of them, as before. Given a collection, + the executor drops each version it does not name once its last reader + has applied its result, before that reader is observed or written. A + last reader that is not reached drops it at its turn in the run order. + Ordinary members read a version as their incumbent and structural nodes + as their base; nothing else does, so a version nothing reads goes with + the node that made it. Only the named versions and their mass ledgers + are attached, and `RunManifest.population` refuses any other with the + error it gives a manifest restored from JSON. An unknown name, an + ordinary member's id, a name that is not a string, a bare `str` or + `bytes`, and anything that is not a collection are refused before any + source is read. Each node reads the same population with or without the + keyword, and it enters no node key, receipt, cache record or portable + manifest field. Runtime-only, the interface lock is unchanged. Adopted + 2026-11-06 for the 15-clone UK spine (#931), which cannot hold every + version it builds in 32 GiB. + Adding a normative field with a default changes the canonical projection of every node that carries it, so node keys moved with amendments 11 and 13's sibling field `entrants`; no released artifact pins a graph key yet. diff --git a/docs/graph-explorer.md b/docs/graph-explorer.md index 29730cda8e..b3b032276a 100644 --- a/docs/graph-explorer.md +++ b/docs/graph-explorer.md @@ -144,9 +144,12 @@ achieved value, residual, standard error, filter, or other field, the table says The shared-bin histogram compares both incoming and outgoing weights divided by the original design-weight anchor, aligned by entity id. For a just-executed run, -those arrays come from `manifest.populations`. For a saved run, the CLI reloads -the structural frames identified by `NodeReceipt.frame_key`. A receipt-provided -before/after ratio sample would take precedence if the runtime adds one later. +those arrays come from `manifest.populations`. A run that names the versions it +retains (`retain_populations`, charter amendment 30) attaches only those, so its +histogram for any other version says the samples are not recorded. For a saved +run, the CLI reloads the structural frames identified by `NodeReceipt.frame_key`. +A receipt-provided before/after ratio sample would take precedence if the +runtime adds one later. Mass totals and strata come first from `receipt.mass`, then from the attached executor `MassRecord`, and finally from the validated before/after structural diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/full_build_cli.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/full_build_cli.py index 53143b2aa0..5e32ba43ff 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/full_build_cli.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/full_build_cli.py @@ -2321,8 +2321,14 @@ def _close_staging( ) +#: The size search, and the pool version it reads. The size checkpoint is +#: materialized from both, so the numerical phase keeps that pool for it. +_SIZE_SEARCH = "uk.full.size_search" +_SIZE_SEARCH_POOL = "uk.full.pool" + + def _writes_size_checkpoint(args: argparse.Namespace) -> bool: - """Whether the build writes the size checkpoint after the solve.""" + """Whether the build may write the size checkpoint after the solve.""" return ( args.dataset_households is not None and not args.no_size_checkpoint @@ -2333,13 +2339,14 @@ def _writes_size_checkpoint(args: argparse.Namespace) -> bool: def _size_checkpoint_populations( args: argparse.Namespace, compiled: CompiledGraph ) -> tuple[str, ...]: - """The versions :func:`_materialize_size_checkpoint` reads from this run. + """The versions :func:`_materialize_size_checkpoint` may read from this run. - It reads the pool, and only when the build writes the checkpoint and the - graph runs the size search. + It may read the pool, and only when the build may write the checkpoint and + the graph runs the size search. A full-pool search writes none, and then + the pool is kept for nothing. """ - if _writes_size_checkpoint(args) and "uk.full.size_search" in compiled.order: - return ("uk.full.pool",) + if _writes_size_checkpoint(args) and _SIZE_SEARCH in compiled.order: + return (_SIZE_SEARCH_POOL,) return () @@ -2363,14 +2370,12 @@ def _materialize_size_checkpoint( from .dataset_size import UKSizeSelection from .size_checkpoint import write_uk_size_checkpoint - if "uk.full.size_search" not in manifest.nodes: + if _SIZE_SEARCH not in manifest.nodes: return None - selection_meta = json.loads( - _payload(manifest, store, "uk.full.size_search", "selection") - ) + selection_meta = json.loads(_payload(manifest, store, _SIZE_SEARCH, "selection")) if selection_meta.get("method") != "contribution_informed_l0": return None - pool = manifest.population("uk.full.pool") + pool = manifest.population(_SIZE_SEARCH_POOL) problem = decode_problem(_payload(manifest, store, "uk.full.problem", "problem")) initial = Frame( {entity: pool.table(entity) for entity in pool.entities}, @@ -2386,7 +2391,7 @@ def _materialize_size_checkpoint( problem=problem, ) search = decode_calibration_result( - _payload(manifest, store, "uk.full.size_search", "result"), + _payload(manifest, store, _SIZE_SEARCH, "result"), frame=initial, problem=problem, ) @@ -2408,9 +2413,7 @@ def _materialize_size_checkpoint( provenance={ "graph_artifacts": { "dense": manifest.nodes["uk.full.dense"].opaque_artifacts["result"], - "search": manifest.nodes["uk.full.size_search"].opaque_artifacts[ - "result" - ], + "search": manifest.nodes[_SIZE_SEARCH].opaque_artifacts["result"], } }, ) @@ -2614,6 +2617,9 @@ def _execute_full_build( ) if receipt is not None and state is not None: append_phase(state, "size_selection_checkpointed") + # The numerical manifest can hold the pool, and nothing reads it again. + # It goes now, so the pool is not resident through the export run. + del manifest _, enforcement = decode_full_gate_report(gate_report_bytes) gate_document = json.loads(gate_report_bytes) # The signed local battery report, written before any refusal so a @@ -3210,6 +3216,9 @@ def _execute_national_build( for entity in spine_frame.entities }, ) + # Nothing reads the loaded checkpoint again: each later run loads its own. + # It goes now, so the targets run and the solve do not hold a second spine. + del spine_frame, checkpoint # 2. The register: compiled inside the graph, frozen beside the outputs. stage(telemetry, "target_compilation", "started") targets = _run_graph_with_progress( diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_full_build_cli.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_full_build_cli.py index 0d5e8ae379..bea44698d3 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_full_build_cli.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_full_build_cli.py @@ -2,9 +2,11 @@ # ruff: noqa: F403, F405 import base64 +import gc import os import shutil import signal +import weakref from types import SimpleNamespace import test_support.microcosm_build.uk_full_build_cli as support # noqa: E402 @@ -509,31 +511,43 @@ def test_each_graph_phase_keeps_only_the_versions_it_reads( A graph run frees every version its caller does not name (#931). A sized request writes the size checkpoint, but this graph runs no size search, so - the numerical phase keeps no pool. + the numerical phase keeps no pool. The build drops the numerical manifest, + which can hold the pool, before the export run starts. """ pytest.importorskip("tables") extra = ("--dataset-households", "2") if sized else () args = arguments(tmp_path, *extra) build = prepared(tmp_path, size_households=2 if sized else None) runs = [] + manifests = [] run_graph = cli.run_graph def recorded(compiled, **kwargs): + alive = [manifest() is not None for manifest in manifests] manifest = run_graph(compiled, **kwargs) - runs.append((kwargs["retain_populations"], set(manifest.populations))) + runs.append((kwargs["retain_populations"], set(manifest.populations), alive)) + manifests.append(weakref.ref(manifest)) return manifest monkeypatch.setattr(cli, "run_graph", recorded) - assert cli.execute_full_build(build, args) == 0 + # Reference counting alone must free the manifest; no collection may help. + gc.disable() + try: + assert cli.execute_full_build(build, args) == 0 + finally: + gc.enable() assert cli._writes_size_checkpoint(args) is sized # The preflight, the numerical phase, the export and the certification run. - assert [retained for retained, _ in runs] == [ + assert [retained for retained, _, _ in runs] == [ (), (), (build.full.population,), (), ] - assert all(set(retained) == attached for retained, attached in runs) + assert all(set(retained) == attached for retained, attached, _ in runs) + # The export run, the third, starts with the second run's manifest gone. + _, _, alive_at_export = runs[2] + assert alive_at_export[1] is False @pytest.mark.parametrize( @@ -557,6 +571,49 @@ def test_the_numerical_phase_keeps_the_pool_only_for_the_size_checkpoint( assert cli._size_checkpoint_populations(args, compiled) == kept +def test_the_kept_pool_is_the_version_the_declared_size_search_reads(tmp_path): + """The name the numerical phase keeps is a version of that phase's graph. + + ``run_graph`` refuses a name that is not, but only when the numerical + phase starts, after the preflight. So the real dense declarations are + checked here: the size search reads the pool the checkpoint is built from. + """ + from microcosm.build.country_spec import load_country_spec + from microcosm.build.uk_runtime.graph import uk_spine_endpoint, uk_spine_graph + from microcosm.build.uk_runtime.graph_build import UKFullBuildConfig, uk_full_graph + from microcosm.build.uk_runtime.graph_calibration import UKGraphCalibrationConfig + from microcosm.build.uk_runtime.graph_evidence import add_uk_spine_gate_nodes + from microcosm.build.uk_runtime.graph_terminal import append_uk_full_gate_nodes + from microcosm.graph import compile_graph + + spine = add_uk_spine_gate_nodes( + uk_spine_graph(source_mode="split"), + spec=load_country_spec("uk"), + engine_identity="declaration-only", + ) + full = uk_full_graph( + UKFullBuildConfig( + calibration_year=2025, + geography_assignment="legacy", + calibration=UKGraphCalibrationConfig(dataset_households=100), + ), + spine=spine, + ) + graph = append_uk_full_gate_nodes( + full.graph, + calibration=full.calibration, + spine_stage_names=uk_spine_endpoint(spine).stage_names, + engine_identity="declaration-only", + review_date="2026-10-08", + ) + numerical = compile_graph(cli._through(graph, "uk.full.gates.calibrated")) + kept = cli._size_checkpoint_populations( + arguments(tmp_path, "--dataset-households", "100"), numerical + ) + assert kept == (numerical.versions[cli._SIZE_SEARCH],) + assert set(kept) <= set(numerical.versions.values()) + + def test_the_dense_gate_replay_signs_a_bound_attempt_the_contract_accepts( tmp_path, monkeypatch ): diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_national_graph.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_national_graph.py index 97e97b1b5e..b3985440d3 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_national_graph.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_national_graph.py @@ -303,6 +303,29 @@ def test_national_graph_composes_the_bound_checkpoint_line(): assert national.population == "uk.full.calibrated" +def test_each_version_the_national_build_keeps_is_a_version_of_its_phase(): + """The national build's input and gates phases keep versions they run. + + ``run_graph`` refuses any other name, but only when that phase starts. The + input phase keeps the bound checkpoint, and the gates phase the calibrated + population the H5 is written from. + """ + from microcosm.build.uk_runtime.full_build_cli import _through + + national = uk_national_graph( + _config(), + spine=bound_spine_graph(seam._frame()), + spine_population="uk.full.spine_checkpoint", + review_date=REVIEW_DATE, + ) + for endpoint, kept in ( + ("uk.full.spine_checkpoint", "uk.full.spine_checkpoint"), + (NATIONAL_GATES_NODE, national.population), + ): + compiled = compile_graph(_through(national.graph, endpoint)) + assert kept in set(compiled.versions.values()) + + def test_national_graph_refuses_a_population_without_bound_provenance(): frame = seam._frame() spine = bound_spine_graph(frame) diff --git a/packages/microcosm-graph/src/microcosm/graph/executor.py b/packages/microcosm-graph/src/microcosm/graph/executor.py index 0c2986a4de..e61726396c 100644 --- a/packages/microcosm-graph/src/microcosm/graph/executor.py +++ b/packages/microcosm-graph/src/microcosm/graph/executor.py @@ -2575,8 +2575,9 @@ def _population_releases( The node that creates a version writes it. Each ordinary member reads the version as its incumbent and writes its successor, and each structural node built on it reads it as its base. Nothing else in a run reads a - version, so once the last of these nodes has run the executor holds the - version only for the manifest. A version that is not retained can go then. + version, so once the last of these nodes has applied its result the + executor holds the version only for the manifest. A version that is not + retained can go then. """ last: dict[str, str] = {} @@ -2711,11 +2712,13 @@ def run_graph( from the manifest. The default, ``None``, keeps every version until the run ends and attaches all of them. Given a collection, the run drops each version it does not name once the last node that reads that version has - run, so its frame can be freed, and attaches only the named versions and - their mass ledgers. A version is read by its ordinary members and by every - structural node built on it. A name that is not a version of the graph is - refused before any work. Each node reads the same population with or - without the keyword, and it enters no key, no receipt and no cache record. + applied its result, before that node is observed or written, so its frame + can be freed. It attaches only the named versions and their mass ledgers. + A version is read by its ordinary members and by every structural node + built on it, and its last reader frees it even when that reader is not + reached. A name that is not a version of the graph is refused before any + work. Each node reads the same population with or without the keyword, + and it enters no key, no receipt and no cache record. The private population observer exposes a detached snapshot of each node's admitted population, design anchors included, to an integrating verifier. @@ -2848,8 +2851,9 @@ def _execute_graph( _preflight_require(compiled, store, keys, implementations, kernels) # Node id to the versions it is the last to use. Each leaves - # ``populations`` once that node has run, so its frame can be freed. - # Without ``retain_populations`` none leaves, and the manifest attaches all. + # ``populations`` once that node has applied its result, so its frame can + # be freed. Without ``retain_populations`` none leaves, and the manifest + # attaches all. releases = {} if retained is None else _population_releases(compiled, retained) populations: dict[str, Population] = {} # Each structural version's ``Frame`` mass log as that version was @@ -3052,6 +3056,10 @@ def _execute_graph( after = _context_digest(context) if before != after: raise NodeRejected(f"Node {node.id!r} mutated its input context.") + # The context copies every column this node projected, and its + # artifacts are decoded payloads. Nothing below reads either, so + # they go now, not when the next cold node replaces them. + del context, artifact_values for name in node.sources: # A stat signature that still matches the one taken across this # source's own read reuses that read's key; a rewrite that moves @@ -3182,6 +3190,14 @@ def _execute_graph( # Captured at admission, so cold execution and a restored cache # hit record the same boundary: both reach this line. boundary_mass_logs[node.id] = updated.frame.mass_log + # Nothing else in this iteration reads the incumbent or + # ``populations``: the observer and the write take ``updated``. So the + # incumbent, and each version this node is the last to use, go before + # them. A structural node's base is then freed before its own frame + # is written. + incumbent = None + for version in releases.get(node_id, ()): + del populations[version] if _population_observer is not None: _population_observer( @@ -3240,8 +3256,11 @@ def _execute_graph( opaque_artifacts=MappingProxyType(receipt_opaque), ) receipt_payloads[node_id] = receipts[node_id].receipt - for version in releases.get(node_id, ()): - del populations[version] + # A version this node made and released lives on only in ``updated``, + # and a restored frame or an opaque payload in ``result`` and + # ``opaque``. They go here, so neither a later node nor the run-end + # pass holds them. + del updated, result, opaque # Every source is re-derived in full, cache bypassed, before any caller # receives a manifest. This closes the two cases a stat signature cannot diff --git a/packages/microcosm-graph/tests/engine_free/shared/test_graph_population_retention.py b/packages/microcosm-graph/tests/engine_free/shared/test_graph_population_retention.py index 10854327d5..f317793c7e 100644 --- a/packages/microcosm-graph/tests/engine_free/shared/test_graph_population_retention.py +++ b/packages/microcosm-graph/tests/engine_free/shared/test_graph_population_retention.py @@ -4,34 +4,43 @@ versions it will read from the manifest. The default, ``None``, keeps every version to the end of the run and attaches all of them, as before. Given a collection, each version it does not name leaves the executor once the last -node that reads it has run, so its frame can be freed. These tests pin that -contract: +node that reads it has applied its result, so its frame can be freed. These +tests pin that contract: - the store, the node keys, the receipts and the portable manifest are the - same with and without the keyword, cold, warm and under ``resume="require"``; + same with and without the keyword, cold, warm and under ``resume="require"``, + over CREATE, FILTER, EXPAND and REWEIGHT versions, a gate and a release; - only the named versions, and their mass ledgers, are attached; -- a dead version's tables are released after its last reader, and not before; +- a dead version's tables are freed by its last reader, before that reader is + observed or writes its own frame, and nothing a node held outlives it into + the run-end pass; - a version read by several members and several structural nodes is kept - until the last of them has run; + until the last of them has run, and a version nothing reads goes with the + node that made it; - an unreached last reader still releases its version; - a name that is not a version of the graph is refused before the run reads a source, runs a kernel or writes to the store. -Synthetic toy graph only: no data file, no country package, no engine. +Synthetic graphs only: the small graphs below and the toy country's fixture +tables. No data file, no country package, no engine. """ from __future__ import annotations +import gc import hashlib +import importlib.util import json +import sys import weakref -from collections.abc import Collection +from collections.abc import Callable, Collection, Iterator from pathlib import Path import numpy as np import pandas as pd import pytest +import microcosm.graph.executor as graph_executor from microcosm.frame import EntitySchema, Frame, WeightKind, Weights from microcosm.graph.decl import ( ArtifactInput, @@ -57,6 +66,18 @@ from microcosm.graph.manifest import NodeReceipt, PopulationView, RunManifest from microcosm.graph.population import Population from microcosm.graph.store import ContentStore +from test_support.paths import paths_for + +_TEST_PATHS = paths_for("microcosm-graph") + +if "_toy" not in sys.modules: + _SPEC = importlib.util.spec_from_file_location( + "_toy", _TEST_PATHS.tests / "_toy.py" + ) + assert _SPEC is not None and _SPEC.loader is not None + sys.modules["_toy"] = importlib.util.module_from_spec(_SPEC) + _SPEC.loader.exec_module(sys.modules["_toy"]) +toy = sys.modules["_toy"] SOURCE = SourceRef("survey", "csv-tables") EVIDENCE = ArtifactType("gate.evidence", 1) @@ -228,11 +249,12 @@ def _chain() -> Graph: def _shared_base() -> Graph: - """``survey`` read by two members and by two structural nodes. + """``survey`` read by two members and by three structural nodes. - ``first`` and ``second`` both build on ``survey`` at one depth, so - ``second`` is the last of its four readers. The run order is survey, a, b, - first, second, c, d. + ``first``, ``leaf`` and ``second`` all build on ``survey`` at one depth, so + ``second`` is the last of its five readers. Nothing reads ``leaf``'s own + version, so ``leaf`` is the last to use it. The run order is survey, a, b, + first, leaf, second, c, d. """ return Graph( @@ -244,6 +266,7 @@ def _shared_base() -> Graph: _member("b", "survey", "age"), _boundary("first", "survey", "a"), _boundary("second", "survey", "selected", keep_selected=True), + _boundary("leaf", "survey", "age"), _member("c", "first", "a"), _member("d", "second", "b"), ), @@ -288,20 +311,41 @@ def _unreached_reader() -> Graph: ) +def _toy_expand() -> Graph: + """The toy country's entrant EXPAND on ``survey``, and the claim of its cells.""" + + return toy.small_graph(nodes=(toy.CREATE, *toy.entrant_expand_node())) + + +#: Each graph the neutrality test runs: how to build it, write its source and +#: register its kernels. The chain has CREATE and FILTER versions. The toy +#: country adds two REWEIGHT versions, a gate and a release, and its entrant +#: graph an EXPAND version. +_GRAPHS: dict[ + str, + tuple[Callable[[], Graph], Callable[[Path], Path], Callable[[], KernelRegistry]], +] = { + "chain": (_chain, _source_path, _registry), + "toy": (toy.full_graph, toy.copy_source, toy.toy_registry), + "toy-expand": (_toy_expand, toy.copy_source, toy.toy_registry), +} + + class _Liveness: """An observer that records which versions' tables are still alive. It holds only weak references, to the tables of the latest population - admitted in each version, so it never keeps a version alive itself. At each - node it first records which of the versions seen so far are alive. By then - the executor has made its releases for every earlier node, and the node - being admitted still holds its own incumbent. The executor must hand it the - live population (``_population_observer_detach=False``): a detached - snapshot is a copy that dies at once. - - It runs no garbage collection. A released version's tables die by - reference counting alone, so they are freed at once, not at some later - collection. + admitted in each version, so it never keeps a version alive itself. At + each node it first takes the population just admitted as its version's + latest, then records which of the versions seen so far are alive. By then + the executor has made that node's releases and dropped its incumbent, so a + version the node was the last to read is already dead. The executor must + hand it the live population (``_population_observer_detach=False``): a + detached snapshot is a copy that dies at once. + + It runs no garbage collection, and the tests that use it turn the cyclic + collector off (``no_cyclic_collector``). So a released version's tables + die by reference counting alone, at once, not at some later collection. """ def __init__(self) -> None: @@ -309,11 +353,11 @@ def __init__(self) -> None: self.alive: dict[str, dict[str, bool]] = {} def __call__(self, node_id: str, population: Population) -> None: - self.alive[node_id] = self.alive_now() self.tables[population.version] = { entity: weakref.ref(population.frame.table(entity)) for entity in population.frame.entities } + self.alive[node_id] = self.alive_now() def alive_now(self) -> dict[str, bool]: return { @@ -322,6 +366,25 @@ def alive_now(self) -> dict[str, bool]: } +@pytest.fixture +def no_cyclic_collector() -> Iterator[None]: + """Turn the cyclic garbage collector off for one test. + + A released version must be freed by reference counting alone. With the + collector on, a version kept alive only by a reference cycle could be + freed by an incidental collection, and a liveness test would pass for the + wrong reason. + """ + + enabled = gc.isenabled() + gc.disable() + try: + yield + finally: + if enabled: + gc.enable() + + def _run( graph: Graph, source: Path, @@ -389,9 +452,27 @@ def _assert_same_version(actual: PopulationView, expected: PopulationView) -> No @pytest.mark.parametrize( - "retain", - [("final",), ("survey", "final"), frozenset({"kept"}), ()], - ids=("final", "survey-and-final", "kept", "none"), + ("graph", "retain"), + [ + ("chain", ("final",)), + ("chain", ("survey", "final")), + ("chain", frozenset({"kept"})), + ("chain", ()), + ("toy", ("calibrated",)), + ("toy", ()), + ("toy-expand", ("survey",)), + ("toy-expand", ()), + ], + ids=( + "chain-final", + "chain-survey-and-final", + "chain-kept", + "chain-none", + "toy-calibrated", + "toy-none", + "toy-expand-survey", + "toy-expand-none", + ), ) @pytest.mark.parametrize( ("warm", "resume"), @@ -399,18 +480,26 @@ def _assert_same_version(actual: PopulationView, expected: PopulationView) -> No ids=("cold", "warm", "require"), ) def test_retention_moves_no_store_object_key_receipt_or_manifest_field( - tmp_path: Path, warm: bool, resume: str, retain: Collection[str] + tmp_path: Path, warm: bool, resume: str, graph: str, retain: Collection[str] ) -> None: """Two runs of one graph, with and without the keyword, into two stores.""" - source = _source_path(tmp_path / "source") + build, write_source, registry = _GRAPHS[graph] + source = write_source(tmp_path / "source") every_store = ContentStore(tmp_path / "every") named_store = ContentStore(tmp_path / "named") if warm: for store in (every_store, named_store): - _run(_chain(), source, store) - every = _run(_chain(), source, every_store, resume=resume) - named = _run(_chain(), source, named_store, resume=resume, retain=retain) + _run(build(), source, store, registry=registry()) + every = _run(build(), source, every_store, resume=resume, registry=registry()) + named = _run( + build(), + source, + named_store, + resume=resume, + retain=retain, + registry=registry(), + ) assert _object_bytes(named_store) == _object_bytes(every_store) assert all(receipt.hit is warm for receipt in named.nodes.values()) @@ -418,6 +507,7 @@ def test_retention_moves_no_store_object_key_receipt_or_manifest_field( assert _portable(named) == _portable(every) assert dict(named.source_identities) == dict(every.source_identities) assert dict(named.verification_epoch) == dict(every.verification_epoch) == {} + assert set(named.populations) == set(named.mass_ledgers) == set(retain) @pytest.mark.parametrize( @@ -452,15 +542,18 @@ def test_only_the_named_versions_and_their_mass_ledgers_are_attached( # -------------------------------------------------------------------------- +@pytest.mark.usefixtures("no_cyclic_collector") @pytest.mark.parametrize("warm", (False, True), ids=("cold", "warm")) -def test_a_dead_version_is_released_after_its_last_reader( +def test_a_dead_version_is_released_by_its_last_reader( tmp_path: Path, warm: bool ) -> None: - """On a structural chain each version goes once the next boundary has run. + """On a structural chain each version goes with the boundary built on it. ``survey`` is last read by ``kept`` and ``kept`` by ``final``. With - ``final`` retained, ``survey`` is gone by the time ``b`` is admitted and - ``kept`` by the time ``c`` is. The default run keeps both to the end. + ``final`` retained, ``survey`` is dead by the time ``kept`` is observed, + and ``kept`` by the time ``final`` is. Each was still there for its last + reader to read, or the run would have failed. The default run keeps both + to the end. """ source = _source_path(tmp_path / "source") @@ -477,10 +570,11 @@ def test_a_dead_version_is_released_after_its_last_reader( assert all(receipt.hit is warm for receipt in manifest.nodes.values()) assert list(named.alive) == list(compile_graph(_chain()).order) - assert named.alive["kept"] == {"survey": True} + assert named.alive["kept"] == {"survey": False, "kept": True} assert named.alive["b"] == {"survey": False, "kept": True} - assert named.alive["final"] == {"survey": False, "kept": True} + assert named.alive["final"] == {"survey": False, "kept": False, "final": True} assert named.alive["c"] == {"survey": False, "kept": False, "final": True} + assert every.alive["kept"] == {"survey": True, "kept": True} assert every.alive["c"] == {"survey": True, "kept": True, "final": True} assert named.alive_now() == {"survey": False, "kept": False, "final": True} # What is still alive is the attached version itself. @@ -489,14 +583,16 @@ def test_a_dead_version_is_released_after_its_last_reader( assert table() is attached.table(entity) +@pytest.mark.usefixtures("no_cyclic_collector") @pytest.mark.parametrize("warm", (False, True), ids=("cold", "warm")) def test_a_version_read_by_several_nodes_is_kept_until_the_last( tmp_path: Path, warm: bool ) -> None: - """Two members and two structural nodes read ``survey``; it waits for all four. + """Two members and three structural nodes read ``survey``; it waits for all. - Dropping it after a member or after ``first`` would leave ``second`` with - no base, and the run would fail. + Dropping it after a member, after ``first`` or after ``leaf`` would leave + ``second`` with no base, and the run would fail. Nothing reads ``leaf``'s + own version, so it goes with ``leaf``: it is dead by the next node. """ source = _source_path(tmp_path / "source") @@ -507,7 +603,7 @@ def test_a_version_read_by_several_nodes_is_kept_until_the_last( _run(_shared_base(), source, store) every = _Liveness() - _run(_shared_base(), source, every_store, observer=every) + every_manifest = _run(_shared_base(), source, every_store, observer=every) named = _Liveness() manifest = _run( _shared_base(), source, named_store, observer=named, retain=("first", "second") @@ -516,10 +612,21 @@ def test_a_version_read_by_several_nodes_is_kept_until_the_last( assert all(receipt.hit is warm for receipt in manifest.nodes.values()) assert list(named.alive) == list(compile_graph(_shared_base()).order) assert named.alive["first"]["survey"] is True - assert named.alive["second"]["survey"] is True - assert named.alive["c"]["survey"] is False - assert named.alive["d"] == {"survey": False, "first": True, "second": True} - assert every.alive["d"]["survey"] is True + assert named.alive["leaf"] == {"survey": True, "first": True, "leaf": True} + assert named.alive["second"] == { + "survey": False, + "first": True, + "leaf": False, + "second": True, + } + assert named.alive["d"] == named.alive["second"] + assert every.alive["d"] == { + "survey": True, + "first": True, + "leaf": True, + "second": True, + } + assert set(every_manifest.populations) == {"survey", "first", "leaf", "second"} assert set(manifest.populations) == {"first", "second"} assert manifest.population("second").table("person")["person_id"].tolist() == [ 1, @@ -527,6 +634,82 @@ def test_a_version_read_by_several_nodes_is_kept_until_the_last( ] +@pytest.mark.usefixtures("no_cyclic_collector") +@pytest.mark.parametrize( + ("retain", "alive"), [(None, True), (("final",), False)], ids=("every", "final") +) +def test_a_dead_base_is_freed_before_its_last_reader_writes( + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, + retain: Collection[str] | None, + alive: bool, +) -> None: + """``kept`` writes with ``survey`` already gone, and ``final`` with ``kept``. + + A structural write copies every column of the node's own frame. A base + still held there would add a whole version to that copy's peak. The + default run keeps both bases, so they are alive there. + """ + + liveness = _Liveness() + writes: dict[str, dict[str, bool]] = {} + write = graph_executor._write_node + + def observed(store, node, **kwargs): + writes[node.id] = liveness.alive_now() + return write(store, node, **kwargs) + + monkeypatch.setattr(graph_executor, "_write_node", observed) + source = _source_path(tmp_path / "source") + store = ContentStore(tmp_path / "store") + _run(_chain(), source, store, observer=liveness, retain=retain) + + assert list(writes) == list(compile_graph(_chain()).order) + assert writes["kept"] == {"survey": alive, "kept": True} + assert writes["final"] == {"survey": alive, "kept": alive, "final": True} + + +@pytest.mark.usefixtures("no_cyclic_collector") +@pytest.mark.parametrize( + ("graph", "retain", "alive"), + [ + (_chain, ("final",), {"survey": False, "kept": False, "final": True}), + (_chain, (), {"survey": False, "kept": False, "final": False}), + (_unreached_reader, (), {"survey": False}), + ], + ids=("chain-final", "chain-none", "unreached-none"), +) +def test_nothing_a_node_held_outlives_it_into_the_run_end_pass( + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, + graph: Callable[[], Graph], + retain: Collection[str], + alive: dict[str, bool], +) -> None: + """The run-end source pass finds only the versions the caller retains. + + That pass re-reads every source in full. ``final``'s last user is its + member ``c``, the last node to run. ``survey``'s, in the unreached graph, + is a boundary that never runs, after the gate that last admitted it. + Neither leaves its population behind for the pass. + """ + + liveness = _Liveness() + passes: list[dict[str, bool]] = [] + derive = graph_executor._SourceIdentities.derive + + def observed(self, name, path): + passes.append(liveness.alive_now()) + return derive(self, name, path) + + monkeypatch.setattr(graph_executor._SourceIdentities, "derive", observed) + source = _source_path(tmp_path / "source") + store = ContentStore(tmp_path / "store") + _run(graph(), source, store, observer=liveness, retain=retain) + + assert passes == [alive] + + @pytest.mark.parametrize( "retain", [(), ("boundary",)], ids=("none", "the-unreached-version") ) From e2e5afd425bbd26481ef394c36b077982ef0ee36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Sat, 7 Nov 2026 01:07:46 +0000 Subject: [PATCH 17/20] Read Scotland's band weights from Chronicle's NRS facts The conditioned-support tool now reads NRS's dwellings by council-tax band for each 2022 data zone at December 2024 from the pinned UK feed (record set nrs.dwellings_data_zone_2025.2024, PolicyEngine/chronicle#421) instead of parsing the registered workbook. It streams the feed and checks the whole file against the pin. It refuses a row of that record set that is not a zone's total or band, a zone without all nine, and bands that miss the total. The provenance records the feed read and a fingerprint of the counts, and the Scottish band columns' source names the record set and that fingerprint. The facts equal the workbook's bands in all 7,392 zones; they come from the same bytes (5d61db5f). So the Scottish support's arrays are unchanged, and only the eight band columns' source moves (a8ca096b, 1,607,718 bytes). England and Wales and Northern Ireland rebuild byte for byte, and every receipt is unchanged. The tool's Chronicle block names #421's merge, where the five raw-only registrations pin the same bytes. The facts are streamed rather than vendored: their 66,528 rows would make a resource of over 80 MB. As for the high-value home stock, a feed-gated test checks on each re-pin that the feed still carries the facts the supports were built from, and the re-pin runbook says to rebuild them if not. Co-Authored-By: Claude Opus 5.5 --- .../931-uk-conditioned-area-supports.added.md | 2 +- docs/geography-assignment.md | 8 +- docs/uk-chronicle-feed-repin.md | 13 + .../src/microcosm/build/uk/spec/sources.yaml | 4 +- ..._area_conditioned_supports.provenance.json | 57 ++-- .../uk/test_uk_conditioned_area_supports.py | 83 +++++- .../test_uk_conditioned_area_supports_tool.py | 118 ++++++-- tools/build_uk_conditioned_area_supports.py | 277 +++++++++++++----- 8 files changed, 427 insertions(+), 135 deletions(-) diff --git a/changelog.d/931-uk-conditioned-area-supports.added.md b/changelog.d/931-uk-conditioned-area-supports.added.md index 45f011c5ca..b8fb17b0aa 100644 --- a/changelog.d/931-uk-conditioned-area-supports.added.md +++ b/changelog.d/931-uk-conditioned-area-supports.added.md @@ -8,7 +8,7 @@ Each conditioned support extends its system's registered support byte for byte, - Scotland takes bands A to H from its 2022 data zone's dwellings by band in NRS's December 2024 estimates, rounded half to even; its output areas nest in those zones. - Northern Ireland is unbanded. -`tools/build_uk_conditioned_area_supports.py` builds them from publisher files pinned by sha256: chronicle#412's raw-only registrations (PR chronicle#413), and NRS's dwellings by 2022 data zone, which Chronicle registers with only their total as facts (chronicle#419 asks for the bands). `uk/uk_atomic_area_conditioned_supports.provenance.json` records every input, the decile rule counts, the rounding and a precomputed table of zero-mass draw cells. +`tools/build_uk_conditioned_area_supports.py` builds them from chronicle#412's raw-only registrations (PR chronicle#413), pinned by sha256, and from NRS's dwellings by band and 2022 data zone, which it reads from the pinned UK Chronicle feed (chronicle#421). `uk/uk_atomic_area_conditioned_supports.provenance.json` records every input, the fingerprint of the NRS facts, the decile rule counts, the rounding and a precomputed table of zero-mass draw cells. A feed-gated test checks that the pinned feed still carries the facts the supports were built from. `sources.yaml` declares the supports under the new role `uk_atomic_area_conditioned_support`, with five new geography vintages. `spine.yaml` declares the FRS channel's `observed_constraints: [imd_decile]`, an optional field the shared spine schema now admits. `validate_uk_country_source_projection` refuses a spec in which the supports, their conditioned forms and that declaration disagree. diff --git a/docs/geography-assignment.md b/docs/geography-assignment.md index 59e482e198..3d68d8198b 100644 --- a/docs/geography-assignment.md +++ b/docs/geography-assignment.md @@ -201,8 +201,9 @@ Each support also has a conditioned form for the geography-first draw the support it extends, and recorded in `uk/uk_atomic_area_conditioned_supports.provenance.json`; `tools/build_uk_conditioned_area_supports.py` builds it from the registered -support's bytes, chronicle#412's raw-only registrations and NRS's dwellings by -2022 data zone. It adds two kinds of column: +support's bytes, chronicle#412's raw-only registrations and, from the pinned UK +Chronicle feed, NRS's dwellings by band and 2022 data zone (chronicle#421). It +adds two kinds of column: - **`imd_decile`**, an exact-match constraint code. It is the area's deprivation decile within its own nation, at the 2019 vintage the FRS @@ -217,7 +218,8 @@ support's bytes, chronicle#412's raw-only registrations and NRS's dwellings by - England and Wales take bands A to I from the area's LSOA mix in VOA CTSOP1.1. Only Wales has band I. - Scotland takes bands A to H from its 2022 data zone's dwellings by band in - NRS's December 2024 estimates; its output areas nest in those zones. + NRS's December 2024 estimates, as Chronicle emits them; its output areas + nest in those zones. - Northern Ireland has domestic rates, so its support carries no bands. The provenance lists every zero-mass draw cell (FRS region by decile, and diff --git a/docs/uk-chronicle-feed-repin.md b/docs/uk-chronicle-feed-repin.md index 2a4b6adc49..ebb6954d9b 100644 --- a/docs/uk-chronicle-feed-repin.md +++ b/docs/uk-chronicle-feed-repin.md @@ -97,6 +97,19 @@ compares it with the fingerprint recorded there for the feed the provenance names. A stock rebuilt on a new feed records that feed's fingerprint beside it; the test reports it. +The conditioned atomic-area supports (microcosm#931) read feed facts too: the +Scottish support's band weights come from NRS's dwellings by council-tax band +and 2022 data zone at December 2024 (record set +`nrs.dwellings_data_zone_2025.2024`, chronicle#421). Their provenance +(`uk/uk_atomic_area_conditioned_supports.provenance.json`) names the feed they +were built from and fingerprints the counts read. The feed-gated +`test_the_pinned_feed_carries_the_band_facts_the_supports_were_built_from` +(`tests/engine_free/uk/test_uk_conditioned_area_supports.py`) reads those facts +on the new pin and compares them with the provenance. If they moved, rebuild +the supports with `tools/build_uk_conditioned_area_supports.py` and update +their digests in `sources.yaml`; if not, the supports and their provenance stay +as built. + The constituency domestic energy resource (`uk/desnz_constituency_energy_facts.json`, microcosm#1095) is built from feed facts too: DESNZ's authority and LSOA / data zone consumption and meter counts. Its loader refuses a resource built on diff --git a/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml b/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml index 980afffb6e..9e36d8ecba 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml +++ b/packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml @@ -204,8 +204,8 @@ sources: value: 2025_ctsop - id: uk_scotland_output_area_2022_conditioned_support role: uk_atomic_area_conditioned_support - sha256: 0c7d78263c5db96d8f6dce06ac22c8e45f5fc4272297a4d16e073c964e797fea - byte_size: 1607702 + sha256: a8ca096bb0eafef90f4149f7e2ec6be302483f5b4c21a02f9c085ab20b597384 + byte_size: 1607718 loader: kernel:load_uk_atomic_area_support vintages: - vintage:uk_oa_2022 diff --git a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json index eeea053cc3..6600092949 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json +++ b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json @@ -2,9 +2,23 @@ "band_weight_scale": 1000000, "built_on": "2026-11-05", "chronicle": { - "commit": "c51f40d2bdaa66315dd63f334ede5790a8891e27", + "commit": "80a3482905843d447f8811b500a56dbf3b5f47fa", "merged": true, - "pull_request": "PolicyEngine/chronicle#413" + "pull_request": "PolicyEngine/chronicle#421" + }, + "feed_facts": { + "nrs_dwellings_by_band": { + "data_zones": 7392, + "fingerprint_sha256": "e1917f2b191c0af847fefd346e99e6fe115292112a94e69fbede8c22543256fe", + "period": { + "type": "calendar_year", + "value": "2024" + }, + "record_set_id": "nrs.dwellings_data_zone_2025.2024", + "rows": 66528, + "source_file": "dwelling-estimates-by-2022-data-zones-24-25.xlsx", + "source_sha256": "5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033" + } }, "issues": { "chronicle_band_facts": "PolicyEngine/chronicle#419", @@ -12,12 +26,18 @@ "umbrella": "PolicyEngine/microcosm#931" }, "kind": "uk_atomic_area_conditioned_supports_provenance", + "ledger_feed": { + "fact_row_count": 2030062, + "facts_sha256": "cb3342c3f59ff961a0ae369ca489293ddd6d021fdeb5cfafb89f6d125329bdfe", + "manifest_sha256": "d2323e7bddb30043fafecc2249fca0ee1506dae8ff20bc5f4db8575dc2ec1b73", + "source_commit": "80a3482905843d447f8811b500a56dbf3b5f47fa" + }, "notes": [ "imd_decile is the 2019 vintage of each nation's index (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017): the FRS 2024-25 variables IMDE, IMDW, IMDS and IMDN carry no change note from 2023-24, which predates the 2025 indices, and on an internal comparison England's FRS decile shares by region fit IoD 2019 better than IoD 2025, as the 2023-24 FRS does. The vintage is still to be confirmed with DWP.", "An area's decile is the one most of its live small-user postcodes carry in the May 2026 NSPL (oa21cd: the 2021 output area in England and Wales, the 2022 output area in Scotland, the 2021 data zone in Northern Ireland). Ranks are within-nation only.", "Northern Ireland's SOAs (2001) do not nest in its 2021 data zones, so many data zones' postcodes span deciles; the modal decile is recorded with relation inferred_modal and the counts below.", "England and Wales band weights read each area's LSOA mix as committed (shares to 6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read its 2022 data zone's dwellings by band, rounded half to even per band.", - "Scotland's band mix is its 2022 data zone's, in which its 2022 output areas nest, from NRS's December 2024 sheet: nearest the FRS 2024-25 year and VOA's stock at 31 March 2025. NRS counts dwellings on the valuation list, as VOA does in England and Wales. Chronicle registers the workbook (nrs-dwellings-data-zone-2025) with only its total as facts; until chronicle#419 adds the band columns, this tool reads them from the registered bytes." + "Scotland's band mix is its 2022 data zone's, in which its 2022 output areas nest, at December 2024: nearest the FRS 2024-25 year and VOA's stock at 31 March 2025. NRS counts dwellings on the valuation list, as VOA does in England and Wales. Chronicle emits the zones' totals and bands A to H as facts (record set nrs.dwellings_data_zone_2025.2024, chronicle#421); this tool reads them from the pinned UK feed and records their fingerprint." ], "publisher_files": { "iod2019": { @@ -42,17 +62,6 @@ "size_bytes": 1772032, "url": "https://www.nisra.gov.uk/files/nisra/publications/NIMDM17_SOAresults.xls" }, - "nrs_dz_dwellings": { - "chronicle_package_id": "nrs-dwellings-data-zone-2025", - "chronicle_source_id": "nrs", - "chronicle_year": 2025, - "filename": "dwelling-estimates-by-2022-data-zones-24-25.xlsx", - "product": "Dwelling estimates by 2022 data zone, December 2024 and 2025", - "publisher": "NRS", - "sha256": "5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033", - "size_bytes": 1223284, - "url": "https://nrscotland.gov.uk/media/43tfx3zo/dwelling-estimates-by-2022-data-zones-24-25.xlsx" - }, "nspl": { "chronicle_package_id": "ons-nspl-may-2026", "chronicle_source_id": "ons", @@ -858,42 +867,42 @@ "households_band_a": { "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_a_share_round_half_even_x1e6", "kind": "weight", - "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" + "source": "chronicle:nrs.dwellings_data_zone_2025.2024@sha256:e1917f2b191c0af847fefd346e99e6fe115292112a94e69fbede8c22543256fe" }, "households_band_b": { "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_b_share_round_half_even_x1e6", "kind": "weight", - "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" + "source": "chronicle:nrs.dwellings_data_zone_2025.2024@sha256:e1917f2b191c0af847fefd346e99e6fe115292112a94e69fbede8c22543256fe" }, "households_band_c": { "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_c_share_round_half_even_x1e6", "kind": "weight", - "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" + "source": "chronicle:nrs.dwellings_data_zone_2025.2024@sha256:e1917f2b191c0af847fefd346e99e6fe115292112a94e69fbede8c22543256fe" }, "households_band_d": { "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_d_share_round_half_even_x1e6", "kind": "weight", - "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" + "source": "chronicle:nrs.dwellings_data_zone_2025.2024@sha256:e1917f2b191c0af847fefd346e99e6fe115292112a94e69fbede8c22543256fe" }, "households_band_e": { "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_e_share_round_half_even_x1e6", "kind": "weight", - "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" + "source": "chronicle:nrs.dwellings_data_zone_2025.2024@sha256:e1917f2b191c0af847fefd346e99e6fe115292112a94e69fbede8c22543256fe" }, "households_band_f": { "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_f_share_round_half_even_x1e6", "kind": "weight", - "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" + "source": "chronicle:nrs.dwellings_data_zone_2025.2024@sha256:e1917f2b191c0af847fefd346e99e6fe115292112a94e69fbede8c22543256fe" }, "households_band_g": { "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_g_share_round_half_even_x1e6", "kind": "weight", - "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" + "source": "chronicle:nrs.dwellings_data_zone_2025.2024@sha256:e1917f2b191c0af847fefd346e99e6fe115292112a94e69fbede8c22543256fe" }, "households_band_h": { "basis": "census_2022_occupied_households_postcode_index_cell_key_perturbed_x_nrs_dz2022_2024_band_h_share_round_half_even_x1e6", "kind": "weight", - "source": "nrs-dwellings-data-zone-2025@sha256:5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033#sheet-2024" + "source": "chronicle:nrs.dwellings_data_zone_2025.2024@sha256:e1917f2b191c0af847fefd346e99e6fe115292112a94e69fbede8c22543256fe" }, "imd_decile": { "kind": "code", @@ -928,8 +937,8 @@ "postcodes_without_rank": 0, "records": 156932 }, - "sha256": "0c7d78263c5db96d8f6dce06ac22c8e45f5fc4272297a4d16e073c964e797fea", - "size_bytes": 1607702, + "sha256": "a8ca096bb0eafef90f4149f7e2ec6be302483f5b4c21a02f9c085ab20b597384", + "size_bytes": 1607718, "zero_mass_cells": [ { "cells": [], diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py index 65acb38f5e..7ef052b78f 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports.py @@ -10,8 +10,11 @@ from __future__ import annotations import hashlib +import importlib.util import json +import os import re +from pathlib import Path import numpy as np import pandas as pd @@ -39,6 +42,7 @@ assemble_uk_conditioned_area_support, uk_conditioned_support_base, ) +from microcosm.build.uk_runtime.chronicle_feed import load_uk_chronicle_feed from microcosm.build.uk_runtime.country_adapter import uk_atomic_support_register from test_support.microcosm_build.uk_atomic_support_fixtures import toy_support_payloads from test_support.paths import paths_for @@ -214,13 +218,18 @@ def bundle(): return compile_spec(load_bundle("uk")) -def test_provenance_pins_chronicle_registrations_and_resources(provenance) -> None: - import importlib.util - +@pytest.fixture(scope="module") +def tool(): path = _REPOSITORY / "tools/build_uk_conditioned_area_supports.py" spec = importlib.util.spec_from_file_location("uk_conditioned_tool_pins", path) - tool = importlib.util.module_from_spec(spec) - spec.loader.exec_module(tool) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def test_provenance_pins_chronicle_registrations_and_resources( + provenance, tool +) -> None: assert provenance["kind"] == "uk_atomic_area_conditioned_supports_provenance" assert provenance["publisher_files"] == tool.SOURCES assert provenance["chronicle"] == tool.CHRONICLE @@ -228,6 +237,18 @@ def test_provenance_pins_chronicle_registrations_and_resources(provenance) -> No provenance["issues"]["chronicle_registration"] == "PolicyEngine/chronicle#412" ) assert provenance["band_weight_scale"] == BAND_WEIGHT_SCALE + assert set(provenance["ledger_feed"]) == { + "source_commit", + "facts_sha256", + "manifest_sha256", + "fact_row_count", + } + facts = provenance["feed_facts"]["nrs_dwellings_by_band"] + assert facts["record_set_id"] == tool.NRS_RECORD_SET + # Each zone's total and bands A to H. + assert facts["data_zones"] == tool.NRS_DATA_ZONES + assert facts["rows"] == 9 * tool.NRS_DATA_ZONES + assert _SHA.fullmatch(facts["fingerprint_sha256"]) for name, resource in provenance["resources"].items(): # A regenerated band mix must regenerate the conditioned supports. assert ( @@ -259,14 +280,16 @@ def test_column_metadata_names_every_input_and_its_vintage(provenance, system) - for column in BAND_WEIGHT_COLUMNS[system]: item = entry["column_metadata"][column] assert item["kind"] == "weight" and item["basis"].endswith("_x1e6") - publisher, _, resource = item["source"].partition("#") - package, _, publisher_digest = publisher.partition("@sha256:") if system == SCOT: - # Scotland reads one sheet of the registered NRS workbook itself. - assert package == "nrs-dwellings-data-zone-2025" - assert sha_by_package[package] == publisher_digest - assert resource == "sheet-2024" + # Scotland reads NRS's band facts from the pinned feed. + facts = provenance["feed_facts"]["nrs_dwellings_by_band"] + assert item["source"] == ( + f"chronicle:{facts['record_set_id']}" + f"@sha256:{facts['fingerprint_sha256']}" + ) continue + publisher, _, resource = item["source"].partition("#") + package, _, publisher_digest = publisher.partition("@sha256:") name, _, digest = resource.partition("@sha256:") assert resources[name]["sha256"] == digest assert ( @@ -278,6 +301,44 @@ def test_column_metadata_names_every_input_and_its_vintage(provenance, system) - ) +def test_the_pinned_feed_carries_the_band_facts_the_supports_were_built_from( + provenance, tool +) -> None: + """The re-pin procedure's check of Scotland's band facts. + + A re-pin whose feed carries NRS's December 2024 band facts unchanged + leaves the supports as built, and their provenance keeps naming the feed + they were built from; one that moves them needs the supports rebuilt + (docs/uk-chronicle-feed-repin.md). + """ + + configured = os.environ.get("CHRONICLE_UK_FACTS") + feed = ( + Path(configured) + if configured + else _REPOSITORY / ".codex-work/consumer_facts_uk.jsonl" + ) + if feed.is_dir(): + feed = feed / "consumer_facts.jsonl" + if not feed.is_file(): + pytest.skip("pinned UK Chronicle consumer feed is not present") + pin = load_uk_chronicle_feed() + facts = tool._read_feed( + feed, + markers=(tool.NRS_RECORD_SET.encode(),), + identity={ + "facts_sha256": pin.facts_sha256, + "fact_row_count": pin.fact_row_count, + }, + ) + _, receipt = tool._nrs_band_counts(facts) + assert receipt == provenance["feed_facts"]["nrs_dwellings_by_band"], ( + "NRS's band facts differ on the pinned feed from those the conditioned " + "supports were built from: rebuild them with " + "tools/build_uk_conditioned_area_supports.py (docs/uk-chronicle-feed-repin.md)." + ) + + def test_spec_declares_the_conditioned_bytes_and_their_vintages( provenance, bundle ) -> None: diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py index d6ea89a562..bde9944941 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_conditioned_area_supports_tool.py @@ -70,12 +70,13 @@ def _invented_inputs(bases: dict[str, bytes]): "publisher_sha256": "2" * 64, } } - return frame, deciles, voa, scot, resources + nrs = {"record_set_id": "invented.record_set", "fingerprint_sha256": "3" * 64} + return frame, deciles, voa, scot, resources, nrs def test_tool_conditions_each_registered_support(tool) -> None: bases = toy_support_payloads() - postcodes, deciles, voa, scot, resources = _invented_inputs(bases) + postcodes, deciles, voa, scot, resources, nrs = _invented_inputs(bases) payloads, entries = tool.condition_supports( bases, postcodes, @@ -83,6 +84,7 @@ def test_tool_conditions_each_registered_support(tool) -> None: voa_mix=voa, scotland_counts=scot, resources=resources, + nrs_facts=nrs, ) for system in SYSTEMS: assert uk_conditioned_support_base(payloads[system]) == bases[system] @@ -109,13 +111,15 @@ def test_tool_conditions_each_registered_support(tool) -> None: # A ninth in band A, rounded half to even. ninth = [round(int(h) * BAND_WEIGHT_SCALE / 9) for h in households] assert weights["households_band_a"].tolist() == ninth + source = entries[system]["column_metadata"]["households_band_a"]["source"] + assert source == f"chronicle:invented.record_set@sha256:{'3' * 64}" if system == NI: assert not weights and entries[system]["band_weights"] is None def test_tool_refuses_a_rank_outside_its_nation_index(tool) -> None: bases = toy_support_payloads() - postcodes, deciles, voa, scot, resources = _invented_inputs(bases) + postcodes, deciles, voa, scot, resources, nrs = _invented_inputs(bases) postcodes.loc[0, "imd20ind"] = "77" with pytest.raises(ValueError, match="not in the E index"): tool.condition_supports( @@ -125,6 +129,7 @@ def test_tool_refuses_a_rank_outside_its_nation_index(tool) -> None: voa_mix=voa, scotland_counts=scot, resources=resources, + nrs_facts=nrs, ) @@ -138,47 +143,104 @@ def test_rank_deciles_refuse_a_split_tie_and_a_short_index(tool, monkeypatch) -> tool._rank_deciles(pd.Series([1, 2]), pd.Series([1, 2]), nation="E") -def _nrs_workbook(tool, path, rows): - """NRS's layout: four title rows, the header on row 5, zones, then a footnote.""" - openpyxl = pytest.importorskip("openpyxl") - workbook = openpyxl.Workbook() - sheet = workbook.active - sheet.title = tool.NRS_SHEET - for _ in range(tool.NRS_HEADER_ROW): - sheet.append(["Dwelling estimates by 2022 Data Zone"]) - sheet.append( - [ - tool.NRS_ZONE_COLUMN, - "Data zone name", - tool.NRS_TOTAL_COLUMN, - *tool.NRS_BAND_COLUMNS.values(), - ] - ) +def _nrs_facts(tool, rows, *, record_set=None): + """Feed rows as Chronicle emits NRS's: each zone's total, then bands A to H.""" + facts = [] for zone, total, *bands in rows: - sheet.append([zone, f"{zone} name", total, *bands]) - sheet.append(["Source: Scottish Assessors' Portal data"]) - workbook.save(path) - return path + values = {tool.NRS_TOTAL_CONCEPT: total} + values.update(zip(tool.NRS_BAND_CONCEPTS, bands, strict=True)) + for concept, value in values.items(): + facts.append( + { + "observed_measure": {"source_concept": concept}, + "value": value, + "geography": { + "id": zone, + "level": "statistical_scope", + "vintage": "dz_2022", + }, + "period": {"type": "calendar_year", "value": 2024}, + "layout": {"record_set_id": record_set or tool.NRS_RECORD_SET}, + "source": {"source_file": "zones.xlsx", "source_sha256": "4" * 64}, + } + ) + return facts def test_nrs_band_counts_read_each_zone_and_refuse_a_broken_sum( - tool, tmp_path, monkeypatch + tool, monkeypatch ) -> None: monkeypatch.setattr(tool, "NRS_DATA_ZONES", 2) rows = [ ["S01013482", 9, 1, 2, 1, 1, 1, 1, 1, 1], ["S01013483", 8, 0, 0, 0, 0, 0, 0, 0, 8], ] - path = tmp_path / "zones.xlsx" - assert tool._nrs_band_counts(_nrs_workbook(tool, path, rows)) == { + # Rows of another record set, such as December 2025's, are not read. + other = _nrs_facts(tool, [["S01013482", 1, 1, 0, 0, 0, 0, 0, 0, 0]], record_set="x") + facts = _nrs_facts(tool, rows) + counts, receipt = tool._nrs_band_counts([*other, *facts]) + assert counts == { "S01013482": dict(zip("abcdefgh", (1, 2, 1, 1, 1, 1, 1, 1), strict=True)), "S01013483": {**dict.fromkeys("abcdefg", 0), "h": 8}, } + assert (receipt["rows"], receipt["data_zones"]) == (18, 2) + assert receipt["source_sha256"] == "4" * 64 + # The fingerprint is of the counts, whatever order the rows come in. + _, reordered = tool._nrs_band_counts(facts[::-1]) + assert reordered["fingerprint_sha256"] == receipt["fingerprint_sha256"] with pytest.raises(ValueError, match="expected 2"): - tool._nrs_band_counts(_nrs_workbook(tool, path, rows[:1])) + tool._nrs_band_counts(facts[:9]) + with pytest.raises(ValueError, match="twice"): + tool._nrs_band_counts([*facts, facts[0]]) + with pytest.raises(ValueError, match="lacks a band"): + tool._nrs_band_counts(facts[:-1]) + fractional = [dict(fact) for fact in facts] + fractional[1]["value"] = 0.5 + with pytest.raises(ValueError, match="not one count"): + tool._nrs_band_counts(fractional) + shifted = [dict(fact) for fact in facts] + shifted[0]["period"] = {"type": "calendar_year", "value": "2025"} + with pytest.raises(ValueError, match="December 2024 total or band"): + tool._nrs_band_counts(shifted) rows[1][1] = 9 with pytest.raises(ValueError, match="miss its total"): - tool._nrs_band_counts(_nrs_workbook(tool, path, rows)) + tool._nrs_band_counts(_nrs_facts(tool, rows)) + + +def test_read_feed_checks_the_whole_feed_against_its_pin(tool, tmp_path) -> None: + lines = [ + json.dumps({"concept": "other", "value": 1}), + json.dumps({"layout": {"record_set_id": tool.NRS_RECORD_SET}, "value": 2}), + ] + feed = tmp_path / "consumer_facts.jsonl" + feed.write_text("\n".join(lines) + "\n") + facts_sha256 = hashlib.sha256(feed.read_bytes()).hexdigest() + manifest = tmp_path / "manifest.json" + manifest.write_text(json.dumps({"facts_sha256": facts_sha256})) + pin = tmp_path / "chronicle_feed.json" + identity = { + "source_commit": "c" * 40, + "facts_sha256": facts_sha256, + "manifest_sha256": hashlib.sha256(manifest.read_bytes()).hexdigest(), + "fact_row_count": 2, + } + pin.write_text(json.dumps(identity)) + assert tool._feed_identity(pin, manifest) == identity + markers = (tool.NRS_RECORD_SET.encode(),) + assert tool._read_feed(feed, markers=markers, identity=identity) == [ + json.loads(lines[1]) + ] + with pytest.raises(ValueError, match="carries 2 rows"): + tool._read_feed( + feed, markers=markers, identity={**identity, "fact_row_count": 3} + ) + with pytest.raises(ValueError, match="is not the feed"): + tool._read_feed( + feed, markers=markers, identity={**identity, "facts_sha256": "0" * 64} + ) + pin.write_text(json.dumps({**identity, "manifest_sha256": "0" * 64})) + with pytest.raises(ValueError, match="is not the manifest"): + tool._feed_identity(pin, manifest) def test_scotland_numerators_refuse_a_zone_without_counts(tool) -> None: diff --git a/tools/build_uk_conditioned_area_supports.py b/tools/build_uk_conditioned_area_supports.py index c3debef9c8..3a9c61471f 100644 --- a/tools/build_uk_conditioned_area_supports.py +++ b/tools/build_uk_conditioned_area_supports.py @@ -18,20 +18,24 @@ - ``households_band_a`` ... : the area's households by council-tax band, times 10^6. England and Wales use the VOA CTSOP1.1 mix of the area's LSOA (``voa_council_tax_band_mix_lsoa.json``); Scotland uses the dwellings by - band of the area's 2022 data zone, in which its 2022 output areas nest, from - NRS's December 2024 sheet. Northern Ireland has domestic rates and no bands. - -The publisher files are pinned here by sha256: chronicle#412's raw-only -registrations (PR chronicle#413), and NRS's dwelling estimates by 2022 data -zone, which Chronicle registers with only their total as facts (chronicle#419 -asks for the band columns). The VOA band mix is a committed package resource. -The provenance register records every input's identity, each nation's decile -rule counts, the rounding, and every zero-mass draw cell. + band of the area's 2022 data zone, in which its 2022 output areas nest, at + December 2024: NRS's estimates, which Chronicle emits as facts + (chronicle#421). Northern Ireland has domestic rates and no bands. + +The publisher files are chronicle#412's raw-only registrations (PR +chronicle#413), pinned here by sha256. The NRS facts are streamed from the +pinned UK Chronicle feed (``uk/chronicle_feed.json``), which is checked whole +against the pin. The VOA band mix is a committed package resource. The +provenance register records every input's identity, the fingerprint of the +facts read, each nation's decile rule counts, the rounding, and every +zero-mass draw cell. Example (odfpy reads the Welsh Government's ODS; nothing else here needs it): uv run --no-sync --with odfpy python tools/build_uk_conditioned_area_supports.py \\ --supports-dir build/uk/supports \\ --source-manifest build/uk/conditioned_sources.json \\ + --ledger-facts .codex-work/uk-artifact/consumer_facts.jsonl \\ + --ledger-manifest .codex-work/uk-artifact/manifest.json \\ --out-dir build/uk/supports ``--source-manifest`` names exact local files (path/url/sha256/bytes per @@ -45,9 +49,11 @@ import datetime as dt import hashlib import json +import math +import re import sys import zipfile -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from pathlib import Path import numpy as np @@ -59,6 +65,7 @@ modal_area_codes, zero_mass_cells, ) +from microcosm.build.ledger_artifact import consumer_fact_schema_versions_of from microcosm.build.uk_runtime.atomic_area_support import ( BAND_WEIGHT_COLUMNS, BAND_WEIGHT_SCALE, @@ -73,20 +80,23 @@ from microcosm.build.uk_runtime.atomic_area_support import ( SOURCES as SUPPORT_SOURCES, ) +from microcosm.build.uk_runtime.chronicle_feed import ( + require_uk_chronicle_feed_subset_row_contracts, +) from microcosm.graph.codecs import RAW_BYTES_MAX_BYTES _TOOLS = Path(__file__).resolve().parent _REPOSITORY_ROOT = _TOOLS.parent _UK_PACKAGE = _REPOSITORY_ROOT / "packages/microcosm-build/src/microcosm/build/uk" _DEFAULT_PROVENANCE = _UK_PACKAGE / CONDITIONED_PROVENANCE_RESOURCE +DEFAULT_FEED_PIN = _UK_PACKAGE / "chronicle_feed.json" VOA_BAND_MIX = "voa_council_tax_band_mix_lsoa.json" PROVENANCE_SCHEMA_VERSION = 1 PROVENANCE_KIND = "uk_atomic_area_conditioned_supports_provenance" EW, SCOT, NI = SYSTEMS -#: chronicle#412's raw-only registrations, as PR chronicle#413 pins them, and -#: NRS's dwellings by 2022 data zone, registered with its total as facts. +#: chronicle#412's raw-only registrations, as PR chronicle#413 pins them. SOURCES: dict[str, dict[str, str | int]] = { "nspl": { "chronicle_source_id": "ons", @@ -143,24 +153,13 @@ "publisher": "NISRA", "product": "NIMDM 2017 results by Super Output Area", }, - "nrs_dz_dwellings": { - "chronicle_source_id": "nrs", - "chronicle_package_id": "nrs-dwellings-data-zone-2025", - "chronicle_year": 2025, - "filename": "dwelling-estimates-by-2022-data-zones-24-25.xlsx", - "url": "https://nrscotland.gov.uk/media/43tfx3zo/dwelling-estimates-by-2022-data-zones-24-25.xlsx", - "sha256": "5d61db5faf7e81451d838e5d394b8e0682bbf501341c1220aea4a78082ceb033", - "size_bytes": 1_223_284, - "publisher": "NRS", - "product": "Dwelling estimates by 2022 data zone, December 2024 and 2025", - }, } -#: The Chronicle commit that registers these files: chronicle#413's merge, which -#: also carries the NRS registration. The supports were first built at #413's -#: head; the file digests did not move. +#: The Chronicle commit the UK feed pins: chronicle#421's merge, which emits +#: NRS's band facts and registers these files as chronicle#413 did. The +#: supports were first built at #413's head; the file digests did not move. CHRONICLE = { - "pull_request": "PolicyEngine/chronicle#413", - "commit": "c51f40d2bdaa66315dd63f334ede5790a8891e27", + "pull_request": "PolicyEngine/chronicle#421", + "commit": "80a3482905843d447f8811b500a56dbf3b5f47fa", "merged": True, } ISSUES = { @@ -179,14 +178,15 @@ BAND_VINTAGES = {EW: "2025_ctsop", SCOT: "2024_nrs_dz_dwellings"} #: Each area's parent for ties and areas without a residential postcode. PARENT_COLUMNS = {EW: "lsoa_code", SCOT: "lsoa_code", NI: "msoa_code"} -#: NRS's December 2024 sheet: nearest the FRS 2024-25 year and VOA's stock at -#: 31 March 2025. Its header is row 5. -NRS_SHEET = "2024" -NRS_HEADER_ROW = 4 +#: NRS's dwellings by council-tax band and 2022 data zone at December 2024 +#: (chronicle#421): nearest the FRS 2024-25 year and VOA's stock at 31 March +#: 2025. Each zone carries its total and bands A to H. +NRS_RECORD_SET = "nrs.dwellings_data_zone_2025.2024" +NRS_PERIOD = ("calendar_year", "2024") +NRS_ZONE_VINTAGE = "dz_2022" NRS_DATA_ZONES = 7_392 -NRS_ZONE_COLUMN = "Data Zone code" -NRS_TOTAL_COLUMN = "Total number of dwellings" -NRS_BAND_COLUMNS = {band.lower(): f"Council Tax band:\n{band}" for band in "ABCDEFGH"} +NRS_TOTAL_CONCEPT = "nrs.dwellings_total" +NRS_BAND_CONCEPTS = {f"nrs.dwellings_band_{band}": band for band in "abcdefgh"} NOTES = ( "imd_decile is the 2019 vintage of each nation's index (IoD 2019, WIMD 2019, " @@ -204,11 +204,11 @@ "6 dp ending at exactly 1), so households x share x 10^6 is exact. Scotland's read " "its 2022 data zone's dwellings by band, rounded half to even per band.", "Scotland's band mix is its 2022 data zone's, in which its 2022 output areas nest, " - "from NRS's December 2024 sheet: nearest the FRS 2024-25 year and VOA's stock at " - "31 March 2025. NRS counts dwellings on the valuation list, as VOA does in England " - "and Wales. Chronicle registers the workbook (nrs-dwellings-data-zone-2025) with " - "only its total as facts; until chronicle#419 adds the band columns, this tool " - "reads them from the registered bytes.", + "at December 2024: nearest the FRS 2024-25 year and VOA's stock at 31 March 2025. " + "NRS counts dwellings on the valuation list, as VOA does in England and Wales. " + "Chronicle emits the zones' totals and bands A to H as facts (record set " + "nrs.dwellings_data_zone_2025.2024, chronicle#421); this tool reads them from the " + "pinned UK feed and records their fingerprint.", ) @@ -228,12 +228,84 @@ def _parse_args(argv: list[str] | None = None) -> argparse.Namespace: parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) parser.add_argument("--supports-dir", required=True, type=Path) parser.add_argument("--source-manifest", required=True, type=Path) + parser.add_argument( + "--ledger-facts", + required=True, + type=Path, + help="consumer_facts.jsonl of the pinned feed", + ) + parser.add_argument( + "--ledger-manifest", + required=True, + type=Path, + help="manifest.json of the pinned feed", + ) + parser.add_argument("--feed-pin", type=Path, default=DEFAULT_FEED_PIN) parser.add_argument("--out-dir", required=True, type=Path) parser.add_argument("--provenance-json", type=Path, default=_DEFAULT_PROVENANCE) parser.add_argument("--resource-dir", type=Path, default=_UK_PACKAGE) return parser.parse_args(argv) +def _feed_identity(pin_path: Path, manifest_path: Path) -> dict[str, object]: + """The pin, after the manifest's bytes and its facts digest are checked.""" + + pin = json.loads(pin_path.read_text(encoding="utf-8")) + manifest_bytes = manifest_path.read_bytes() + if hashlib.sha256(manifest_bytes).hexdigest() != pin["manifest_sha256"]: + raise ValueError( + f"{manifest_path} is not the manifest uk/chronicle_feed.json pins." + ) + if json.loads(manifest_bytes).get("facts_sha256") != pin["facts_sha256"]: + raise ValueError("The feed manifest names other facts than the pin.") + return { + key: pin[key] + for key in ( + "source_commit", + "facts_sha256", + "manifest_sha256", + "fact_row_count", + ) + } + + +def _pinned_row_contracts(pin_path: Path) -> list[str]: + """The row contracts the feed pin lists, refusing a pin that lists none.""" + + versions = json.loads(pin_path.read_text(encoding="utf-8")).get( + "consumer_fact_schema_versions" + ) + if not isinstance(versions, list) or not versions: + raise ValueError( + f"{pin_path} lists no consumer_fact_schema_versions for the feed's rows." + ) + return versions + + +def _read_feed( + path: Path, *, markers: tuple[bytes, ...], identity: Mapping[str, object] +) -> list[dict]: + """Every row carrying a marker; the whole file's digest and rows are checked.""" + + digest = hashlib.sha256() + count = 0 + facts = [] + with path.open("rb") as stream: + for line in stream: + digest.update(line) + if line.strip(): + count += 1 + if any(marker in line for marker in markers): + facts.append(json.loads(line)) + if digest.hexdigest() != identity["facts_sha256"]: + raise ValueError(f"{path} is not the feed uk/chronicle_feed.json pins.") + if count != identity["fact_row_count"]: + raise ValueError( + f"{path} carries {count} rows; the pin records {identity['fact_row_count']}." + ) + return facts + + def _pinned_sources(path: Path) -> dict[str, Path]: """Every source as an exact local file whose bytes match its registration.""" manifest = json.loads(path.read_bytes()) @@ -329,31 +401,82 @@ def _postcodes(path: Path) -> pd.DataFrame: return frame.loc[live, ["oa21cd", "imd20ind"]].reset_index(drop=True) -def _nrs_band_counts(path: Path) -> dict[str, dict[str, int]]: - """Each 2022 data zone's dwellings by band a to h; bands must sum to its total.""" - frame = pd.read_excel(path, sheet_name=NRS_SHEET, header=NRS_HEADER_ROW) - columns = [NRS_ZONE_COLUMN, NRS_TOTAL_COLUMN, *NRS_BAND_COLUMNS.values()] - missing = [column for column in columns if column not in frame.columns] - if missing: - raise ValueError(f"NRS sheet {NRS_SHEET} lacks columns {missing}.") - zones = frame.loc[ - frame[NRS_ZONE_COLUMN].astype(str).str.fullmatch(r"S01\d{6}"), columns - ] - if len(zones) != NRS_DATA_ZONES or zones[NRS_ZONE_COLUMN].duplicated().any(): +def _nrs_band_counts( + facts: Iterable[Mapping], +) -> tuple[dict[str, dict[str, int]], dict[str, object]]: + """Each 2022 data zone's dwellings by band a to h, and the facts' receipt. + + Reads NRS's December 2024 record set only. Every row of it must be one + data zone's total or band, each zone must carry all nine once, and its + bands must sum to its total. The receipt fingerprints the counts read. + """ + concepts = {NRS_TOTAL_CONCEPT: "total", **NRS_BAND_CONCEPTS} + cells: dict[str, dict[str, int]] = {} + files = set() + rows = 0 + for fact in facts: + if (fact.get("layout") or {}).get("record_set_id") != NRS_RECORD_SET: + continue + rows += 1 + geography = fact.get("geography") or {} + period = fact.get("period") or {} + zone = str(geography.get("id", "")) + # A feed row names its concept as the source measure it observes. + concept = (fact.get("observed_measure") or {}).get("source_concept") + key = concepts.get(concept) + if ( + key is None + or geography.get("vintage") != NRS_ZONE_VINTAGE + or re.fullmatch(r"S01\d{6}", zone) is None + or (period.get("type"), str(period.get("value"))) != NRS_PERIOD + ): + raise ValueError( + f"NRS record set {NRS_RECORD_SET} carries a row that is not a data " + f"zone's December 2024 total or band: {zone} {concept}." + ) + value = fact.get("value") + if ( + isinstance(value, bool) + or not isinstance(value, (int, float)) + or not math.isfinite(value) + or value < 0 + or value != int(value) + ): + raise ValueError(f"NRS zone {zone} has a {key} that is not one count.") + if key in cells.setdefault(zone, {}): + raise ValueError(f"NRS zone {zone} carries its {key} twice.") + cells[zone][key] = int(value) + source = fact.get("source") or {} + files.add((source.get("source_file"), source.get("source_sha256"))) + if len(cells) != NRS_DATA_ZONES: raise ValueError( - f"NRS sheet {NRS_SHEET}: {len(zones):,} data zones, " + f"NRS record set {NRS_RECORD_SET}: {len(cells):,} data zones, " f"expected {NRS_DATA_ZONES:,}." ) - counts = zones[columns[1:]].apply(pd.to_numeric, errors="coerce").to_numpy(float) - if not np.all(np.isfinite(counts) & (counts >= 0) & (counts == np.floor(counts))): - raise ValueError(f"NRS sheet {NRS_SHEET} has a count that is not one count.") - counts = counts.astype(np.int64) - if not np.array_equal(counts[:, 1:].sum(axis=1), counts[:, 0]): - raise ValueError(f"NRS sheet {NRS_SHEET}: a zone's bands miss its total.") - return { - str(zone): dict(zip(NRS_BAND_COLUMNS, map(int, row[1:]), strict=True)) - for zone, row in zip(zones[NRS_ZONE_COLUMN], counts, strict=True) + bands = tuple(NRS_BAND_CONCEPTS.values()) + if any(set(row) != {"total", *bands} for row in cells.values()): + raise ValueError(f"NRS record set {NRS_RECORD_SET}: a zone lacks a band.") + if any(sum(row[band] for band in bands) != row["total"] for row in cells.values()): + raise ValueError( + f"NRS record set {NRS_RECORD_SET}: a zone's bands miss its total." + ) + if len(files) != 1: + raise ValueError( + f"NRS record set {NRS_RECORD_SET} names {len(files)} source files." + ) + ((source_file, source_sha256),) = files + canonical = json.dumps(cells, sort_keys=True, separators=(",", ":")).encode() + receipt = { + "record_set_id": NRS_RECORD_SET, + "period": dict(zip(("type", "value"), NRS_PERIOD, strict=True)), + "rows": rows, + "data_zones": len(cells), + "source_file": source_file, + "source_sha256": source_sha256, + "fingerprint_sha256": hashlib.sha256(canonical).hexdigest(), } + counts = {zone: {band: row[band] for band in bands} for zone, row in cells.items()} + return counts, receipt def decile_column( @@ -441,7 +564,12 @@ def _source_tag(name: str) -> str: return f"{spec['chronicle_package_id']}@sha256:{spec['sha256']}" -def _metadata(system: str, support, resources: Mapping[str, dict]) -> dict: +def _metadata( + system: str, + support, + resources: Mapping[str, dict], + nrs_facts: Mapping[str, object], +) -> dict: indices = "+".join(_source_tag(NATION_INDEX[p]) for p in NATION_PREFIXES[system]) metadata = { IMD_DECILE_COLUMN: { @@ -462,8 +590,11 @@ def _metadata(system: str, support, resources: Mapping[str, dict]) -> dict: ) share = f"voa_ctsop1_1_2025_lsoa_band_{band}_share_6dp" else: - source = f"{_source_tag('nrs_dz_dwellings')}#sheet-{NRS_SHEET}" - share = f"nrs_dz2022_{NRS_SHEET}_band_{band}_share_round_half_even" + source = ( + f"chronicle:{nrs_facts['record_set_id']}" + f"@sha256:{nrs_facts['fingerprint_sha256']}" + ) + share = f"nrs_dz2022_{NRS_PERIOD[1]}_band_{band}_share_round_half_even" metadata[column] = { "kind": "weight", "source": source, @@ -496,6 +627,7 @@ def condition_supports( voa_mix: Mapping, scotland_counts: Mapping[str, Mapping[str, int]], resources: Mapping[str, dict], + nrs_facts: Mapping[str, object], ) -> tuple[dict[str, bytes], dict[str, dict]]: """The three conditioned supports and each one's receipts.""" payloads, entries = {}, {} @@ -521,7 +653,7 @@ def condition_supports( base=base, imd_decile=decile, band_weights=weights, - column_metadata=_metadata(system, support, resources), + column_metadata=_metadata(system, support, resources, nrs_facts), ) if uk_conditioned_support_base(payload) != base: raise ValueError(f"{system}: conditioned support does not extend its base.") @@ -586,13 +718,24 @@ def main(argv: list[str] | None = None) -> None: _log(" reading the NSPL") postcodes = _postcodes(paths["nspl"]) voa, resources = _resources(args.resource_dir) + identity = _feed_identity(args.feed_pin, args.ledger_manifest) + _log(" streaming the pinned feed") + facts = _read_feed( + args.ledger_facts, markers=(NRS_RECORD_SET.encode(),), identity=identity + ) + require_uk_chronicle_feed_subset_row_contracts( + consumer_fact_schema_versions_of(facts), + pinned_versions=_pinned_row_contracts(args.feed_pin), + ) + scotland_counts, nrs_facts = _nrs_band_counts(facts) payloads, entries = condition_supports( bases, postcodes, deciles, voa_mix=voa, - scotland_counts=_nrs_band_counts(paths["nrs_dz_dwellings"]), + scotland_counts=scotland_counts, resources=resources, + nrs_facts=nrs_facts, ) args.out_dir.mkdir(parents=True, exist_ok=True) supports = {} @@ -617,6 +760,8 @@ def main(argv: list[str] | None = None) -> None: "issues": ISSUES, "chronicle": CHRONICLE, "publisher_files": {name: dict(spec) for name, spec in SOURCES.items()}, + "ledger_feed": identity, + "feed_facts": {"nrs_dwellings_by_band": nrs_facts}, "resources": resources, "band_weight_scale": BAND_WEIGHT_SCALE, "supports": supports, From fe823f2a60b12d5891b5ef60cfffcb23490fce2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Sun, 15 Nov 2026 09:24:09 +0000 Subject: [PATCH 18/20] Count the floors of the stages main added since 6 Nov in true source households (#931) Rebasing this branch on main drops its two merges of main. One of them, cd15bcaee, also carried what it took to hold main's microcosm#1490 stages to this branch's floor rule. This commit restores that, and holds to the same rule what main has added since 9d080e793. The tests it fixes are this branch's own: the static floor scan and the counting-module bindings. - spi_employment_shell (its declared inputs came back with the clone fold) and aps_occupation, from cd15bcaee: - aps_occupation declares source_household_id, which receipt_counts.source_household_ids now reads, in place of household_source_id; - both join _COUNTING_STAGES; - both test frames gain the clone index and the true source. - pip_points, uc_limited_capability, frs_disability, frs_council_tax and frs_spine now import receipt_counts, so they join _COUNTING_STAGES. pip_points declares source_household_id in place of household_source_id, as its receipt counts through source_household_ids, and the test frames of pip_points and uc_limited_capability gain the true source. uc_limited_capability reads an open surface. - frs_spine's three new counts, the carer households in the care-recipient evidence and the two support counts of the DWP carer hours, go through receipt_counts.own_source_households. The survey holds no copies when frs_spine runs, so each count is the same as before. - Main's new tests meet this branch's required inputs, as the tests around them do: the two apprentice-draw tests pass person_sources, and the SPI carer-link test's household table gains the true source. - test_counting_module_changes_invalidate_every_stage_that_counts follows frs_spine to the CREATE node that runs its transform (create_uk_frs; the node named after it only claims the cells), and takes frs_employment as its control, since frs_council_tax now counts. What moves: the hashes, and so the node keys, of the seven stages that join _COUNTING_STAGES, and of uk.create@1 through frs_spine. No value moves. Co-Authored-By: Claude Opus 5.5 --- .../src/microcosm/build/uk_runtime/frs_spine.py | 14 ++++++++++---- .../src/microcosm/build/uk_runtime/graph.py | 4 ++-- .../microcosm/build/uk_runtime/graph_kernels.py | 7 +++++++ .../engine_free/uk/test_uk_apprentice_draw.py | 4 ++-- .../tests/engine_free/uk/test_uk_graph.py | 9 +++++++-- .../tests/engine_free/uk/test_uk_pip_points.py | 2 ++ .../tests/engine_free/uk/test_uk_spi_income.py | 2 ++ .../uk/test_uk_uc_limited_capability.py | 2 ++ test_support/microcosm_build/uk_aps_occupation.py | 5 +++++ .../microcosm_build/uk_spi_employment_shell.py | 3 +++ 10 files changed, 42 insertions(+), 10 deletions(-) diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_spine.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_spine.py index 93ab5eee68..11a503d900 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_spine.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/frs_spine.py @@ -32,6 +32,7 @@ from microcosm.build.uk_runtime.receipt_counts import ( UK_DISCLOSURE_FLOOR, UK_WITHHELD, + own_source_households, rounded_count, support_band, ) @@ -2095,15 +2096,18 @@ def frs_care_recipients( by_carer = by_carer.join(line_routes).fillna({"inside": False, "outside": False}) by_carer = by_carer.astype({"inside": bool, "outside": bool}) held_carers = by_carer.loc[by_carer.index.isin(list(held))] + # The survey holds no copies yet, so each carer's own household, from the + # care tab, is their true source (microcosm#931). + sources = own_source_households( + held_carers.rename(columns={"household_id": "person_household_id"}) + ) recipients = at_line.loc[at_line["needper"].isin(FRS_CARE_HELPER_NUMBERS)] recipient_ids = recipients["household_id"] * 1000 + recipients["needper"] evidence.update( { # Record counts are rounded, never exact (UKDS CD137 cl. 8). "carers": rounded_count(len(held_carers)), - "carer_households": support_band( - int(held_carers["household_id"].nunique()) - ), + "carer_households": support_band(len(set(sources.tolist()))), "household_only": rounded_count( int((held_carers["inside"] & ~held_carers["outside"]).sum()) ), @@ -2591,7 +2595,9 @@ def frs_dwp_carer_care_hours( hours = pe_person["care_hours"].to_numpy(dtype=np.float64).copy() benunits = pe_person["person_benunit_id"].to_numpy() - households = pe_person["person_household_id"].to_numpy() + # Each person's own household is their true source: the spine has no + # copies yet (microcosm#931). + households = own_source_households(pe_person) adult = pe_person["is_claimant_or_partner"].to_numpy(dtype=bool) reported = ( pd.to_numeric(pe_person["carers_allowance_reported"], errors="coerce") diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py index 91e41365c0..65d01c1d6e 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph.py @@ -438,7 +438,7 @@ ("person", "person_source_id"), ("household", "region"), ("household", "household_support_channel"), - ("household", "household_source_id"), + ("household", "source_household_id"), } ), # Engine-free: the housing predictors and the channel split. The rewritten @@ -732,7 +732,7 @@ { ("person", "pip_dl_category"), ("person", "pip_m_category"), - ("household", "household_source_id"), + ("household", "source_household_id"), } ), # The claim statuses are drawn on each person's final self-employment diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py index a64c3773bf..c656e6fc37 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/graph_kernels.py @@ -341,6 +341,13 @@ "childcare_copy_take_up", "isa_subscriptions", "trading_allowance_receipts", + "frs_spine", + "frs_council_tax", + "frs_disability", + "spi_employment_shell", + "aps_occupation", + "uc_limited_capability", + "pip_points", } ) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_apprentice_draw.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_apprentice_draw.py index e8e7feaf47..b065ed17d9 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_apprentice_draw.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_apprentice_draw.py @@ -85,7 +85,7 @@ def test_full_time_students_are_never_flagged() -> None: person["is_in_full_time_education"] = full_time weights = np.ones(len(person)) - draw = derive_is_apprentice(person, rate=0.06, person_weights=weights) + draw = _apprentices(person, rate=0.06, person_weights=weights) age = person["age"].to_numpy() in_ages = (age >= 21) & (age <= 24) @@ -105,7 +105,7 @@ def test_refuses_a_frame_without_the_full_time_education_flag() -> None: person = _small([22], ["FT_EMPLOYED"]).drop(columns="is_in_full_time_education") with pytest.raises(ValueError, match="is_in_full_time_education"): - derive_is_apprentice(person, rate=0.06) + _apprentices(person, rate=0.06) def test_flagged_weight_is_nearest_the_per_head_target() -> None: diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_graph.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_graph.py index 60ea5700a6..9444996d62 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_graph.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_graph.py @@ -278,10 +278,15 @@ def test_counting_module_changes_invalidate_every_stage_that_counts(monkeypatch) graph = uk_spine_graph() registry = uk_registry(graph=graph) + # The root stage's transform runs in the CREATE node; the node named + # after it only claims its cells. frs_employment reads no counting + # module, so its hash must stay. + runs = {"frs_spine": "create_uk_frs"} affected = [ - graph.node(stage).kernel for stage in sorted(graph_kernels._COUNTING_STAGES) + graph.node(runs.get(stage, stage)).kernel + for stage in sorted(graph_kernels._COUNTING_STAGES) ] - control = graph.node("frs_council_tax").kernel + control = graph.node("frs_employment").kernel for module in (receipt_counts, source_lineage): before = { ref: registry.implementation_hash(ref) for ref in (*affected, control) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_pip_points.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_pip_points.py index b90923a75d..f4527fe00b 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_pip_points.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_pip_points.py @@ -188,6 +188,8 @@ def _frame(categories, ages, regions, sources): "household_id": list(range(1, count + 1)), "region": regions, "household_source_id": sources, + # The true source each floor counts (microcosm#931). + "source_household_id": sources, } ) return uk_national_frame( diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py index 3291ac47ba..fc49822fb9 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_spi_income.py @@ -147,6 +147,8 @@ def test_spi_carer_link_is_taken_again_from_the_channels_benefits() -> None: "household_id": [1, 2, 101, 102, 103, 104], "household_weight": [10.0, 10.0, 1.0, 1.0, 1.0, 1.0], "household_source_id": [1, 2, 1, 2, 3, 4], + # The true source each floor counts (microcosm#931). + "source_household_id": [1, 2, 1, 2, 3, 4], } ) spi_channel = person["person_household_id"].ge(100) diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_limited_capability.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_limited_capability.py index d906e407d4..a208f061e3 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_limited_capability.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_uc_limited_capability.py @@ -69,6 +69,8 @@ def _frame(people=_PEOPLE, *, spi_column: bool = True, carrier: bool = True): "household_id": households, "region": ["WALES"] * len(households), "household_source_id": households, + # The true source each floor counts (microcosm#931). + "source_household_id": households, } ) if spi_column: diff --git a/test_support/microcosm_build/uk_aps_occupation.py b/test_support/microcosm_build/uk_aps_occupation.py index 69c5162147..f4c08d1e02 100644 --- a/test_support/microcosm_build/uk_aps_occupation.py +++ b/test_support/microcosm_build/uk_aps_occupation.py @@ -101,7 +101,9 @@ def occupation_frame_tables(n_frs: int = 900, n_spi: int = 150, seed: int = 0): { "household_id": household_id, "household_support_channel": "frs", + "household_support_clone_index": 0, "household_source_id": household_id, + "source_household_id": household_id, "region": rng.choice(_REGIONS, n_frs), } ) @@ -164,7 +166,10 @@ def adults(status_draw: np.ndarray) -> pd.DataFrame: { "household_id": n_frs + np.arange(1, n_spi + 1), "household_support_channel": "spi", + "household_support_clone_index": 1, "household_source_id": twins, + # A copy's true source is the FRS household it copies. + "source_household_id": twins, "region": household.set_index("household_id") .loc[twins, "region"] .to_numpy(), diff --git a/test_support/microcosm_build/uk_spi_employment_shell.py b/test_support/microcosm_build/uk_spi_employment_shell.py index 2999814c70..7224d283c2 100644 --- a/test_support/microcosm_build/uk_spi_employment_shell.py +++ b/test_support/microcosm_build/uk_spi_employment_shell.py @@ -55,7 +55,10 @@ def employment_shell_tables(n_frs: int = 1500, n_spi: int = 300, seed: int = 0): { "household_id": household_id, "household_support_channel": channel, + "household_support_clone_index": np.where(channel == "spi", 1, 0), "household_source_id": source, + # A copy's true source is the FRS household it copies. + "source_household_id": source, "region": region, } ) From 690f0a27588292c92f178a1462f297a125aa7700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Sun, 15 Nov 2026 09:52:38 +0000 Subject: [PATCH 19/20] Regenerate the supports' provenance, the coverage manifest and the H2 fixture on main (#931) The rebase on main drops this branch's re-pin of the UK feed onto 80a3482, the merge of PolicyEngine/chronicle#421: main has since pinned 4ce631f5 (PolicyEngine/chronicle#439), which descends from it. The generated files this branch touches are regenerated from their tools on the rebased tree, with the environment synced to main's lock (policyengine-uk 2.177.7). - The conditioned supports, rebuilt from main's pinned feed by tools/build_uk_conditioned_area_supports.py, are byte-identical to those the old head was built with (E&W 0b0f80ea, Scotland a8ca096b, NI 6d71f2a9): NRS's December 2024 band facts are the same in both feeds. Their provenance names the new feed (2,160,233 rows) and build date. - The coverage manifest moves only its source-manifest digest, since sources.yaml lists the conditioned supports. - The H2 fixture differs from main's in the inputs of the ten stages whose declared slices this branch changes, and in UC take-up's contract hash; its fixture.json, in the two stage notes that name source_household_id (UC take-up's pooling and the carer's allowance take-up). Both tools pass --check, and the feed-gated check of Scotland's band facts passes against main's pinned feed. Co-Authored-By: Claude Opus 5.5 --- .../uk/release_input_coverage_manifest.json | 54 +++++++++---------- ..._area_conditioned_supports.provenance.json | 10 ++-- .../parity/uk_spine/sources/fixture.json | 4 +- .../fixtures/parity/uk_spine/uk_spine.json | 2 +- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/packages/microcosm-build/src/microcosm/build/uk/release_input_coverage_manifest.json b/packages/microcosm-build/src/microcosm/build/uk/release_input_coverage_manifest.json index bba8c0442a..4096c30332 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/release_input_coverage_manifest.json +++ b/packages/microcosm-build/src/microcosm/build/uk/release_input_coverage_manifest.json @@ -61,7 +61,7 @@ "required_mass_change_reason": "Capital-gains incidence anchor moves the mass of non-liable clone households back to their paired originals until the sub-exempt and loss-making clone mass match the Advani-Summers reporter composition at the redrawn liable mass; every pair's mass and the total household mass are conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "Advani and Summers (2020), Capital Gains and UK Inequality, CAGE Working Paper 465", "survey": "Family Resources Survey 2024-25, SPI synthetic support, the HMRC Table 3 redrawn gains on the spine and Advani-Summers capital-gains incidence" @@ -84,7 +84,7 @@ "capital_gains" ], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "Advani and Summers (2020), Capital Gains and UK Inequality, CAGE Working Paper 465", "survey": "Family Resources Survey 2024-25, SPI synthetic support, and Advani-Summers capital-gains incidence" @@ -107,7 +107,7 @@ "required_mass_change_reason": "Capital-gains residential split divides every household carrying liable gainers into arms weighted by the solved residential probabilities, one arm per subset of residential gainers; every household's mass and the total household mass are conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "https://www.gov.uk/government/statistics/capital-gains-tax-statistics", "survey": "HMRC Capital Gains Tax statistics 2026 release, Table 8 (UK residential property disposals, 2024-25, administrative) on the amounts the Table 3 redraw placed" @@ -129,7 +129,7 @@ "required_mass_change_reason": "Capital-gains support split divides the wealthiest households of each HMRC Table 3 income band into light copies at equal weight; every household's mass and the total household mass are conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "HMRC Capital Gains Tax statistics, July 2026 release, Table 3 for 2024-25, via the vendored conditioning facts", "survey": "Family Resources Survey 2024-25, SPI synthetic support and HMRC Capital Gains Tax statistics Table 3 (2024-25 individuals by size of gain and taxable income)" @@ -163,7 +163,7 @@ "hmrc_spi_employment_benefits" ], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "The FRS job record's company car answers through frs_spine's carriers (EXPBEN01, EXPBEN03, CARVAL, FUELTYP, CARCON, CARAMT), WAS round-8 company cars' list prices, and HMRC's 2024-25 company car recipients by CO2 band (Table 2A) and fuel (Table 2C), via the vendored facts", "survey": "Family Resources Survey 2024-25 job record; Wealth and Assets Survey round 8; HMRC Benefits in kind statistics (July 2026)" @@ -192,7 +192,7 @@ "required_mass_change_reason": "ETB public-services imputation on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "UK Data Service SN 8856 Effects of Taxes and Benefits household tab, DfT rail fare index, and public NHS activity/cost table.", "survey": "Effects of Taxes and Benefits 1977-2024 and NHS age-gender public table" @@ -212,7 +212,7 @@ "required_mass_change_reason": "ETB VAT expenditure-rate imputation on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "UK Data Service SN 8856 Effects of Taxes and Benefits household tab and cited VAT anchor resource.", "survey": "Effects of Taxes and Benefits 1977-2024" @@ -234,7 +234,7 @@ "required_mass_change_reason": "High-value home support divides every owner household in the top value stratum of its region into light copies at equal weight; every household's mass and the total household mass are conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "Microcosm structural operator (microcosm#1240 fix 1); no publisher input", "survey": "Family Resources Survey 2024-25 and SPI synthetic support, after the WAS wealth draw and the regional property uprating" @@ -255,7 +255,7 @@ "required_mass_change_reason": "CGT asset-type assignment on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "https://www.gov.uk/government/statistics/capital-gains-tax-statistics", "survey": "HMRC Capital Gains Tax statistics 2026 release, Table 8 (UK residential property disposals, 2024-25, administrative), Table 4.1 (individuals claiming Business Asset Disposal Relief or Investors' Relief by band of qualifying gain, 2024-25, administrative) and Table 7 (disposals, proceeds and gains by asset type, 2023-24, sample-based), vendored from the pinned Chronicle feed" @@ -279,7 +279,7 @@ "capital_gains" ], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "conditioning_resource": "hmrc_cgt_conditioning_facts.json", "conditioning_resource_sha256": "bade5462cb0376e46a163639c63a5237c45577be0f9aa7e75b10c057f4b3ac3c", @@ -369,7 +369,7 @@ "full_frs_tei_band_unavailable" ], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "hmrc_surface": "2023-24", "mapped_build_period": "2024", @@ -396,7 +396,7 @@ "required_mass_change_reason": "ISA subscriptions per adult from HMRC's ISA tables on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "HMRC Individual Savings Account statistics Tables 9.4, 9.6 and 9.7 to 9.9, the cash ISA limit reduction impact note and Lifetime ISA Table 1a, via the vendored facts; Office for National Statistics Wealth and Assets Survey, UK Data Service SN 7215, DOI 10.5255/UKDA-SN-7215-20; local licensed round-8 person and household tabs (interviews April 2020 to March 2022, Great Britain).", "survey": "HMRC Annual savings statistics (September 2026 release); Wealth and Assets Survey round 8" @@ -468,7 +468,7 @@ "required_mass_change_reason": "LCFS consumption imputation on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "UK Data Service SN 9603 Living Costs and Food Survey 2024-25 (2nd edition) household/person tabs and the vendored Chronicle facts for NEED 2024 mean kWh, DESNZ Energy Trends and QEP average prices paid for calendar 2024, road-fuel outturn (DESNZ, HMRC, ONS Consumer Trends) and road fuel by vehicle type (DESNZ), ONS Consumer Trends household spending by COICOP division, the DfT VEH1103 licensed-car stock, NTS bus use, the NTS private cars (UK Data Service SN 5340, End User Licence; the vehicle and household tabs, survey years 2022-2024) for the zero-emission share by income fifth and the household-paid road-fuel mix, and the DfT and devolved bus finance tables and fares indices.", "survey": "Living Costs and Food Survey 2024-25" @@ -494,7 +494,7 @@ "required_mass_change_reason": "NTS bus-travel imputation on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "Department for Transport National Travel Survey, UK Data Service SN 5340 (End User Licence, 19th edition, November 2025), DOI 10.5255/UKDA-SN-5340-19; local licensed tab files (household, individual, trip); England residents only from 2013.", "survey": "National Travel Survey 2002-2024" @@ -515,7 +515,7 @@ "required_mass_change_reason": "PIP points stored on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "pip_dl_category and pip_m_category (frs_disability, and hmrc_spi_income_spine for the SPI rows) and the stored age; dwp_pip_points_facts.json, vendored from the pinned feed", "survey": "DWP's Pathways to Work evidence pack, chapter 2, Tables 2.9 and 2.10 (PIP points by age group, England and Wales, end of January 2025), on the spine's stored PIP awards" @@ -535,7 +535,7 @@ "required_mass_change_reason": "Private-school attendance stored on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "policyengine-uk attends_private_school (the gov.simulation.private_school_vat attendance rates and factor), evaluated by the pinned engine", "survey": "policyengine-uk private-school attendance imputation, stored at the spine's weights" @@ -558,7 +558,7 @@ "property_finance_costs" ], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "https://www.gov.uk/government/statistics/property-rental-income-statistics", "survey": "Survey of Personal Incomes Public Use Tape 2022-23 and HMRC Property Rental Income Statistics 2026 (tax year 2024-25)" @@ -579,7 +579,7 @@ "required_mass_change_reason": "Annual property purchases imputed on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "https://www.gov.uk/government/statistics/uk-stamp-tax-statistics", "survey": "HMRC Annual Stamp Tax Statistics 2024 to 2025 (corrected 11 March 2026), Tables 6b, 8a and 8b" @@ -602,7 +602,7 @@ "property_wealth" ], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "uk/high_value_home_value_knots.json, built by tools/build_uk_high_value_home_stock.py from PolicyEngine/chronicle#343's registrations", "survey": "HM Land Registry Price Paid latest sales uprated with the UK House Price Index, owner-weighted by region (the dense value node's knots, region level)" @@ -626,7 +626,7 @@ "non_residential_property_value" ], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "MHCLG dwellings and the UK House Price Index regional average price averaged over the twelve months of calendar 2024 from the July 2026 full file, the frame's valuation basis, so the engine's annual uprating from 2024 projects the value once (microcosm#1240 fix 5).", "survey": "Public regional property reference" @@ -654,7 +654,7 @@ "employment_income" ], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "HMRC, Salary sacrifice reform for pension contributions effective from 6 April 2029", "survey": "Family Resources Survey 2024-25 salary-sacrifice respondents and HMRC salary-sacrifice reform analysis" @@ -687,7 +687,7 @@ "household_source_id" ], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "Reserved SPI support households for the HMRC Table 2.5 total-income bands from GBP 200,000, stacked at the published band taxpayer count over the donors per band (PolicyEngine/chronicle#280 lane).", "survey": "Survey of Personal Incomes Public Use Tape 2022-23 and HMRC Income Tax liabilities statistics July 2026 Table 2.5" @@ -710,7 +710,7 @@ "student_loan_balance" ], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "Explore Education Statistics Table 6a, Higher education total", "survey": "Family Resources Survey 2024-25 and Student Loans Company borrower forecasts for England" @@ -731,7 +731,7 @@ "required_mass_change_reason": "Trading allowance claim statuses stored on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "self_employment_income after the SPI income stage, and household_is_spi_synthetic for the full-relief group; HMRC's published gainers of the raise to GBP 3,000, about 400,000 taxpayers with a lower bill by about GBP 380 on average", "survey": "The self-employed's own profit on the final spine, and HMRC's policy paper on the Budget 2026 trading allowance raise (calibration)" @@ -752,7 +752,7 @@ "required_mass_change_reason": "UC limited capability flags stored on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "frs_uc_lcw_status (frs_spine) on the UC row's person, and the locked engine's uc_limited_capability_for_WRA, uc_limited_capability_for_work, is_uc_assessed_claimant and is_carer_for_benefits on the frame as it stands", "survey": "Family Resources Survey 2024-25 (BENEFITS.UCLCW, DWP's limited capability status on a linked Universal Credit claim) and policyengine-uk's limited capability proxy, evaluated by the pinned engine" @@ -774,7 +774,7 @@ "required_mass_change_reason": "WAS Lifetime ISA imputation on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "Office for National Statistics Wealth and Assets Survey, UK Data Service SN 7215, DOI 10.5255/UKDA-SN-7215-20; local licensed round-8 person and household tabs (interviews April 2020 to March 2022, Great Britain).", "survey": "Wealth and Assets Survey round 8" @@ -813,7 +813,7 @@ "required_mass_change_reason": "WAS wealth imputation on the source spine: household weights pass through unchanged and total household mass is conserved.", "rewrites": [], "source_manifest": "source_stages.json", - "source_manifest_sha256": "f23696d798a5a17ac35845ded07298765259b023ccc03f5fea068158e01ae11d", + "source_manifest_sha256": "c737d82ea2339730fcc18bd368293aacf9c4bcb87a71dfb2c270a44c0e172565", "source_vintages": { "source": "Office for National Statistics Wealth and Assets Survey, UK Data Service SN 7215, DOI 10.5255/UKDA-SN-7215-20; local licensed 2006-22 household tab.", "survey": "Wealth and Assets Survey round 8" diff --git a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json index 6600092949..3fa40a8387 100644 --- a/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json +++ b/packages/microcosm-build/src/microcosm/build/uk/uk_atomic_area_conditioned_supports.provenance.json @@ -1,6 +1,6 @@ { "band_weight_scale": 1000000, - "built_on": "2026-11-05", + "built_on": "2026-11-15", "chronicle": { "commit": "80a3482905843d447f8811b500a56dbf3b5f47fa", "merged": true, @@ -27,10 +27,10 @@ }, "kind": "uk_atomic_area_conditioned_supports_provenance", "ledger_feed": { - "fact_row_count": 2030062, - "facts_sha256": "cb3342c3f59ff961a0ae369ca489293ddd6d021fdeb5cfafb89f6d125329bdfe", - "manifest_sha256": "d2323e7bddb30043fafecc2249fca0ee1506dae8ff20bc5f4db8575dc2ec1b73", - "source_commit": "80a3482905843d447f8811b500a56dbf3b5f47fa" + "fact_row_count": 2160233, + "facts_sha256": "c294ba2013d0ff61b150589640ec63add8563390057b769447c0241661ad5a1c", + "manifest_sha256": "74e564fba1c4589e15e4bb19138414c46e4db316486b5c0d7ccbcccb211c52df", + "source_commit": "4ce631f5ad690fb85007193273ee85a873b824d3" }, "notes": [ "imd_decile is the 2019 vintage of each nation's index (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017): the FRS 2024-25 variables IMDE, IMDW, IMDS and IMDN carry no change note from 2023-24, which predates the 2025 indices, and on an internal comparison England's FRS decile shares by region fit IoD 2019 better than IoD 2025, as the 2023-24 FRS does. The vintage is still to be confirmed with DWP.", diff --git a/packages/microcosm-graph/tests/fixtures/parity/uk_spine/sources/fixture.json b/packages/microcosm-graph/tests/fixtures/parity/uk_spine/sources/fixture.json index 7edfd2b84d..3ff4a956b4 100644 --- a/packages/microcosm-graph/tests/fixtures/parity/uk_spine/sources/fixture.json +++ b/packages/microcosm-graph/tests/fixtures/parity/uk_spine/sources/fixture.json @@ -267,7 +267,7 @@ "artifacts": [], "grain": "person", "nonnegative_outputs": [], - "notes": "Runs after the SPI income chain, UC capital coherence, the Pension Credit and Child Benefit redraws and salary_sacrifice, so the earnings test reads the pay salary sacrifice converts (microcosm#1095 B5); a CGT copy draws as the member it copies, placed with it as one record of their joint weight, so every clone carries its source's draw (microcosm#1319). frs_spine sets would_claim_carers_allowance from reported receipt and the SPI income chain re-derives it from the refilled receipt on the rows it redraws, so that care_hours qualifies a carer for the Universal Credit carer element without paying the allowance to every carer (#882). A carer above the earnings limit cannot report the allowance, so no reform that widens it reached a carer who would claim once entitled: the April 2025 rise of the limit from \u00a3151 to \u00a3196 a week brought an estimated 61,000 more people into eligibility (Independent Review of Carer's Allowance Overpayments, July 2025, chapter 7). One temporary engine materialization at the survey year, on the frame's own values, gives each person's is_gainfully_employed_for_carers_allowance and carers_allowance_earnings (consumed only); the engine reads a year's parameters at 30 April, so the limit is 2024-25's \u00a3151. The allowance is paid only for caring for a severely disabled person (SSCBA 1992 s. 70(2)), which the care hours do not record (microcosm#1418), and policyengine-uk reads it from cares_for_severely_disabled_person (2.177.3, pe-uk#2860) wherever care_hours reach the minimum. frs_disability writes that input from the FRS care tab and the benefits of the people each carer gives their largest band of care, and hmrc_spi_income_spine takes it again on the SPI channel's households; a carer of someone outside the household with no qualifying member is drawn at the share of the in-household carers who report no allowance and care for a qualifying member, the rule this stage drew its own pool by until it read the input (Mar\u00eda's decision (a) of 2026-10-28; A3 of the November event-data plan's PR3, microcosm#1095, Mar\u00eda's choices of 2026-11-10; she signed these notes on 2026-11-11). The pool is the carers at the hours whom the input holds caring for a severely disabled person. A person in that pool whose care_hours reach the engine's gov.dwp.carers_allowance.min_hours (35), who reports no allowance and whom the earnings test holds gainfully employed claims at the take-up contract's carers_allowance_newly_entitled rate (0.6, Mar\u00eda's ruling of 2026-10-20, sensitivity 0.45 to 0.75) on the person's identity-keyed uniform (seed 0, salt would_claim_carers_allowance), placed by weight within strata and rotated by a start drawn per stratum, so that each stratum claims the rate of its eligible weight to within one record and each eligible carer with probability equal to the rate (weight_balanced_uniforms, policyengine-uk's stratified_uniform with a random start; microcosm#1418 and the independent review of microcosm#1420): the route (whether the carer's largest in-household band, frs_care_hours_in_household, reaches the hours), whether the benefit unit reports a means-tested benefit at the survey year, and the survey-year weekly earnings band, one weekly rate wide above the limit and open above three. would_claim = reported OR (eligible AND position < rate). A reporter stays true; a carer under the limit who reports no allowance stays false, as the survey records them entitled and not claiming. Scotland is drawn too (Mar\u00eda's ruling of 2026-10-23): there the flag is Carer Support Payment's, which policyengine-uk pays only under its own earnings limit from 2.146.1 (PolicyEngine/policyengine-uk#2473), and the receipt reports Scotland apart. The earnings test is read before salary_sacrifice moves some contributors' pension amounts out of their pay, so a drawn carer whom that conversion takes under the survey year's limit keeps the flag although the file then shows them entitled and not reporting. The stage rebuilds the flag from reported receipt and refuses a frame whose flag no longer follows it. Its receipt bands support on distinct source households (household_source_id), and gives a weighted total only where three or more carry it and a share only where neither of its sides rests on one or two; it lists each stratum's realised share against its target, and the stage refuses a take-up stratum whose drawn weight misses its share by more than its heaviest record, the most the rotated placement allows, so the balance holds on every build (Anthony's reviews of microcosm#1420). The stage has no health gate.", + "notes": "Runs after the SPI income chain, UC capital coherence, the Pension Credit and Child Benefit redraws and salary_sacrifice, so the earnings test reads the pay salary sacrifice converts (microcosm#1095 B5); a CGT copy draws as the member it copies, placed with it as one record of their joint weight, so every clone carries its source's draw (microcosm#1319). frs_spine sets would_claim_carers_allowance from reported receipt and the SPI income chain re-derives it from the refilled receipt on the rows it redraws, so that care_hours qualifies a carer for the Universal Credit carer element without paying the allowance to every carer (#882). A carer above the earnings limit cannot report the allowance, so no reform that widens it reached a carer who would claim once entitled: the April 2025 rise of the limit from \u00a3151 to \u00a3196 a week brought an estimated 61,000 more people into eligibility (Independent Review of Carer's Allowance Overpayments, July 2025, chapter 7). One temporary engine materialization at the survey year, on the frame's own values, gives each person's is_gainfully_employed_for_carers_allowance and carers_allowance_earnings (consumed only); the engine reads a year's parameters at 30 April, so the limit is 2024-25's \u00a3151. The allowance is paid only for caring for a severely disabled person (SSCBA 1992 s. 70(2)), which the care hours do not record (microcosm#1418), and policyengine-uk reads it from cares_for_severely_disabled_person (2.177.3, pe-uk#2860) wherever care_hours reach the minimum. frs_disability writes that input from the FRS care tab and the benefits of the people each carer gives their largest band of care, and hmrc_spi_income_spine takes it again on the SPI channel's households; a carer of someone outside the household with no qualifying member is drawn at the share of the in-household carers who report no allowance and care for a qualifying member, the rule this stage drew its own pool by until it read the input (Mar\u00eda's decision (a) of 2026-10-28; A3 of the November event-data plan's PR3, microcosm#1095, Mar\u00eda's choices of 2026-11-10; she signed these notes on 2026-11-11). The pool is the carers at the hours whom the input holds caring for a severely disabled person. A person in that pool whose care_hours reach the engine's gov.dwp.carers_allowance.min_hours (35), who reports no allowance and whom the earnings test holds gainfully employed claims at the take-up contract's carers_allowance_newly_entitled rate (0.6, Mar\u00eda's ruling of 2026-10-20, sensitivity 0.45 to 0.75) on the person's identity-keyed uniform (seed 0, salt would_claim_carers_allowance), placed by weight within strata and rotated by a start drawn per stratum, so that each stratum claims the rate of its eligible weight to within one record and each eligible carer with probability equal to the rate (weight_balanced_uniforms, policyengine-uk's stratified_uniform with a random start; microcosm#1418 and the independent review of microcosm#1420): the route (whether the carer's largest in-household band, frs_care_hours_in_household, reaches the hours), whether the benefit unit reports a means-tested benefit at the survey year, and the survey-year weekly earnings band, one weekly rate wide above the limit and open above three. would_claim = reported OR (eligible AND position < rate). A reporter stays true; a carer under the limit who reports no allowance stays false, as the survey records them entitled and not claiming. Scotland is drawn too (Mar\u00eda's ruling of 2026-10-23): there the flag is Carer Support Payment's, which policyengine-uk pays only under its own earnings limit from 2.146.1 (PolicyEngine/policyengine-uk#2473), and the receipt reports Scotland apart. The earnings test is read before salary_sacrifice moves some contributors' pension amounts out of their pay, so a drawn carer whom that conversion takes under the survey year's limit keeps the flag although the file then shows them entitled and not reporting. The stage rebuilds the flag from reported receipt and refuses a frame whose flag no longer follows it. Its receipt bands support on distinct source households (source_household_id), and gives a weighted total only where three or more carry it and a share only where neither of its sides rests on one or two; it lists each stratum's realised share against its target, and the stage refuses a take-up stratum whose drawn weight misses its share by more than its heaviest record, the most the rotated placement allows, so the balance holds on every build (Anthony's reviews of microcosm#1420). The stage has no health gate.", "operations": [ { "consumed_only": true, @@ -8163,7 +8163,7 @@ "minimum_pool_sources": 30, "not_drawn": "keeps its stored flag, except a unit keeping income-related ESA, which claims none", "output": "would_claim_uc", - "pooling": "adjacent bands within a family type, lowest first, until the drawn units rest on minimum_pool_sources distinct household_source_id values; a short last pool joins the one before it. Then, lowest first, a pool that cannot meet DWP's count (its undrawn entitled units' expected claims exceed the count, or the count exceeds them plus the weight of every drawn unit) is held at the nearer of those ends and passes its gap to the other pools, nearest first, the one with more room first at equal distance and the lower on a tie, each taking what its room allows; a gap no pool can take leaves the family type unreachable. With the fits, a passed shortfall's room is the pool's undrawn claims plus the weight of its drawn units with neither a young claimant or partner nor the LCWRA element, less its count (age_fit, lcwra_fit)", + "pooling": "adjacent bands within a family type, lowest first, until the drawn units rest on minimum_pool_sources distinct source_household_id values; a short last pool joins the one before it. Then, lowest first, a pool that cannot meet DWP's count (its undrawn entitled units' expected claims exceed the count, or the count exceeds them plus the weight of every drawn unit) is held at the nearer of those ends and passes its gap to the other pools, nearest first, the one with more room first at equal distance and the lower on a tie, each taking what its room allows; a gap no pool can take leaves the family type unreachable. With the fits, a passed shortfall's room is the pool's undrawn claims plus the weight of its drawn units with neither a young claimant or partner nor the LCWRA element, less its count (age_fit, lcwra_fit)", "population": "uc_age_eligible", "residual_rate": "(T - F) / D, clipped to [0, 1]; T DWP's calendar-2025 mean count of the pool's bands after any gaps passed to or from it, D the weight of the pool's drawn units and F the expected claims of its other entitled units, over Great Britain at the stage's household weights; realized by the drawn units claiming in the order of their uniform until their weight is nearest T - F, and applied at that uniform to Northern Ireland's drawn units too", "seed": 0, diff --git a/packages/microcosm-graph/tests/fixtures/parity/uk_spine/uk_spine.json b/packages/microcosm-graph/tests/fixtures/parity/uk_spine/uk_spine.json index f391b438be..02ac47c4ac 100644 --- a/packages/microcosm-graph/tests/fixtures/parity/uk_spine/uk_spine.json +++ b/packages/microcosm-graph/tests/fixtures/parity/uk_spine/uk_spine.json @@ -1 +1 @@ -{"country":"uk","nodes":[{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Load the source-bound UK FRS root population.","id":"create_uk_frs","inputs":[],"kernel":"uk.create@1","mass":"conserve","outputs":[{"column":"age","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"gender","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"months_since_last_birthday","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"marital_status","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"hours_worked","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"care_hours","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_care_hours_in_household","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_care_recipients","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"is_household_head","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_benunit_head","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_parent","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_blind","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_uc_claimant","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_claimant_or_partner","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_hbai_dependent_child","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"uc_is_in_startup_period","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_uc_lcw_status","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_uc_carer_element","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"uc_is_in_gainful_self_employment","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"rent_paid_as_boarder","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"rent_paid_as_lodger","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employment_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"self_employment_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"trading_loss","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"loss_relief","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"ni_class_4_losses_brought_forward","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"private_pension_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"annuity_and_trust_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"individual_savings_account_interest_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"savings_interest_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"dividend_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"other_investment_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"stands_as_sole_owner_or_partner_of_company","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_engaged_in_owned_company_trade","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"owned_company_is_main_employment","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"owned_company_carries_on_trade","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"owned_company_carries_on_property_business","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"owned_company_income_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"property_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"reports_rent_from_other_property","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"maintenance_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"spousal_maintenance_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"miscellaneous_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"private_transfer_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"lump_sum_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"student_loan_repayments","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"statutory_sick_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"statutory_maternity_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"statutory_paternity_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"student_loans","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"access_fund","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"education_grants","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"healthy_start_vouchers","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"free_school_breakfasts","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"free_school_fruit_veg","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"free_school_meals","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"council_tax_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"maintenance_expenses","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"childcare_expenses","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"personal_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employee_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"pension_contributions_via_salary_sacrifice","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"salary_sacrifice_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"salary_sacrifice_asked","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_bonus_amount","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_company_car_price_band","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_company_car_fuel_code","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_company_car_private_fuel","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_company_car_contribution","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"child_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"income_support_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"housing_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"attendance_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"dla_sc_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"dla_m_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"iidb_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"carers_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"would_claim_carers_allowance","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"sda_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"afcs_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"ssmg_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"pension_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"child_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"working_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"state_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"winter_fuel_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"incapacity_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"universal_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"pip_m_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"pip_dl_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"jsa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"jsa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"esa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"esa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"esa_includes_support_component","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"bsp_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"war_widows_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"widowed_parents_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_benunit_capital","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"is_married","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"dependent_children","dtype":"int64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"liable_for_share_of_household_rent","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"region","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"tenure_type","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"accommodation_type","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"num_bedrooms","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"council_tax_reported","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"council_tax_band","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"council_tax_rebate","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"council_tax_single_adult_raw","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"water_and_sewerage_charges","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"domestic_rates","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"rent","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"subrent","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"mortgage_interest_repayment","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"mortgage_capital_repayment","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"structural_insurance_payments","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"housing_service_charges","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"external_child_payments","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"sample_fraction":1.0,"sample_seed":578,"stage_contract_sha256":"98ca74949e07fcf0f858bc88f882f2a196c6bf6f768b0002d2d8d1ce40ce56cb","time_period":"2024"},"population":null,"sources":["frs"],"structural":"create","weights":null},{"base":"create_uk_frs","citation":"","description":"Ownership boundary for the source-assembling root stage.","id":"frs_spine.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"base":null,"citation":"","description":"Claim the cells assembled by the UK FRS root transform.","id":"frs_spine","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"age","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"gender","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"months_since_last_birthday","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"marital_status","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hours_worked","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"care_hours","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_care_hours_in_household","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_care_recipients","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_household_head","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_benunit_head","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_parent","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_blind","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_uc_claimant","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_claimant_or_partner","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_hbai_dependent_child","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"uc_is_in_startup_period","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_uc_lcw_status","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_uc_carer_element","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"uc_is_in_gainful_self_employment","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"rent_paid_as_boarder","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"rent_paid_as_lodger","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"self_employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"trading_loss","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"loss_relief","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"ni_class_4_losses_brought_forward","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"private_pension_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"annuity_and_trust_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"individual_savings_account_interest_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"savings_interest_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dividend_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"other_investment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"stands_as_sole_owner_or_partner_of_company","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_engaged_in_owned_company_trade","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_is_main_employment","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_carries_on_trade","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_carries_on_property_business","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_income_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"reports_rent_from_other_property","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"maintenance_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"spousal_maintenance_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"miscellaneous_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"private_transfer_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"lump_sum_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"student_loan_repayments","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"statutory_sick_pay","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"statutory_maternity_pay","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"statutory_paternity_pay","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"student_loans","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"access_fund","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"education_grants","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"healthy_start_vouchers","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"free_school_breakfasts","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"free_school_fruit_veg","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"free_school_meals","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"maintenance_expenses","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"childcare_expenses","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"personal_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employee_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pension_contributions_via_salary_sacrifice","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"salary_sacrifice_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"salary_sacrifice_asked","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_bonus_amount","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_company_car_price_band","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_company_car_fuel_code","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_company_car_private_fuel","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_company_car_contribution","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"income_support_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"housing_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"attendance_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_sc_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_m_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"iidb_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"carers_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_carers_allowance","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"sda_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"afcs_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"ssmg_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pension_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"working_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"state_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"winter_fuel_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"incapacity_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"universal_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_m_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_dl_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"jsa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"jsa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_includes_support_component","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"bsp_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"war_widows_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"widowed_parents_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_benunit_capital","dtype":"float64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_married","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dependent_children","dtype":"int64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"liable_for_share_of_household_rent","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"region","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"tenure_type","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"accommodation_type","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"num_bedrooms","dtype":"int64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_reported","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_band","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_rebate","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_single_adult_raw","dtype":"int64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"water_and_sewerage_charges","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"domestic_rates","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"rent","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"subrent","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"mortgage_interest_repayment","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"mortgage_capital_repayment","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"structural_insurance_payments","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"housing_service_charges","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"external_child_payments","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"}],"params":{},"population":"frs_spine.boundary","sources":[],"structural":"none","weights":null},{"base":"frs_spine.boundary","citation":"","description":"Ownership boundary before age_tail rewrites.","id":"age_tail.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage age_tail.","id":"age_tail","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["external_child_payments","region"],"entity":"household","rows":"all"},{"columns":["gender"],"entity":"person","rows":"all"}],"kernel":"uk.stage.age_tail@1","mass":"conserve","outputs":[{"column":"age","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"age_tail","stage_contract_sha256":"963a34f38caede2525e3b8735f904bb70a1bbef5a272f0eefd4346343444484f","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_relationships.","id":"frs_relationships","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","is_household_head"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_relationships@1","mass":"conserve","outputs":[{"column":"relationship_to_head","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"ons_family_role","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"ons_family_index","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"is_looked_after_by_local_authority","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"child_limit_non_parental_caring_exception","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"ons_household_type","dtype":"string","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_relationships","stage_contract_sha256":"ae32bf855753d3b7505e54a18532b1b53a04b6beda764cc09ad09462cf130085","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_employment.","id":"frs_employment","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["ons_household_type","region"],"entity":"household","rows":"all"},{"columns":["age"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_employment@1","mass":"conserve","outputs":[{"column":"employment_status","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"employment_sector","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"sic_industry_division","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"soc2020_major_group","dtype":"string","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_employment","stage_contract_sha256":"c4dc3da7179c7b7d6eb67c6f119df1f213e50ee6b83a53660d317126a5773027","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_council_tax.","id":"frs_council_tax","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","soc2020_major_group"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_council_tax@1","mass":"conserve","outputs":[{"column":"council_tax","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_council_tax","stage_contract_sha256":"2523bdaed96ad432bc3f6bca68ed5edcf8f0a44d66bf3f04a3afa9fa30e3987b","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_disability.","id":"frs_disability","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["council_tax","region"],"entity":"household","rows":"all"},{"columns":["afcs_reported","age","attendance_allowance_reported","care_hours","carers_allowance_reported","dla_m_reported","dla_sc_reported","esa_contrib_reported","esa_income_reported","frs_care_recipients","frs_uc_carer_element","iidb_reported","incapacity_benefit_reported","is_claimant_or_partner","pip_dl_reported","pip_m_reported","sda_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_disability@1","mass":"conserve","outputs":[{"column":"aa_category","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"dla_sc_category","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"dla_m_category","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"pip_m_category","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"pip_dl_category","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"is_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_enhanced_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"cares_for_severely_disabled_person","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_disability","stage_contract_sha256":"5a89f3cfa318efe309329371bcaf438a2a44d86428d5f2839370439629686cb9","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_education.","id":"frs_education","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","cares_for_severely_disabled_person","esa_contrib_reported","esa_income_reported","jsa_contrib_reported","jsa_income_reported","universal_credit_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_education@1","mass":"conserve","outputs":[{"column":"current_education","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"highest_education","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"is_in_non_advanced_education","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_in_approved_training","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"age_started_or_accepted_current_education_or_training","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"is_before_universal_credit_qualifying_young_person_terminal_date","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"adult_ema","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"child_ema","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"receives_benefits_in_own_right","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"reports_outstanding_student_loan","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"age_left_full_time_education","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"is_in_full_time_education","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_education","stage_contract_sha256":"17f97af529c76e807f709af26a4bd1dd11e103c0f885048a73c18e28b94b9b54","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_legacy_proxies.","id":"frs_legacy_proxies","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_legacy_proxies@1","mass":"conserve","outputs":[{"column":"legacy_jobseeker_proxy","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"esa_health_condition_proxy","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"esa_support_group_proxy","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_legacy_proxies","stage_contract_sha256":"1ecf761cf3fa7180da15659e138e67a8654e58272b4fde28344aa27a874ad0aa","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"age_tail.boundary","citation":"","description":"Ownership boundary before frs_education_grant_split rewrites.","id":"frs_education_grant_split.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_education_grant_split.","id":"frs_education_grant_split","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_education_grant_split@1","mass":"conserve","outputs":[{"column":"disabled_students_allowance_eligible_expenses","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"education_grants","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_education_grant_split","stage_contract_sha256":"8718f014b90498c2cc7c754289775ca4a41452d9b978d8cbc5f34b64cbdc7df2","time_period":"2024"},"population":"frs_education_grant_split.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_take_up.","id":"frs_take_up","inputs":[{"columns":["frs_benunit_capital","is_married"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","child_benefit_reported","education_grants","is_uc_claimant","months_since_last_birthday","pension_credit_reported","universal_credit_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_child_benefit","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"child_benefit_opts_out","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_pc","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_uc","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_tfc","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_extended_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_universal_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_targeted_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_uc_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"maximum_extended_childcare_hours_usage","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"max_free_entitlement_hours_used","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_take_up","stage_contract_sha256":"78aec80408c50455b37308e5a977fb70df3ecf915d6c1e8f80715ad9b58e62cf","time_period":"2024"},"population":"frs_education_grant_split.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_person_draws.","id":"frs_person_draws","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","employment_income","employment_status","is_in_full_time_education","max_free_entitlement_hours_used"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_person_draws@1","mass":"conserve","outputs":[{"column":"would_claim_marriage_allowance","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"would_claim_scp","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"attends_private_school_random_draw","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"tax_free_childcare_spend_routed_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"is_apprentice","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_person_draws","stage_contract_sha256":"5bd9c080af0e151afc10462fed72d491bad50e2516f0067654cb06680f4329ae","time_period":"2024"},"population":"frs_education_grant_split.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_household_draws.","id":"frs_household_draws","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","is_apprentice"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_household_draws@1","mass":"conserve","outputs":[{"column":"household_owns_tv","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"would_evade_tv_licence_fee","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"main_residential_property_purchased_is_first_home","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"property_purchased","dtype":"bool","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_household_draws","stage_contract_sha256":"c74c63b09264319c4bf0049dabba00ecd0ce660beb7b53d6dae71518434bc949","time_period":"2024"},"population":"frs_education_grant_split.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_brma.","id":"frs_brma","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_brma@1","mass":"conserve","outputs":[{"column":"brma","dtype":"string","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_brma","stage_contract_sha256":"4285376b37299d375ed583b7f6b1747bd8b7cb1c8c0d19a36481156b5314a854","time_period":"2024"},"population":"frs_education_grant_split.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"frs_education_grant_split.boundary","citation":"","description":"Freeze the assembled-spine gate population.","id":"frs_brma.checkpoint","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_hmrc_spine_leaves.","id":"frs_hmrc_spine_leaves","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["brma","region"],"entity":"household","rows":"all"},{"columns":["age","employment_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_hmrc_spine_leaves@1","mass":"conserve","outputs":[{"column":"hmrc_spi_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_unemployment_benefit_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_incapacity_benefit_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"ossben_identifiable_subset","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"srp_regular_code5","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employer_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_hmrc_spine_leaves","stage_contract_sha256":"cb0552c10c46b3045be3f92cffa062fc7d1d55353da648b155e0513264c7a2ff","time_period":"2024"},"population":"frs_brma.checkpoint","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_annual_income_spells.","id":"frs_annual_income_spells","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","employer_pension_contributions","employment_income","gender","self_employment_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_annual_income_spells@1","mass":"conserve","outputs":[{"column":"employment_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employment_income_other_spells","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"self_employment_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"self_employment_income_other_spells","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"private_pension_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"contributory_benefits_annual_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_annual_income_spells","stage_contract_sha256":"c5f170931bf33d9e490c8b79c176994f0b6a01582ddecebde665745bc5d859a9","time_period":"2024"},"population":"frs_brma.checkpoint","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"frs_brma.checkpoint","citation":"","description":"Run structural UK stage spi_support_channel.","id":"spi_support_channel","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.spi_support_channel@1","mass":"declared","outputs":[],"params":{"expand_cells":[["person","person_source_id","int64"],["person","person_support_channel","string"],["person","person_support_clone_index","int64"],["benunit","benunit_source_id","int64"],["benunit","benunit_support_channel","string"],["benunit","benunit_support_clone_index","int64"],["household","source_household_id","int64"],["household","source_year","int64"],["household","source_household_key","string"],["household","household_source_id","int64"],["household","household_support_channel","string"],["household","household_support_clone_index","int64"],["household","household_is_spi_synthetic","bool"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"spi_support_channel","stage_contract_sha256":"2c682605139c0a8f96e8ba45a2c03f506d3f758ef437841066a8fdb8b74269b6","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by spi_support_channel.","id":"spi_support_channel.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"person_source_id","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"person_support_channel","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"person_support_clone_index","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"benunit_source_id","dtype":"int64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"benunit_support_channel","dtype":"string","entity":"benunit","ownership":"produced","rows":"all"},{"column":"benunit_support_clone_index","dtype":"int64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"source_household_id","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"source_year","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"source_household_key","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"household_source_id","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"household_support_channel","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"household_support_clone_index","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"household_is_spi_synthetic","dtype":"bool","entity":"household","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["person.person_source_id","person.person_support_channel","person.person_support_clone_index","benunit.benunit_source_id","benunit.benunit_support_channel","benunit.benunit_support_clone_index","household.source_household_id","household.source_year","household.source_household_key","household.household_source_id","household.household_support_channel","household.household_support_clone_index","household.household_is_spi_synthetic"]},"population":"spi_support_channel","sources":[],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"spi_support_channel","citation":"","description":"Run structural UK stage spi_income_band_donors.","id":"spi_income_band_donors","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.spi_income_band_donors@1","mass":"declared","outputs":[],"params":{"expand_cells":[["person","person_source_id","int64"],["person","person_support_channel","string"],["person","person_support_clone_index","int64"],["benunit","benunit_source_id","int64"],["benunit","benunit_support_channel","string"],["benunit","benunit_support_clone_index","int64"],["household","household_source_id","int64"],["household","household_support_channel","string"],["household","household_support_clone_index","int64"],["household","household_is_spi_synthetic","bool"],["household","household_is_spi_income_band_donor","bool"],["household","spi_income_band_donor_lower_bound","float64"],["person","person_is_spi_income_band_carrier","bool"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"spi_income_band_donors","stage_contract_sha256":"fea5354cec3ac0f6289018fc79d0d1ebc971870205ecf9c710df7a7312db21c7","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by spi_income_band_donors.","id":"spi_income_band_donors.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"person_source_id","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"person_support_channel","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"person_support_clone_index","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"benunit_source_id","dtype":"int64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"benunit_support_channel","dtype":"string","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"benunit_support_clone_index","dtype":"int64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"household_source_id","dtype":"int64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"household_support_channel","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"household_support_clone_index","dtype":"int64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"household_is_spi_synthetic","dtype":"bool","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"household_is_spi_income_band_donor","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"spi_income_band_donor_lower_bound","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"person_is_spi_income_band_carrier","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["household.household_is_spi_income_band_donor","household.spi_income_band_donor_lower_bound","person.person_is_spi_income_band_carrier"]},"population":"spi_income_band_donors","sources":[],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage hmrc_spi_income_spine.","id":"hmrc_spi_income_spine","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","frs_uc_lcw_status","frs_uc_carer_element","rent_paid_as_boarder","rent_paid_as_lodger","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","maintenance_expenses","childcare_expenses","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","ssmg_reported","incapacity_benefit_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","ossben_identifiable_subset","srp_regular_code5","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier"],"entity":"person","rows":"all"}],"kernel":"uk.stage.hmrc_spi_income_spine@1","mass":"conserve","outputs":[{"column":"charitable_investment_gifts","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"gift_aid","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"other_investment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_employment_benefits","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_employment_expenses","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_other_social_security_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_taxable_termination_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_miscellaneous_employment_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_other_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_state_pension_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"property_finance_costs","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_employed_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_total_earned_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_total_investment_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_assessable_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"self_employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"savings_interest_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dividend_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"private_pension_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employee_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employer_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"personal_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pension_contributions_via_salary_sacrifice","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"individual_savings_account_interest_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"universal_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pension_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"housing_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"income_support_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"working_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"attendance_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"state_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_sc_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_m_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_m_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_dl_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"sda_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"carers_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"iidb_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"afcs_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"bsp_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"war_widows_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"widowed_parents_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"winter_fuel_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"jsa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"jsa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"trading_loss","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"loss_relief","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"ni_class_4_losses_brought_forward","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_income_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_pay","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_unemployment_benefit_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_incapacity_benefit_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employment_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employment_income_other_spells","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"self_employment_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"self_employment_income_other_spells","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"private_pension_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"contributory_benefits_annual_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"annuity_and_trust_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"aa_category","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_sc_category","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_m_category","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_m_category","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_dl_category","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_enhanced_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_carers_allowance","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"uc_is_in_startup_period","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"uc_is_in_gainful_self_employment","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_includes_support_component","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"reports_rent_from_other_property","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"stands_as_sole_owner_or_partner_of_company","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_engaged_in_owned_company_trade","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_is_main_employment","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_carries_on_trade","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_carries_on_property_business","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"cares_for_severely_disabled_person","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"person_is_spi_income_recipient","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"hmrc_spi_income_spine","stage_contract_sha256":"88e459e60ca51cb5e53fd2335ad6db1736241125484024834c28b56feef28496","time_period":"2024"},"population":"spi_income_band_donors","sources":["frs"],"structural":"none","weights":null},{"base":"spi_income_band_donors","citation":"","description":"Ownership boundary before company_cars rewrites.","id":"company_cars.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage company_cars.","id":"company_cars","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","rent_paid_as_boarder","rent_paid_as_lodger","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient"],"entity":"person","rows":"all"}],"kernel":"uk.stage.company_cars@1","mass":"conserve","outputs":[{"column":"company_car_list_price","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"company_car_co2_emissions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"company_car_fuel_type","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"company_car_electric_range","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"company_car_capital_contributions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"company_car_private_fuel_provided","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"uc_is_in_gainful_self_employment","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_pay","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_employment_benefits","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"company_cars","stage_contract_sha256":"13dd8d3f30efbd1d67227442ffd4547b69225e0f89b0f6b7f305b786c25172a8","time_period":"2024"},"population":"company_cars.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"company_cars.boundary","citation":"","description":"Ownership boundary before spi_employment_shell rewrites.","id":"spi_employment_shell.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage spi_employment_shell.","id":"spi_employment_shell","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_source_id","household_support_channel","region"],"entity":"household","rows":"all"},{"columns":["age","dividend_income","employment_income","employment_status","gender","hmrc_spi_employment_benefits","hmrc_spi_pay","person_is_spi_income_recipient","private_pension_income","savings_interest_income","self_employment_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.spi_employment_shell@1","mass":"conserve","outputs":[{"column":"soc2020_major_group","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"sic_industry_division","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employment_sector","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"spi_employment_shell","stage_contract_sha256":"4612c78bf72a36c34a6be652d15d1348fe3d99c873fa8d5821978816b59d1618","time_period":"2024"},"population":"spi_employment_shell.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage aps_occupation.","id":"aps_occupation","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_source_id","household_support_channel","region"],"entity":"household","rows":"all"},{"columns":["age","employment_income","employment_sector","employment_status","gender","hmrc_spi_pay","person_is_spi_income_recipient","person_source_id","sic_industry_division","soc2020_major_group"],"entity":"person","rows":"all"}],"kernel":"uk.stage.aps_occupation@1","mass":"conserve","outputs":[{"column":"soc2020_sub_major_group","dtype":"string","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"aps_occupation","stage_contract_sha256":"644102f010870dccd28f8b980cbc5f648b7ff8ed140a0a5d9f23f02ada7f3d6d","time_period":"2024"},"population":"spi_employment_shell.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"spi_employment_shell.boundary","citation":"","description":"Ownership boundary before spi_housing_shell rewrites.","id":"spi_housing_shell.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage spi_housing_shell.","id":"spi_housing_shell","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["council_tax_single_adult_raw","household_support_channel","ons_household_type","region"],"entity":"household","rows":"all"},{"columns":["age","dividend_income","employment_income","individual_savings_account_interest_income","is_household_head","other_investment_income","private_pension_income","property_income","savings_interest_income","self_employment_income","soc2020_sub_major_group","state_pension_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.spi_housing_shell@1","mass":"conserve","outputs":[{"column":"tenure_type","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"accommodation_type","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_band","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"num_bedrooms","dtype":"int64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_reported","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"rent","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"mortgage_interest_repayment","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"mortgage_capital_repayment","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"structural_insurance_payments","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"housing_service_charges","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"water_and_sewerage_charges","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"domestic_rates","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"subrent","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_rebate","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"housing_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"spi_housing_shell","stage_contract_sha256":"9a76a02ceddb2cd85819f57cd33feb44d645800ce963d0b18bad0f6de808fd81","time_period":"2024"},"population":"spi_housing_shell.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage was_wealth.","id":"was_wealth","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group"],"entity":"person","rows":"all"}],"kernel":"uk.stage.was_wealth@1","mass":"conserve","outputs":[{"column":"owned_land","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"property_wealth","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"corporate_wealth","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"private_pension_wealth","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"gross_financial_wealth","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"net_financial_wealth","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"main_residence_value","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"other_residential_property_value","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"non_residential_property_value","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"savings","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"num_vehicles","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"cash_isa","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"stocks_and_shares_isa","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"mortgage_debt","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"consumer_debt","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"student_loan_balance","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"directly_held_shares","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"unit_and_investment_trusts","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"other_residential_property_secured_debt","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"non_residential_property_secured_debt","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"was_wealth","stage_contract_sha256":"4c0bcaabf3695a75ec7e69d99b6b8c90570fd345067d77f1ea315f5508a88962","time_period":"2024"},"population":"spi_housing_shell.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage was_lisa.","id":"was_lisa","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance"],"entity":"person","rows":"all"}],"kernel":"uk.stage.was_lisa@1","mass":"conserve","outputs":[{"column":"has_lifetime_isa","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"lifetime_isa_balance","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"household_lifetime_isa_balance","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"was_lisa","stage_contract_sha256":"6f9a9dc796a43487e520910c6e50561e9394323c83934923321741018648c661","time_period":"2024"},"population":"spi_housing_shell.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"spi_housing_shell.boundary","citation":"","description":"Ownership boundary before regional_property_uprating rewrites.","id":"regional_property_uprating.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage regional_property_uprating.","id":"regional_property_uprating","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_lifetime_isa_balance","household_support_channel","region"],"entity":"household","rows":"all"},{"columns":["age"],"entity":"person","rows":"all"}],"kernel":"uk.stage.regional_property_uprating@1","mass":"conserve","outputs":[{"column":"main_residence_value","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_wealth","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_land","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"other_residential_property_value","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"non_residential_property_value","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"regional_property_uprating","stage_contract_sha256":"f45db95fde3f93731c0925b9bf8c12021921df2e4908770acdec1e3c97889277","time_period":"2024"},"population":"regional_property_uprating.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"regional_property_uprating.boundary","citation":"","description":"Run structural UK stage high_value_home_support.","id":"high_value_home_support","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.high_value_home_support@1","mass":"conserve","outputs":[],"params":{"expand_cells":[["household","household_is_high_value_support_copy","bool"],["household","high_value_support_copies","int64"],["household","high_value_support_copy_index","int64"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"high_value_home_support","stage_contract_sha256":"174f4b38228d98107bee1639d1a297a2748bb618e87c7bd0a6c869c6ab06f8fa","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by high_value_home_support.","id":"high_value_home_support.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"household_is_high_value_support_copy","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"high_value_support_copies","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"high_value_support_copy_index","dtype":"int64","entity":"household","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["household.household_is_high_value_support_copy","household.high_value_support_copies","household.high_value_support_copy_index"]},"population":"high_value_home_support","sources":[],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage regional_home_values.","id":"regional_home_values","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["high_value_support_copy_index","household_is_high_value_support_copy","household_source_id","region","tenure_type"],"entity":"household","rows":"all"},{"columns":["age"],"entity":"person","rows":"all"}],"kernel":"uk.stage.regional_home_values@1","mass":"conserve","outputs":[{"column":"main_residence_value","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_wealth","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"main_residence_value_rank_basis","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"regional_home_values","stage_contract_sha256":"d1c8f12081507e28a2a4b532961b4996577ea972b78e30b39a61f41a7d35046c","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage property_components.","id":"property_components","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["main_residence_value_rank_basis","non_residential_property_value","other_residential_property_value","region","subrent"],"entity":"household","rows":"all"},{"columns":["age","is_household_head","person_is_spi_income_recipient","person_support_channel"],"entity":"person","rows":"all"}],"kernel":"uk.stage.property_components@1","mass":"conserve","outputs":[{"column":"property_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_finance_costs","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_rental_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"property_components","stage_contract_sha256":"23cc497627946fde4875c27b5ed2cf94a9cb89d7bd64025c1f34f1ac3b9baaf6","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage property_purchases.","id":"property_purchases","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_source_id","non_residential_property_value","other_residential_property_value","region"],"entity":"household","rows":"all"},{"columns":["age","property_rental_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.property_purchases@1","mass":"conserve","outputs":[{"column":"additional_residential_property_purchased","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"non_residential_property_purchased","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"property_purchases","stage_contract_sha256":"cfe459095fbb1cdeb95596442291d0405d99de1bc544a2ee27b3b49f841be940","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage nts_bus_travel.","id":"nts_bus_travel","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.nts_bus_travel@1","mass":"conserve","outputs":[{"column":"local_bus_use_band","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"bus_in_london_trips","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"other_local_bus_trips","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"local_bus_trips","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"bus_pass_eligible","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"local_bus_single_fare_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"household_local_bus_trips","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"nts_bus_travel","stage_contract_sha256":"6753039b8ce02c6e4bed6f6b00d52c8c2a38e9b9a5f19eb3821625767f4667c6","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage lcfs_consumption.","id":"lcfs_consumption","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share"],"entity":"person","rows":"all"}],"kernel":"uk.stage.lcfs_consumption@1","mass":"conserve","outputs":[{"column":"food_and_non_alcoholic_beverages_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"alcohol_and_tobacco_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"clothing_and_footwear_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"housing_water_and_electricity_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"household_furnishings_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"health_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"transport_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"communication_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"recreation_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"education_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"restaurants_and_hotels_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"miscellaneous_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"petrol_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"diesel_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"bus_fare_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"domestic_energy_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"electricity_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"gas_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"liquid_fuel_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"solid_fuel_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"has_fuel_consumption","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"uses_energy_prepayment_meter","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"electricity_kwh","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"gas_kwh","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"beer_litres","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"cider_litres","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"wine_litres","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"spirits_litres","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"other_fermented_litres","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"beer_draught_share","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"cider_draught_share","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"cigarettes_per_week","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"hand_rolling_tobacco_grams_per_week","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"cigars_grams_per_week","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"other_tobacco_grams_per_week","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"remote_gaming_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"pool_betting_net_receipts","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"bingo_net_receipts","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"national_lottery_ticket_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"land_based_casino_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"machine_games_lower_rate_net_takings","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"machine_games_standard_rate_net_takings","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"machine_games_higher_rate_net_takings","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"land_based_fixed_odds_betting_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"remote_uk_horseracing_betting_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"remote_other_betting_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"betting_exchange_commission","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"horse_and_dog_pool_betting_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"car_fuel_type","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"car_co2_emissions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"car_engine_size","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"car_first_registration_date","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"car_is_ved_exempt","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"lcfs_consumption","stage_contract_sha256":"8b9c6bcea0ced75d344e059daf10b03f010764025326ec0ee713b3774d39c686","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage etb_vat.","id":"etb_vat","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt"],"entity":"person","rows":"all"}],"kernel":"uk.stage.etb_vat@1","mass":"conserve","outputs":[{"column":"full_rate_vat_expenditure_rate","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"etb_vat","stage_contract_sha256":"216b28835eba7a952243134dffbb45a1b3a0cdff2e3e7d0e94e2acbf754052b5","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage etb_services.","id":"etb_services","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt"],"entity":"person","rows":"all"}],"kernel":"uk.stage.etb_services@1","mass":"conserve","outputs":[{"column":"dfe_education_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"rail_subsidy_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"bus_subsidy_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"rail_usage","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"a_and_e_visits","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"admitted_patient_visits","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"outpatient_visits","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"nhs_a_and_e_spending","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"nhs_admitted_patient_spending","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"nhs_outpatient_spending","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"etb_services","stage_contract_sha256":"3a83840f41735987cf9c6d110c6afc31387680d74c03ccab578f03e08de9c36a","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"base":"high_value_home_support","citation":"","description":"Ownership boundary before uc_reporter_redraw rewrites.","id":"uc_reporter_redraw.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_reporter_redraw.","id":"uc_reporter_redraw","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_reporter_redraw@1","mass":"conserve","outputs":[{"column":"universal_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_reporter_redraw","stage_contract_sha256":"1b8f99bd8bc50e3e5dacbb63b75e6b8da0c42c1c8c508c492d078e08ddab0e66","time_period":"2024"},"population":"uc_reporter_redraw.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"uc_reporter_redraw.boundary","citation":"","description":"Ownership boundary before spi_benefit_coherence rewrites.","id":"spi_benefit_coherence.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage spi_benefit_coherence.","id":"spi_benefit_coherence","inputs":[{"columns":["benunit_support_channel","frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_source_id","region"],"entity":"household","rows":"all"},{"columns":["aa_category","age","attendance_allowance_reported","dla_m_category","dla_m_reported","dla_sc_category","dla_sc_reported","employment_income","hours_worked","incapacity_benefit_reported","is_uc_claimant","person_source_id","person_support_channel","pip_dl_category","pip_dl_reported","pip_m_category","pip_m_reported","private_pension_income","self_employment_income","universal_credit_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.spi_benefit_coherence@1","mass":"conserve","outputs":[{"column":"jsa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"income_support_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"working_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"sda_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"ssmg_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"iidb_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"afcs_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"bsp_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"war_widows_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"widowed_parents_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"jsa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_enhanced_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"receives_benefits_in_own_right","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_uc","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"spi_benefit_coherence","stage_contract_sha256":"362a543dce4f0578b11083cef2f2790b1ed3a7a6e539b31c5fdf796e517e8f15","time_period":"2024"},"population":"spi_benefit_coherence.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"spi_benefit_coherence.boundary","citation":"","description":"Ownership boundary before uc_capital_coherence rewrites.","id":"uc_capital_coherence.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_capital_coherence.","id":"uc_capital_coherence","inputs":[{"columns":["benunit_support_channel","dependent_children","is_married"],"entity":"benunit","rows":"all"},{"columns":["non_residential_property_secured_debt","non_residential_property_value","other_residential_property_secured_debt","other_residential_property_value","owned_land","region"],"entity":"household","rows":"all"},{"columns":["age","dividend_income","individual_savings_account_interest_income","is_benunit_head","is_household_head","is_parent","other_investment_income","person_support_channel","savings_interest_income","universal_credit_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_capital_coherence@1","mass":"conserve","outputs":[{"column":"uc_reported_capital","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"pension_credit_reported_capital","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"frs_benunit_capital","dtype":"float64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_uc","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_capital_coherence","stage_contract_sha256":"67478de55540a138448d9da387a64e5e2afbb17caf17b244bc3baaa34de56022","time_period":"2024"},"population":"uc_capital_coherence.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_limited_capability.","id":"uc_limited_capability","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_limited_capability@1","mass":"conserve","outputs":[{"column":"uc_limited_capability_for_WRA","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"uc_limited_capability_for_work","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_limited_capability","stage_contract_sha256":"a8be9ab834fc66961b26395cf93f57103af3d474fe84d778aca85514a632acf2","time_period":"2024"},"population":"uc_capital_coherence.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"uc_capital_coherence.boundary","citation":"","description":"Ownership boundary before uc_take_up rewrites.","id":"uc_take_up.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_take_up.","id":"uc_take_up","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_uc","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_take_up","stage_contract_sha256":"4b30f0c65c98e231edac4c6fbb2767418658674c1975d0e2d5dc7c5b099c8514","time_period":"2024"},"population":"uc_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_legacy_closure_take_up.","id":"uc_legacy_closure_take_up","inputs":[{"columns":["frs_benunit_capital","would_claim_uc"],"entity":"benunit","rows":"all"},{"columns":["household_source_id","region"],"entity":"household","rows":"all"},{"columns":["age","child_tax_credit_reported","esa_income_reported","housing_benefit_reported","income_support_reported","is_claimant_or_partner","jsa_income_reported","universal_credit_reported","working_tax_credit_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_legacy_closure_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_uc_at_legacy_closure","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_legacy_closure_take_up","stage_contract_sha256":"d39bc7366bd2828323ee974b23beb22b732646e2f7b28a4039b5a5f067671ac6","time_period":"2024"},"population":"uc_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"uc_take_up.boundary","citation":"","description":"Ownership boundary before pension_credit_take_up rewrites.","id":"pension_credit_take_up.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage pension_credit_take_up.","id":"pension_credit_take_up","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.stage.pension_credit_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_pc","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"has_mixed_age_couple_pension_credit_saving","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"pension_credit_take_up","stage_contract_sha256":"e887dbbb186cb79f6d3fc9a629269dbac4a43381b9574df65353b816f01a3a35","time_period":"2024"},"population":"pension_credit_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"pension_credit_take_up.boundary","citation":"","description":"Ownership boundary before child_benefit_take_up rewrites.","id":"child_benefit_take_up.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage child_benefit_take_up.","id":"child_benefit_take_up","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.stage.child_benefit_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_child_benefit","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_benefit_opts_out","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"child_benefit_take_up","stage_contract_sha256":"c0a3eb7c406b55909f37485560c8b655eb9b95ed518471e14d4c3647c105239b","time_period":"2024"},"population":"child_benefit_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_deduction_attributes.","id":"uc_deduction_attributes","inputs":[{"columns":["child_benefit_opts_out","frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_deduction_attributes@1","mass":"conserve","outputs":[{"column":"uc_deduction_random_draw","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"uc_deduction_type_random_draw","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"uc_latent_deduction_rate","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"uc_deduction_combination","dtype":"string","entity":"benunit","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_deduction_attributes","stage_contract_sha256":"6bc7e3ec1a5712e23ca1b7d2956e8b17f2526b94431ba3e5a9294b04658e4fe0","time_period":"2024"},"population":"child_benefit_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"child_benefit_take_up.boundary","citation":"","description":"Run structural UK stage cgt_support_split.","id":"cgt_support_split","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.cgt_support_split@1","mass":"conserve","outputs":[],"params":{"expand_cells":[["household","household_is_cgt_support_copy","bool"],["household","cgt_support_copies","int64"],["household","cgt_support_copy_index","int64"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"cgt_support_split","stage_contract_sha256":"401df68fcfc15aa99024e480d197d07d5536d485181abcaad0a148c17b9b3f4c","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by cgt_support_split.","id":"cgt_support_split.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"household_is_cgt_support_copy","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"cgt_support_copies","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"cgt_support_copy_index","dtype":"int64","entity":"household","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["household.household_is_cgt_support_copy","household.cgt_support_copies","household.cgt_support_copy_index"]},"population":"cgt_support_split","sources":[],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"cgt_support_split","citation":"","description":"Run structural UK stage cgt_incidence_clone.","id":"cgt_incidence_clone","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.cgt_incidence_clone@1","mass":"conserve","outputs":[],"params":{"expand_cells":[["household","household_is_capital_gains_clone","bool"],["person","capital_gains","float64"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"cgt_incidence_clone","stage_contract_sha256":"29198953c5522c9b996b981478909916870977a79e9f2feb2db7e9e72ef15de8","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by cgt_incidence_clone.","id":"cgt_incidence_clone.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"household_is_capital_gains_clone","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"capital_gains","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["household.household_is_capital_gains_clone","person.capital_gains"]},"population":"cgt_incidence_clone","sources":[],"structural":"none","weights":null},{"base":"cgt_incidence_clone","citation":"","description":"Ownership boundary before hmrc_cgt_gains_spine rewrites.","id":"hmrc_cgt_gains_spine.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage hmrc_cgt_gains_spine.","id":"hmrc_cgt_gains_spine","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["cgt_support_copies","corporate_wealth","gross_financial_wealth","household_is_cgt_support_copy","non_residential_property_value","other_residential_property_value","region"],"entity":"household","rows":"all"},{"columns":["age","dividend_income","employment_income","individual_savings_account_interest_income","miscellaneous_income","private_pension_income","property_income","savings_interest_income","self_employment_income","state_pension_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.hmrc_cgt_gains_spine@1","mass":"conserve","outputs":[{"column":"capital_gains","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"hmrc_cgt_gains_spine","stage_contract_sha256":"497c3d06f99f108f46d54b8e6144d363005585640da18ac53cee3093fb809279","time_period":"2024"},"population":"hmrc_cgt_gains_spine.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"hmrc_cgt_gains_spine.boundary","citation":"","description":"Run structural UK stage cgt_incidence_anchor.","id":"cgt_incidence_anchor","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_is_capital_gains_clone","region"],"entity":"household","rows":"all"},{"columns":["age","capital_gains","dividend_income","employment_income","individual_savings_account_interest_income","miscellaneous_income","private_pension_income","property_income","savings_interest_income","self_employment_income","state_pension_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.cgt_incidence_anchor@1","mass":"conserve","outputs":[],"params":{"expand_cells":[],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"cgt_incidence_anchor","stage_contract_sha256":"ed54c55428e56d7597c57c8459b014aa43b2ff9495b903f0b789bd5e4264ca9a","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"cgt_incidence_anchor","citation":"","description":"Run structural UK stage cgt_residential_split.","id":"cgt_residential_split","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.cgt_residential_split@1","mass":"conserve","outputs":[],"params":{"expand_cells":[["household","household_is_cgt_residential_clone","bool"],["household","cgt_residential_clone_index","int64"],["person","cgt_residential_probability","float64"],["person","capital_gains_residential_property","float64"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"cgt_residential_split","stage_contract_sha256":"02be930e9900eb352fc29cda472d556ba0a52bd6ded6e81f166aa45f554c6f1a","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by cgt_residential_split.","id":"cgt_residential_split.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"household_is_cgt_residential_clone","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"cgt_residential_clone_index","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"cgt_residential_probability","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"capital_gains_residential_property","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["household.household_is_cgt_residential_clone","household.cgt_residential_clone_index","person.cgt_residential_probability","person.capital_gains_residential_property"]},"population":"cgt_residential_split","sources":[],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage hmrc_cgt_asset_type_spine.","id":"hmrc_cgt_asset_type_spine","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["corporate_wealth","gross_financial_wealth","other_residential_property_value","region","stocks_and_shares_isa"],"entity":"household","rows":"all"},{"columns":["age","capital_gains","capital_gains_residential_property","dividend_income","property_income","reports_rent_from_other_property","self_employment_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.hmrc_cgt_asset_type_spine@1","mass":"conserve","outputs":[{"column":"capital_gains_asset_type","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"capital_gains_badr","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"hmrc_cgt_asset_type_spine","stage_contract_sha256":"465ecb7410a0d0a421505ad48475e78e18115cba66333d300a9d60166f297d3c","time_period":"2024"},"population":"cgt_residential_split","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage salary_sacrifice.","id":"salary_sacrifice","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr"],"entity":"person","rows":"all"}],"kernel":"uk.stage.salary_sacrifice@1","mass":"conserve","outputs":[{"column":"pension_contributions_via_salary_sacrifice","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pension_contributions_via_bonus_sacrifice","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employee_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"salary_sacrifice_pre_conversion_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"salary_sacrifice","stage_contract_sha256":"3335763d91350fa7f938ead181af4659aaca44ac6566b31158ac1284a01d965c","time_period":"2024"},"population":"cgt_residential_split","sources":["frs"],"structural":"none","weights":null},{"base":"cgt_residential_split","citation":"","description":"Ownership boundary before carers_allowance_take_up rewrites.","id":"carers_allowance_take_up.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage carers_allowance_take_up.","id":"carers_allowance_take_up","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay"],"entity":"person","rows":"all"}],"kernel":"uk.stage.carers_allowance_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_carers_allowance","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"carers_allowance_take_up","stage_contract_sha256":"d86f2d3466d641b5064a0ae68942a53ad3cca005eae0080cd0a937b9c4632348","time_period":"2024"},"population":"carers_allowance_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"carers_allowance_take_up.boundary","citation":"","description":"Ownership boundary before student_loans rewrites.","id":"student_loans.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage student_loans.","id":"student_loans","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","age_left_full_time_education","current_education","highest_education","reports_outstanding_student_loan","student_loan_repayments","student_loans","would_claim_carers_allowance"],"entity":"person","rows":"all"}],"kernel":"uk.stage.student_loans@1","mass":"conserve","outputs":[{"column":"student_loan_plan","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"student_loan_balance","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"student_loans","stage_contract_sha256":"507ca0160144d8f5ea1b2483b812658ee8b49854e2388d50a8c59ca58f2ca9ee","time_period":"2024"},"population":"student_loans.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"student_loans.boundary","citation":"","description":"Ownership boundary before childcare_copy_take_up rewrites.","id":"childcare_copy_take_up.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay","student_loan_plan"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage childcare_copy_take_up.","id":"childcare_copy_take_up","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_uc_childcare","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay","student_loan_plan"],"entity":"person","rows":"all"}],"kernel":"uk.stage.childcare_copy_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_tfc","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_extended_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_universal_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_targeted_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"maximum_extended_childcare_hours_usage","dtype":"float64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"max_free_entitlement_hours_used","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"childcare_copy_take_up","stage_contract_sha256":"cdbb7e135b16fac7ca1bcd6c54222821e2976b4da99f10a60913efd0ba03c13c","time_period":"2024"},"population":"childcare_copy_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage private_school_attendance.","id":"private_school_attendance","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay","student_loan_plan"],"entity":"person","rows":"all"}],"kernel":"uk.stage.private_school_attendance@1","mass":"conserve","outputs":[{"column":"attends_private_school","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"private_school_attendance","stage_contract_sha256":"7e44379c0331fe4c9de05cd76a075c1a6aa22cf0dec6cd2f91b277e70f14a038","time_period":"2024"},"population":"childcare_copy_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage isa_subscriptions.","id":"isa_subscriptions","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["cash_isa","region","stocks_and_shares_isa"],"entity":"household","rows":"all"},{"columns":["age","attends_private_school","dividend_income","employment_income","gender","has_lifetime_isa","individual_savings_account_interest_income","lifetime_isa_balance","loss_relief","miscellaneous_income","private_pension_income","property_income","savings_interest_income","self_employment_income","state_pension_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.isa_subscriptions@1","mass":"conserve","outputs":[{"column":"cash_isa_balance","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"stocks_and_shares_isa_balance","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"cash_isa_subscriptions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"stocks_and_shares_isa_subscriptions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"lifetime_isa_payments","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"isa_subscriptions","stage_contract_sha256":"6bdc671fde73a35dcf32e78d492e695d97c1d2f83226108c77d774a91bf61785","time_period":"2024"},"population":"childcare_copy_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage pip_points.","id":"pip_points","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_source_id","region"],"entity":"household","rows":"all"},{"columns":["age","lifetime_isa_payments","pip_dl_category","pip_m_category"],"entity":"person","rows":"all"}],"kernel":"uk.stage.pip_points@1","mass":"conserve","outputs":[{"column":"pip_dl_points","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"pip_m_points","dtype":"int64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"pip_points","stage_contract_sha256":"43f97d6ffe248c3038c31ed9767548c656c0668c6624e9da06b8b28f815f9cfd","time_period":"2024"},"population":"childcare_copy_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage trading_allowance_receipts.","id":"trading_allowance_receipts","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_is_spi_synthetic","household_source_id","region"],"entity":"household","rows":"all"},{"columns":["age","pip_m_points","self_employment_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.trading_allowance_receipts@1","mass":"conserve","outputs":[{"column":"trading_allowance_claim_status","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"trading_allowance_full_relief","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"trading_allowance_receipts","stage_contract_sha256":"50582c6c9e3d5d6300ff8058e3fbc77ce6adf13a487b3c3cf7f674367fcf4d9d","time_period":"2024"},"population":"childcare_copy_take_up.boundary","sources":["frs"],"structural":"none","weights":null}],"sources":[{"codec":"csv-tables","description":"Content-bound UK FRS and donor fixture/source bundle.","name":"frs"}]} +{"country":"uk","nodes":[{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Load the source-bound UK FRS root population.","id":"create_uk_frs","inputs":[],"kernel":"uk.create@1","mass":"conserve","outputs":[{"column":"age","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"gender","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"months_since_last_birthday","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"marital_status","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"hours_worked","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"care_hours","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_care_hours_in_household","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_care_recipients","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"is_household_head","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_benunit_head","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_parent","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_blind","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_uc_claimant","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_claimant_or_partner","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_hbai_dependent_child","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"uc_is_in_startup_period","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_uc_lcw_status","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_uc_carer_element","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"uc_is_in_gainful_self_employment","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"rent_paid_as_boarder","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"rent_paid_as_lodger","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employment_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"self_employment_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"trading_loss","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"loss_relief","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"ni_class_4_losses_brought_forward","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"private_pension_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"annuity_and_trust_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"individual_savings_account_interest_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"savings_interest_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"dividend_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"other_investment_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"stands_as_sole_owner_or_partner_of_company","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_engaged_in_owned_company_trade","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"owned_company_is_main_employment","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"owned_company_carries_on_trade","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"owned_company_carries_on_property_business","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"owned_company_income_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"property_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"reports_rent_from_other_property","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"maintenance_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"spousal_maintenance_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"miscellaneous_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"private_transfer_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"lump_sum_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"student_loan_repayments","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"statutory_sick_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"statutory_maternity_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"statutory_paternity_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"student_loans","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"access_fund","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"education_grants","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"healthy_start_vouchers","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"free_school_breakfasts","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"free_school_fruit_veg","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"free_school_meals","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"council_tax_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"maintenance_expenses","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"childcare_expenses","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"personal_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employee_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"pension_contributions_via_salary_sacrifice","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"salary_sacrifice_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"salary_sacrifice_asked","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_bonus_amount","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_company_car_price_band","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_company_car_fuel_code","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_company_car_private_fuel","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_company_car_contribution","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"child_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"income_support_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"housing_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"attendance_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"dla_sc_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"dla_m_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"iidb_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"carers_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"would_claim_carers_allowance","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"sda_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"afcs_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"ssmg_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"pension_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"child_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"working_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"state_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"winter_fuel_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"incapacity_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"universal_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"pip_m_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"pip_dl_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"jsa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"jsa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"esa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"esa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"esa_includes_support_component","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"bsp_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"war_widows_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"widowed_parents_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"frs_benunit_capital","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"is_married","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"dependent_children","dtype":"int64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"liable_for_share_of_household_rent","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"region","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"tenure_type","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"accommodation_type","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"num_bedrooms","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"council_tax_reported","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"council_tax_band","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"council_tax_rebate","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"council_tax_single_adult_raw","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"water_and_sewerage_charges","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"domestic_rates","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"rent","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"subrent","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"mortgage_interest_repayment","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"mortgage_capital_repayment","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"structural_insurance_payments","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"housing_service_charges","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"external_child_payments","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"sample_fraction":1.0,"sample_seed":578,"stage_contract_sha256":"98ca74949e07fcf0f858bc88f882f2a196c6bf6f768b0002d2d8d1ce40ce56cb","time_period":"2024"},"population":null,"sources":["frs"],"structural":"create","weights":null},{"base":"create_uk_frs","citation":"","description":"Ownership boundary for the source-assembling root stage.","id":"frs_spine.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"base":null,"citation":"","description":"Claim the cells assembled by the UK FRS root transform.","id":"frs_spine","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"age","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"gender","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"months_since_last_birthday","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"marital_status","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hours_worked","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"care_hours","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_care_hours_in_household","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_care_recipients","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_household_head","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_benunit_head","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_parent","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_blind","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_uc_claimant","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_claimant_or_partner","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_hbai_dependent_child","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"uc_is_in_startup_period","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_uc_lcw_status","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_uc_carer_element","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"uc_is_in_gainful_self_employment","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"rent_paid_as_boarder","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"rent_paid_as_lodger","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"self_employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"trading_loss","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"loss_relief","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"ni_class_4_losses_brought_forward","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"private_pension_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"annuity_and_trust_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"individual_savings_account_interest_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"savings_interest_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dividend_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"other_investment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"stands_as_sole_owner_or_partner_of_company","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_engaged_in_owned_company_trade","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_is_main_employment","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_carries_on_trade","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_carries_on_property_business","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_income_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"reports_rent_from_other_property","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"maintenance_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"spousal_maintenance_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"miscellaneous_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"private_transfer_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"lump_sum_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"student_loan_repayments","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"statutory_sick_pay","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"statutory_maternity_pay","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"statutory_paternity_pay","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"student_loans","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"access_fund","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"education_grants","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"healthy_start_vouchers","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"free_school_breakfasts","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"free_school_fruit_veg","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"free_school_meals","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"maintenance_expenses","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"childcare_expenses","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"personal_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employee_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pension_contributions_via_salary_sacrifice","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"salary_sacrifice_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"salary_sacrifice_asked","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_bonus_amount","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_company_car_price_band","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_company_car_fuel_code","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_company_car_private_fuel","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_company_car_contribution","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"income_support_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"housing_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"attendance_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_sc_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_m_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"iidb_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"carers_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_carers_allowance","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"sda_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"afcs_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"ssmg_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pension_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"working_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"state_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"winter_fuel_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"incapacity_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"universal_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_m_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_dl_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"jsa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"jsa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_includes_support_component","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"bsp_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"war_widows_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"widowed_parents_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"frs_benunit_capital","dtype":"float64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_married","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dependent_children","dtype":"int64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"liable_for_share_of_household_rent","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"region","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"tenure_type","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"accommodation_type","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"num_bedrooms","dtype":"int64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_reported","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_band","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_rebate","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_single_adult_raw","dtype":"int64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"water_and_sewerage_charges","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"domestic_rates","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"rent","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"subrent","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"mortgage_interest_repayment","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"mortgage_capital_repayment","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"structural_insurance_payments","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"housing_service_charges","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"external_child_payments","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"}],"params":{},"population":"frs_spine.boundary","sources":[],"structural":"none","weights":null},{"base":"frs_spine.boundary","citation":"","description":"Ownership boundary before age_tail rewrites.","id":"age_tail.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage age_tail.","id":"age_tail","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["external_child_payments","region"],"entity":"household","rows":"all"},{"columns":["gender"],"entity":"person","rows":"all"}],"kernel":"uk.stage.age_tail@1","mass":"conserve","outputs":[{"column":"age","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"age_tail","stage_contract_sha256":"963a34f38caede2525e3b8735f904bb70a1bbef5a272f0eefd4346343444484f","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_relationships.","id":"frs_relationships","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","is_household_head"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_relationships@1","mass":"conserve","outputs":[{"column":"relationship_to_head","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"ons_family_role","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"ons_family_index","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"is_looked_after_by_local_authority","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"child_limit_non_parental_caring_exception","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"ons_household_type","dtype":"string","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_relationships","stage_contract_sha256":"ae32bf855753d3b7505e54a18532b1b53a04b6beda764cc09ad09462cf130085","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_employment.","id":"frs_employment","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["ons_household_type","region"],"entity":"household","rows":"all"},{"columns":["age"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_employment@1","mass":"conserve","outputs":[{"column":"employment_status","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"employment_sector","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"sic_industry_division","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"soc2020_major_group","dtype":"string","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_employment","stage_contract_sha256":"c4dc3da7179c7b7d6eb67c6f119df1f213e50ee6b83a53660d317126a5773027","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_council_tax.","id":"frs_council_tax","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","soc2020_major_group"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_council_tax@1","mass":"conserve","outputs":[{"column":"council_tax","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_council_tax","stage_contract_sha256":"2523bdaed96ad432bc3f6bca68ed5edcf8f0a44d66bf3f04a3afa9fa30e3987b","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_disability.","id":"frs_disability","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["council_tax","region"],"entity":"household","rows":"all"},{"columns":["afcs_reported","age","attendance_allowance_reported","care_hours","carers_allowance_reported","dla_m_reported","dla_sc_reported","esa_contrib_reported","esa_income_reported","frs_care_recipients","frs_uc_carer_element","iidb_reported","incapacity_benefit_reported","is_claimant_or_partner","pip_dl_reported","pip_m_reported","sda_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_disability@1","mass":"conserve","outputs":[{"column":"aa_category","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"dla_sc_category","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"dla_m_category","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"pip_m_category","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"pip_dl_category","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"is_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_enhanced_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"cares_for_severely_disabled_person","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_disability","stage_contract_sha256":"5a89f3cfa318efe309329371bcaf438a2a44d86428d5f2839370439629686cb9","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_education.","id":"frs_education","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","cares_for_severely_disabled_person","esa_contrib_reported","esa_income_reported","jsa_contrib_reported","jsa_income_reported","universal_credit_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_education@1","mass":"conserve","outputs":[{"column":"current_education","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"highest_education","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"is_in_non_advanced_education","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"is_in_approved_training","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"age_started_or_accepted_current_education_or_training","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"is_before_universal_credit_qualifying_young_person_terminal_date","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"adult_ema","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"child_ema","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"receives_benefits_in_own_right","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"reports_outstanding_student_loan","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"age_left_full_time_education","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"is_in_full_time_education","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_education","stage_contract_sha256":"17f97af529c76e807f709af26a4bd1dd11e103c0f885048a73c18e28b94b9b54","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_legacy_proxies.","id":"frs_legacy_proxies","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_legacy_proxies@1","mass":"conserve","outputs":[{"column":"legacy_jobseeker_proxy","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"esa_health_condition_proxy","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"esa_support_group_proxy","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_legacy_proxies","stage_contract_sha256":"1ecf761cf3fa7180da15659e138e67a8654e58272b4fde28344aa27a874ad0aa","time_period":"2024"},"population":"age_tail.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"age_tail.boundary","citation":"","description":"Ownership boundary before frs_education_grant_split rewrites.","id":"frs_education_grant_split.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_education_grant_split.","id":"frs_education_grant_split","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_education_grant_split@1","mass":"conserve","outputs":[{"column":"disabled_students_allowance_eligible_expenses","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"education_grants","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_education_grant_split","stage_contract_sha256":"8718f014b90498c2cc7c754289775ca4a41452d9b978d8cbc5f34b64cbdc7df2","time_period":"2024"},"population":"frs_education_grant_split.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_take_up.","id":"frs_take_up","inputs":[{"columns":["frs_benunit_capital","is_married"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","child_benefit_reported","education_grants","is_uc_claimant","months_since_last_birthday","pension_credit_reported","universal_credit_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_child_benefit","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"child_benefit_opts_out","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_pc","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_uc","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_tfc","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_extended_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_universal_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_targeted_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"would_claim_uc_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"},{"column":"maximum_extended_childcare_hours_usage","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"max_free_entitlement_hours_used","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_take_up","stage_contract_sha256":"78aec80408c50455b37308e5a977fb70df3ecf915d6c1e8f80715ad9b58e62cf","time_period":"2024"},"population":"frs_education_grant_split.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_person_draws.","id":"frs_person_draws","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","employment_income","employment_status","is_in_full_time_education","max_free_entitlement_hours_used"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_person_draws@1","mass":"conserve","outputs":[{"column":"would_claim_marriage_allowance","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"would_claim_scp","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"attends_private_school_random_draw","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"tax_free_childcare_spend_routed_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"is_apprentice","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_person_draws","stage_contract_sha256":"5bd9c080af0e151afc10462fed72d491bad50e2516f0067654cb06680f4329ae","time_period":"2024"},"population":"frs_education_grant_split.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_household_draws.","id":"frs_household_draws","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","is_apprentice"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_household_draws@1","mass":"conserve","outputs":[{"column":"household_owns_tv","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"would_evade_tv_licence_fee","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"main_residential_property_purchased_is_first_home","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"property_purchased","dtype":"bool","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_household_draws","stage_contract_sha256":"c74c63b09264319c4bf0049dabba00ecd0ce660beb7b53d6dae71518434bc949","time_period":"2024"},"population":"frs_education_grant_split.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_brma.","id":"frs_brma","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_brma@1","mass":"conserve","outputs":[{"column":"brma","dtype":"string","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_brma","stage_contract_sha256":"4285376b37299d375ed583b7f6b1747bd8b7cb1c8c0d19a36481156b5314a854","time_period":"2024"},"population":"frs_education_grant_split.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"frs_education_grant_split.boundary","citation":"","description":"Freeze the assembled-spine gate population.","id":"frs_brma.checkpoint","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_hmrc_spine_leaves.","id":"frs_hmrc_spine_leaves","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["brma","region"],"entity":"household","rows":"all"},{"columns":["age","employment_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_hmrc_spine_leaves@1","mass":"conserve","outputs":[{"column":"hmrc_spi_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_unemployment_benefit_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_incapacity_benefit_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"ossben_identifiable_subset","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"srp_regular_code5","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employer_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_hmrc_spine_leaves","stage_contract_sha256":"cb0552c10c46b3045be3f92cffa062fc7d1d55353da648b155e0513264c7a2ff","time_period":"2024"},"population":"frs_brma.checkpoint","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage frs_annual_income_spells.","id":"frs_annual_income_spells","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","employer_pension_contributions","employment_income","gender","self_employment_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.frs_annual_income_spells@1","mass":"conserve","outputs":[{"column":"employment_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employment_income_other_spells","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"self_employment_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"self_employment_income_other_spells","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"private_pension_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"contributory_benefits_annual_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"frs_annual_income_spells","stage_contract_sha256":"c5f170931bf33d9e490c8b79c176994f0b6a01582ddecebde665745bc5d859a9","time_period":"2024"},"population":"frs_brma.checkpoint","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"frs_brma.checkpoint","citation":"","description":"Run structural UK stage spi_support_channel.","id":"spi_support_channel","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.spi_support_channel@1","mass":"declared","outputs":[],"params":{"expand_cells":[["person","person_source_id","int64"],["person","person_support_channel","string"],["person","person_support_clone_index","int64"],["benunit","benunit_source_id","int64"],["benunit","benunit_support_channel","string"],["benunit","benunit_support_clone_index","int64"],["household","source_household_id","int64"],["household","source_year","int64"],["household","source_household_key","string"],["household","household_source_id","int64"],["household","household_support_channel","string"],["household","household_support_clone_index","int64"],["household","household_is_spi_synthetic","bool"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"spi_support_channel","stage_contract_sha256":"2c682605139c0a8f96e8ba45a2c03f506d3f758ef437841066a8fdb8b74269b6","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by spi_support_channel.","id":"spi_support_channel.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"person_source_id","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"person_support_channel","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"person_support_clone_index","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"benunit_source_id","dtype":"int64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"benunit_support_channel","dtype":"string","entity":"benunit","ownership":"produced","rows":"all"},{"column":"benunit_support_clone_index","dtype":"int64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"source_household_id","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"source_year","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"source_household_key","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"household_source_id","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"household_support_channel","dtype":"string","entity":"household","ownership":"produced","rows":"all"},{"column":"household_support_clone_index","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"household_is_spi_synthetic","dtype":"bool","entity":"household","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["person.person_source_id","person.person_support_channel","person.person_support_clone_index","benunit.benunit_source_id","benunit.benunit_support_channel","benunit.benunit_support_clone_index","household.source_household_id","household.source_year","household.source_household_key","household.household_source_id","household.household_support_channel","household.household_support_clone_index","household.household_is_spi_synthetic"]},"population":"spi_support_channel","sources":[],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"spi_support_channel","citation":"","description":"Run structural UK stage spi_income_band_donors.","id":"spi_income_band_donors","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.spi_income_band_donors@1","mass":"declared","outputs":[],"params":{"expand_cells":[["person","person_source_id","int64"],["person","person_support_channel","string"],["person","person_support_clone_index","int64"],["benunit","benunit_source_id","int64"],["benunit","benunit_support_channel","string"],["benunit","benunit_support_clone_index","int64"],["household","household_source_id","int64"],["household","household_support_channel","string"],["household","household_support_clone_index","int64"],["household","household_is_spi_synthetic","bool"],["household","household_is_spi_income_band_donor","bool"],["household","spi_income_band_donor_lower_bound","float64"],["person","person_is_spi_income_band_carrier","bool"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"spi_income_band_donors","stage_contract_sha256":"fea5354cec3ac0f6289018fc79d0d1ebc971870205ecf9c710df7a7312db21c7","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by spi_income_band_donors.","id":"spi_income_band_donors.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"person_source_id","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"person_support_channel","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"person_support_clone_index","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"benunit_source_id","dtype":"int64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"benunit_support_channel","dtype":"string","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"benunit_support_clone_index","dtype":"int64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"household_source_id","dtype":"int64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"household_support_channel","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"household_support_clone_index","dtype":"int64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"household_is_spi_synthetic","dtype":"bool","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"household_is_spi_income_band_donor","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"spi_income_band_donor_lower_bound","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"person_is_spi_income_band_carrier","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["household.household_is_spi_income_band_donor","household.spi_income_band_donor_lower_bound","person.person_is_spi_income_band_carrier"]},"population":"spi_income_band_donors","sources":[],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage hmrc_spi_income_spine.","id":"hmrc_spi_income_spine","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","frs_uc_lcw_status","frs_uc_carer_element","rent_paid_as_boarder","rent_paid_as_lodger","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","maintenance_expenses","childcare_expenses","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","ssmg_reported","incapacity_benefit_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","ossben_identifiable_subset","srp_regular_code5","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier"],"entity":"person","rows":"all"}],"kernel":"uk.stage.hmrc_spi_income_spine@1","mass":"conserve","outputs":[{"column":"charitable_investment_gifts","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"gift_aid","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"other_investment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_employment_benefits","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_employment_expenses","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_other_social_security_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_taxable_termination_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_miscellaneous_employment_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_other_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_state_pension_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"property_finance_costs","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_employed_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_total_earned_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_total_investment_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"hmrc_spi_assessable_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"self_employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"savings_interest_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dividend_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"private_pension_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employee_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employer_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"personal_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pension_contributions_via_salary_sacrifice","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"individual_savings_account_interest_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"universal_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pension_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"housing_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"income_support_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"working_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"attendance_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"state_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_sc_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_m_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_m_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_dl_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"sda_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"carers_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"iidb_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"afcs_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"bsp_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"war_widows_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"widowed_parents_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"winter_fuel_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"jsa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"jsa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"trading_loss","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"loss_relief","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"ni_class_4_losses_brought_forward","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_income_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_pay","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_unemployment_benefit_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_incapacity_benefit_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employment_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employment_income_other_spells","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"self_employment_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"self_employment_income_other_spells","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"private_pension_income_annual_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"contributory_benefits_annual_share","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"annuity_and_trust_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"aa_category","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_sc_category","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"dla_m_category","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_m_category","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pip_dl_category","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_enhanced_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_carers_allowance","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"uc_is_in_startup_period","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"uc_is_in_gainful_self_employment","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_includes_support_component","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"reports_rent_from_other_property","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"stands_as_sole_owner_or_partner_of_company","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_engaged_in_owned_company_trade","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_is_main_employment","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_carries_on_trade","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_company_carries_on_property_business","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"cares_for_severely_disabled_person","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"person_is_spi_income_recipient","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"hmrc_spi_income_spine","stage_contract_sha256":"88e459e60ca51cb5e53fd2335ad6db1736241125484024834c28b56feef28496","time_period":"2024"},"population":"spi_income_band_donors","sources":["frs"],"structural":"none","weights":null},{"base":"spi_income_band_donors","citation":"","description":"Ownership boundary before company_cars rewrites.","id":"company_cars.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage company_cars.","id":"company_cars","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","rent_paid_as_boarder","rent_paid_as_lodger","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient"],"entity":"person","rows":"all"}],"kernel":"uk.stage.company_cars@1","mass":"conserve","outputs":[{"column":"company_car_list_price","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"company_car_co2_emissions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"company_car_fuel_type","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"company_car_electric_range","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"company_car_capital_contributions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"company_car_private_fuel_provided","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"uc_is_in_gainful_self_employment","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_pay","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"hmrc_spi_employment_benefits","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"company_cars","stage_contract_sha256":"13dd8d3f30efbd1d67227442ffd4547b69225e0f89b0f6b7f305b786c25172a8","time_period":"2024"},"population":"company_cars.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"company_cars.boundary","citation":"","description":"Ownership boundary before spi_employment_shell rewrites.","id":"spi_employment_shell.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage spi_employment_shell.","id":"spi_employment_shell","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_support_channel","household_support_clone_index","region","source_household_id"],"entity":"household","rows":"all"},{"columns":["age","dividend_income","employment_income","employment_status","gender","hmrc_spi_employment_benefits","hmrc_spi_pay","person_is_spi_income_recipient","private_pension_income","savings_interest_income","self_employment_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.spi_employment_shell@1","mass":"conserve","outputs":[{"column":"soc2020_major_group","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"sic_industry_division","dtype":"int64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employment_sector","dtype":"string","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"spi_employment_shell","stage_contract_sha256":"4612c78bf72a36c34a6be652d15d1348fe3d99c873fa8d5821978816b59d1618","time_period":"2024"},"population":"spi_employment_shell.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage aps_occupation.","id":"aps_occupation","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_support_channel","region","source_household_id"],"entity":"household","rows":"all"},{"columns":["age","employment_income","employment_sector","employment_status","gender","hmrc_spi_pay","person_is_spi_income_recipient","person_source_id","sic_industry_division","soc2020_major_group"],"entity":"person","rows":"all"}],"kernel":"uk.stage.aps_occupation@1","mass":"conserve","outputs":[{"column":"soc2020_sub_major_group","dtype":"string","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"aps_occupation","stage_contract_sha256":"644102f010870dccd28f8b980cbc5f648b7ff8ed140a0a5d9f23f02ada7f3d6d","time_period":"2024"},"population":"spi_employment_shell.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"spi_employment_shell.boundary","citation":"","description":"Ownership boundary before spi_housing_shell rewrites.","id":"spi_housing_shell.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage spi_housing_shell.","id":"spi_housing_shell","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["council_tax_single_adult_raw","household_support_channel","household_support_clone_index","ons_household_type","region","source_household_id"],"entity":"household","rows":"all"},{"columns":["age","dividend_income","employment_income","individual_savings_account_interest_income","is_household_head","other_investment_income","private_pension_income","property_income","savings_interest_income","self_employment_income","soc2020_sub_major_group","state_pension_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.spi_housing_shell@1","mass":"conserve","outputs":[{"column":"tenure_type","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"accommodation_type","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_band","dtype":"string","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"num_bedrooms","dtype":"int64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_reported","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"rent","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"mortgage_interest_repayment","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"mortgage_capital_repayment","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"structural_insurance_payments","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"housing_service_charges","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"water_and_sewerage_charges","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"domestic_rates","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"subrent","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_rebate","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"housing_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"council_tax_benefit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"spi_housing_shell","stage_contract_sha256":"9a76a02ceddb2cd85819f57cd33feb44d645800ce963d0b18bad0f6de808fd81","time_period":"2024"},"population":"spi_housing_shell.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage was_wealth.","id":"was_wealth","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group"],"entity":"person","rows":"all"}],"kernel":"uk.stage.was_wealth@1","mass":"conserve","outputs":[{"column":"owned_land","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"property_wealth","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"corporate_wealth","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"private_pension_wealth","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"gross_financial_wealth","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"net_financial_wealth","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"main_residence_value","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"other_residential_property_value","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"non_residential_property_value","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"savings","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"num_vehicles","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"cash_isa","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"stocks_and_shares_isa","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"mortgage_debt","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"consumer_debt","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"student_loan_balance","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"directly_held_shares","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"unit_and_investment_trusts","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"other_residential_property_secured_debt","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"non_residential_property_secured_debt","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"was_wealth","stage_contract_sha256":"4c0bcaabf3695a75ec7e69d99b6b8c90570fd345067d77f1ea315f5508a88962","time_period":"2024"},"population":"spi_housing_shell.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage was_lisa.","id":"was_lisa","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance"],"entity":"person","rows":"all"}],"kernel":"uk.stage.was_lisa@1","mass":"conserve","outputs":[{"column":"has_lifetime_isa","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"lifetime_isa_balance","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"household_lifetime_isa_balance","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"was_lisa","stage_contract_sha256":"6f9a9dc796a43487e520910c6e50561e9394323c83934923321741018648c661","time_period":"2024"},"population":"spi_housing_shell.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"spi_housing_shell.boundary","citation":"","description":"Ownership boundary before regional_property_uprating rewrites.","id":"regional_property_uprating.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage regional_property_uprating.","id":"regional_property_uprating","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_lifetime_isa_balance","household_support_channel","region"],"entity":"household","rows":"all"},{"columns":["age"],"entity":"person","rows":"all"}],"kernel":"uk.stage.regional_property_uprating@1","mass":"conserve","outputs":[{"column":"main_residence_value","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_wealth","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"owned_land","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"other_residential_property_value","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"non_residential_property_value","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"regional_property_uprating","stage_contract_sha256":"f45db95fde3f93731c0925b9bf8c12021921df2e4908770acdec1e3c97889277","time_period":"2024"},"population":"regional_property_uprating.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"regional_property_uprating.boundary","citation":"","description":"Run structural UK stage high_value_home_support.","id":"high_value_home_support","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.high_value_home_support@1","mass":"conserve","outputs":[],"params":{"expand_cells":[["household","household_is_high_value_support_copy","bool"],["household","high_value_support_copies","int64"],["household","high_value_support_copy_index","int64"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"high_value_home_support","stage_contract_sha256":"174f4b38228d98107bee1639d1a297a2748bb618e87c7bd0a6c869c6ab06f8fa","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by high_value_home_support.","id":"high_value_home_support.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"household_is_high_value_support_copy","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"high_value_support_copies","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"high_value_support_copy_index","dtype":"int64","entity":"household","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["household.household_is_high_value_support_copy","household.high_value_support_copies","household.high_value_support_copy_index"]},"population":"high_value_home_support","sources":[],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage regional_home_values.","id":"regional_home_values","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["high_value_support_copy_index","household_is_high_value_support_copy","region","source_household_id","tenure_type"],"entity":"household","rows":"all"},{"columns":["age"],"entity":"person","rows":"all"}],"kernel":"uk.stage.regional_home_values@1","mass":"conserve","outputs":[{"column":"main_residence_value","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_wealth","dtype":"float64","entity":"household","ownership":"produced","rewrite":true,"rows":"all"},{"column":"main_residence_value_rank_basis","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"regional_home_values","stage_contract_sha256":"d1c8f12081507e28a2a4b532961b4996577ea972b78e30b39a61f41a7d35046c","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage property_components.","id":"property_components","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["main_residence_value_rank_basis","non_residential_property_value","other_residential_property_value","region","subrent"],"entity":"household","rows":"all"},{"columns":["age","is_household_head","person_is_spi_income_recipient","person_support_channel"],"entity":"person","rows":"all"}],"kernel":"uk.stage.property_components@1","mass":"conserve","outputs":[{"column":"property_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_finance_costs","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"property_rental_income","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"property_components","stage_contract_sha256":"23cc497627946fde4875c27b5ed2cf94a9cb89d7bd64025c1f34f1ac3b9baaf6","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage property_purchases.","id":"property_purchases","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["non_residential_property_value","other_residential_property_value","region","source_household_id"],"entity":"household","rows":"all"},{"columns":["age","property_rental_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.property_purchases@1","mass":"conserve","outputs":[{"column":"additional_residential_property_purchased","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"non_residential_property_purchased","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"property_purchases","stage_contract_sha256":"cfe459095fbb1cdeb95596442291d0405d99de1bc544a2ee27b3b49f841be940","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage nts_bus_travel.","id":"nts_bus_travel","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.nts_bus_travel@1","mass":"conserve","outputs":[{"column":"local_bus_use_band","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"bus_in_london_trips","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"other_local_bus_trips","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"local_bus_trips","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"bus_pass_eligible","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"local_bus_single_fare_share","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"household_local_bus_trips","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"nts_bus_travel","stage_contract_sha256":"6753039b8ce02c6e4bed6f6b00d52c8c2a38e9b9a5f19eb3821625767f4667c6","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage lcfs_consumption.","id":"lcfs_consumption","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share"],"entity":"person","rows":"all"}],"kernel":"uk.stage.lcfs_consumption@1","mass":"conserve","outputs":[{"column":"food_and_non_alcoholic_beverages_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"alcohol_and_tobacco_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"clothing_and_footwear_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"housing_water_and_electricity_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"household_furnishings_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"health_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"transport_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"communication_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"recreation_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"education_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"restaurants_and_hotels_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"miscellaneous_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"petrol_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"diesel_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"bus_fare_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"domestic_energy_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"electricity_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"gas_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"liquid_fuel_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"solid_fuel_consumption","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"has_fuel_consumption","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"uses_energy_prepayment_meter","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"electricity_kwh","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"gas_kwh","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"beer_litres","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"cider_litres","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"wine_litres","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"spirits_litres","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"other_fermented_litres","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"beer_draught_share","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"cider_draught_share","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"cigarettes_per_week","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"hand_rolling_tobacco_grams_per_week","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"cigars_grams_per_week","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"other_tobacco_grams_per_week","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"remote_gaming_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"pool_betting_net_receipts","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"bingo_net_receipts","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"national_lottery_ticket_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"land_based_casino_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"machine_games_lower_rate_net_takings","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"machine_games_standard_rate_net_takings","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"machine_games_higher_rate_net_takings","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"land_based_fixed_odds_betting_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"remote_uk_horseracing_betting_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"remote_other_betting_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"betting_exchange_commission","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"horse_and_dog_pool_betting_net_losses","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"car_fuel_type","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"car_co2_emissions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"car_engine_size","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"car_first_registration_date","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"car_is_ved_exempt","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"lcfs_consumption","stage_contract_sha256":"8b9c6bcea0ced75d344e059daf10b03f010764025326ec0ee713b3774d39c686","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage etb_vat.","id":"etb_vat","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt"],"entity":"person","rows":"all"}],"kernel":"uk.stage.etb_vat@1","mass":"conserve","outputs":[{"column":"full_rate_vat_expenditure_rate","dtype":"float64","entity":"household","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"etb_vat","stage_contract_sha256":"216b28835eba7a952243134dffbb45a1b3a0cdff2e3e7d0e94e2acbf754052b5","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage etb_services.","id":"etb_services","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt"],"entity":"person","rows":"all"}],"kernel":"uk.stage.etb_services@1","mass":"conserve","outputs":[{"column":"dfe_education_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"rail_subsidy_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"bus_subsidy_spending","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"rail_usage","dtype":"float64","entity":"household","ownership":"produced","rows":"all"},{"column":"a_and_e_visits","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"admitted_patient_visits","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"outpatient_visits","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"nhs_a_and_e_spending","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"nhs_admitted_patient_spending","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"nhs_outpatient_spending","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"etb_services","stage_contract_sha256":"3a83840f41735987cf9c6d110c6afc31387680d74c03ccab578f03e08de9c36a","time_period":"2024"},"population":"high_value_home_support","sources":["frs"],"structural":"none","weights":null},{"base":"high_value_home_support","citation":"","description":"Ownership boundary before uc_reporter_redraw rewrites.","id":"uc_reporter_redraw.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_reporter_redraw.","id":"uc_reporter_redraw","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_reporter_redraw@1","mass":"conserve","outputs":[{"column":"universal_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_reporter_redraw","stage_contract_sha256":"1b8f99bd8bc50e3e5dacbb63b75e6b8da0c42c1c8c508c492d078e08ddab0e66","time_period":"2024"},"population":"uc_reporter_redraw.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"uc_reporter_redraw.boundary","citation":"","description":"Ownership boundary before spi_benefit_coherence rewrites.","id":"spi_benefit_coherence.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage spi_benefit_coherence.","id":"spi_benefit_coherence","inputs":[{"columns":["benunit_support_channel","frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region","source_household_id"],"entity":"household","rows":"all"},{"columns":["aa_category","age","attendance_allowance_reported","dla_m_category","dla_m_reported","dla_sc_category","dla_sc_reported","employment_income","hours_worked","incapacity_benefit_reported","is_uc_claimant","person_source_id","person_support_channel","pip_dl_category","pip_dl_reported","pip_m_category","pip_m_reported","private_pension_income","self_employment_income","universal_credit_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.spi_benefit_coherence@1","mass":"conserve","outputs":[{"column":"jsa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_income_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"income_support_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"working_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_tax_credit_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"sda_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"ssmg_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"iidb_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"afcs_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"bsp_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"war_widows_pension_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"widowed_parents_allowance_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"jsa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"esa_contrib_reported","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"is_enhanced_disabled_for_benefits","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"receives_benefits_in_own_right","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_uc","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"spi_benefit_coherence","stage_contract_sha256":"362a543dce4f0578b11083cef2f2790b1ed3a7a6e539b31c5fdf796e517e8f15","time_period":"2024"},"population":"spi_benefit_coherence.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"spi_benefit_coherence.boundary","citation":"","description":"Ownership boundary before uc_capital_coherence rewrites.","id":"uc_capital_coherence.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_capital_coherence.","id":"uc_capital_coherence","inputs":[{"columns":["benunit_support_channel","dependent_children","is_married"],"entity":"benunit","rows":"all"},{"columns":["high_value_support_copy_index","household_is_high_value_support_copy","household_support_channel","household_support_clone_index","non_residential_property_secured_debt","non_residential_property_value","other_residential_property_secured_debt","other_residential_property_value","owned_land","region","source_household_id"],"entity":"household","rows":"all"},{"columns":["age","dividend_income","individual_savings_account_interest_income","is_benunit_head","is_household_head","is_parent","other_investment_income","person_support_channel","savings_interest_income","universal_credit_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_capital_coherence@1","mass":"conserve","outputs":[{"column":"uc_reported_capital","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"pension_credit_reported_capital","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"frs_benunit_capital","dtype":"float64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_uc","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_capital_coherence","stage_contract_sha256":"67478de55540a138448d9da387a64e5e2afbb17caf17b244bc3baaa34de56022","time_period":"2024"},"population":"uc_capital_coherence.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_limited_capability.","id":"uc_limited_capability","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_limited_capability@1","mass":"conserve","outputs":[{"column":"uc_limited_capability_for_WRA","dtype":"bool","entity":"person","ownership":"produced","rows":"all"},{"column":"uc_limited_capability_for_work","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_limited_capability","stage_contract_sha256":"a8be9ab834fc66961b26395cf93f57103af3d474fe84d778aca85514a632acf2","time_period":"2024"},"population":"uc_capital_coherence.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"uc_capital_coherence.boundary","citation":"","description":"Ownership boundary before uc_take_up rewrites.","id":"uc_take_up.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_take_up.","id":"uc_take_up","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_uc","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_take_up","stage_contract_sha256":"76f1ec765c8fa7b0bd9dbf01784e528e8a51bc19e0b75d7a9f09d047badc5dd9","time_period":"2024"},"population":"uc_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_legacy_closure_take_up.","id":"uc_legacy_closure_take_up","inputs":[{"columns":["frs_benunit_capital","would_claim_uc"],"entity":"benunit","rows":"all"},{"columns":["region","source_household_id"],"entity":"household","rows":"all"},{"columns":["age","child_tax_credit_reported","esa_income_reported","housing_benefit_reported","income_support_reported","is_claimant_or_partner","jsa_income_reported","universal_credit_reported","working_tax_credit_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_legacy_closure_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_uc_at_legacy_closure","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_legacy_closure_take_up","stage_contract_sha256":"d39bc7366bd2828323ee974b23beb22b732646e2f7b28a4039b5a5f067671ac6","time_period":"2024"},"population":"uc_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"uc_take_up.boundary","citation":"","description":"Ownership boundary before pension_credit_take_up rewrites.","id":"pension_credit_take_up.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage pension_credit_take_up.","id":"pension_credit_take_up","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.stage.pension_credit_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_pc","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"has_mixed_age_couple_pension_credit_saving","dtype":"bool","entity":"benunit","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"pension_credit_take_up","stage_contract_sha256":"e887dbbb186cb79f6d3fc9a629269dbac4a43381b9574df65353b816f01a3a35","time_period":"2024"},"population":"pension_credit_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"pension_credit_take_up.boundary","citation":"","description":"Ownership boundary before child_benefit_take_up rewrites.","id":"child_benefit_take_up.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage child_benefit_take_up.","id":"child_benefit_take_up","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.stage.child_benefit_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_child_benefit","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"child_benefit_opts_out","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"child_benefit_take_up","stage_contract_sha256":"c0a3eb7c406b55909f37485560c8b655eb9b95ed518471e14d4c3647c105239b","time_period":"2024"},"population":"child_benefit_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage uc_deduction_attributes.","id":"uc_deduction_attributes","inputs":[{"columns":["child_benefit_opts_out","frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age"],"entity":"person","rows":"all"}],"kernel":"uk.stage.uc_deduction_attributes@1","mass":"conserve","outputs":[{"column":"uc_deduction_random_draw","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"uc_deduction_type_random_draw","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"uc_latent_deduction_rate","dtype":"float64","entity":"benunit","ownership":"produced","rows":"all"},{"column":"uc_deduction_combination","dtype":"string","entity":"benunit","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"uc_deduction_attributes","stage_contract_sha256":"6bc7e3ec1a5712e23ca1b7d2956e8b17f2526b94431ba3e5a9294b04658e4fe0","time_period":"2024"},"population":"child_benefit_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"child_benefit_take_up.boundary","citation":"","description":"Run structural UK stage cgt_support_split.","id":"cgt_support_split","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.cgt_support_split@1","mass":"conserve","outputs":[],"params":{"expand_cells":[["household","household_is_cgt_support_copy","bool"],["household","cgt_support_copies","int64"],["household","cgt_support_copy_index","int64"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"cgt_support_split","stage_contract_sha256":"401df68fcfc15aa99024e480d197d07d5536d485181abcaad0a148c17b9b3f4c","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by cgt_support_split.","id":"cgt_support_split.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"household_is_cgt_support_copy","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"cgt_support_copies","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"cgt_support_copy_index","dtype":"int64","entity":"household","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["household.household_is_cgt_support_copy","household.cgt_support_copies","household.cgt_support_copy_index"]},"population":"cgt_support_split","sources":[],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"cgt_support_split","citation":"","description":"Run structural UK stage cgt_incidence_clone.","id":"cgt_incidence_clone","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.cgt_incidence_clone@1","mass":"conserve","outputs":[],"params":{"expand_cells":[["household","household_is_capital_gains_clone","bool"],["person","capital_gains","float64"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"cgt_incidence_clone","stage_contract_sha256":"29198953c5522c9b996b981478909916870977a79e9f2feb2db7e9e72ef15de8","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by cgt_incidence_clone.","id":"cgt_incidence_clone.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"household_is_capital_gains_clone","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"capital_gains","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["household.household_is_capital_gains_clone","person.capital_gains"]},"population":"cgt_incidence_clone","sources":[],"structural":"none","weights":null},{"base":"cgt_incidence_clone","citation":"","description":"Ownership boundary before hmrc_cgt_gains_spine rewrites.","id":"hmrc_cgt_gains_spine.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage hmrc_cgt_gains_spine.","id":"hmrc_cgt_gains_spine","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["cgt_support_copies","corporate_wealth","gross_financial_wealth","household_is_cgt_support_copy","non_residential_property_value","other_residential_property_value","region"],"entity":"household","rows":"all"},{"columns":["age","dividend_income","employment_income","individual_savings_account_interest_income","miscellaneous_income","private_pension_income","property_income","savings_interest_income","self_employment_income","state_pension_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.hmrc_cgt_gains_spine@1","mass":"conserve","outputs":[{"column":"capital_gains","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"hmrc_cgt_gains_spine","stage_contract_sha256":"497c3d06f99f108f46d54b8e6144d363005585640da18ac53cee3093fb809279","time_period":"2024"},"population":"hmrc_cgt_gains_spine.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"hmrc_cgt_gains_spine.boundary","citation":"","description":"Run structural UK stage cgt_incidence_anchor.","id":"cgt_incidence_anchor","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_is_capital_gains_clone","region"],"entity":"household","rows":"all"},{"columns":["age","capital_gains","dividend_income","employment_income","individual_savings_account_interest_income","miscellaneous_income","private_pension_income","property_income","savings_interest_income","self_employment_income","state_pension_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.cgt_incidence_anchor@1","mass":"conserve","outputs":[],"params":{"expand_cells":[],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"cgt_incidence_anchor","stage_contract_sha256":"ed54c55428e56d7597c57c8459b014aa43b2ff9495b903f0b789bd5e4264ca9a","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":"cgt_incidence_anchor","citation":"","description":"Run structural UK stage cgt_residential_split.","id":"cgt_residential_split","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains"],"entity":"person","rows":"all"}],"kernel":"uk.stage.expand.cgt_residential_split@1","mass":"conserve","outputs":[],"params":{"expand_cells":[["household","household_is_cgt_residential_clone","bool"],["household","cgt_residential_clone_index","int64"],["person","cgt_residential_probability","float64"],["person","capital_gains_residential_property","float64"]],"expand_weight_entity":"household","expand_weight_kind":"importance","numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"cgt_residential_split","stage_contract_sha256":"02be930e9900eb352fc29cda472d556ba0a52bd6ded6e81f166aa45f554c6f1a","time_period":"2024"},"population":null,"sources":["frs"],"structural":"expand","weights":null},{"base":null,"citation":"","description":"Own the cells materialized by cgt_residential_split.","id":"cgt_residential_split.owned","inputs":[],"kernel":"uk.claim@1","mass":"conserve","outputs":[{"column":"household_is_cgt_residential_clone","dtype":"bool","entity":"household","ownership":"produced","rows":"all"},{"column":"cgt_residential_clone_index","dtype":"int64","entity":"household","ownership":"produced","rows":"all"},{"column":"cgt_residential_probability","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"capital_gains_residential_property","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"materialized_expand_outputs":["household.household_is_cgt_residential_clone","household.cgt_residential_clone_index","person.cgt_residential_probability","person.capital_gains_residential_property"]},"population":"cgt_residential_split","sources":[],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage hmrc_cgt_asset_type_spine.","id":"hmrc_cgt_asset_type_spine","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["corporate_wealth","gross_financial_wealth","other_residential_property_value","region","stocks_and_shares_isa"],"entity":"household","rows":"all"},{"columns":["age","capital_gains","capital_gains_residential_property","dividend_income","property_income","reports_rent_from_other_property","self_employment_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.hmrc_cgt_asset_type_spine@1","mass":"conserve","outputs":[{"column":"capital_gains_asset_type","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"capital_gains_badr","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"hmrc_cgt_asset_type_spine","stage_contract_sha256":"465ecb7410a0d0a421505ad48475e78e18115cba66333d300a9d60166f297d3c","time_period":"2024"},"population":"cgt_residential_split","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage salary_sacrifice.","id":"salary_sacrifice","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr"],"entity":"person","rows":"all"}],"kernel":"uk.stage.salary_sacrifice@1","mass":"conserve","outputs":[{"column":"pension_contributions_via_salary_sacrifice","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"pension_contributions_via_bonus_sacrifice","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"employee_pension_contributions","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"employment_income","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"},{"column":"salary_sacrifice_pre_conversion_pay","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"salary_sacrifice","stage_contract_sha256":"3335763d91350fa7f938ead181af4659aaca44ac6566b31158ac1284a01d965c","time_period":"2024"},"population":"cgt_residential_split","sources":["frs"],"structural":"none","weights":null},{"base":"cgt_residential_split","citation":"","description":"Ownership boundary before carers_allowance_take_up rewrites.","id":"carers_allowance_take_up.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage carers_allowance_take_up.","id":"carers_allowance_take_up","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay"],"entity":"person","rows":"all"}],"kernel":"uk.stage.carers_allowance_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_carers_allowance","dtype":"bool","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"carers_allowance_take_up","stage_contract_sha256":"d86f2d3466d641b5064a0ae68942a53ad3cca005eae0080cd0a937b9c4632348","time_period":"2024"},"population":"carers_allowance_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"carers_allowance_take_up.boundary","citation":"","description":"Ownership boundary before student_loans rewrites.","id":"student_loans.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage student_loans.","id":"student_loans","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region"],"entity":"household","rows":"all"},{"columns":["age","age_left_full_time_education","current_education","highest_education","reports_outstanding_student_loan","student_loan_repayments","student_loans","would_claim_carers_allowance"],"entity":"person","rows":"all"}],"kernel":"uk.stage.student_loans@1","mass":"conserve","outputs":[{"column":"student_loan_plan","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"student_loan_balance","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"student_loans","stage_contract_sha256":"507ca0160144d8f5ea1b2483b812658ee8b49854e2388d50a8c59ca58f2ca9ee","time_period":"2024"},"population":"student_loans.boundary","sources":["frs"],"structural":"none","weights":null},{"base":"student_loans.boundary","citation":"","description":"Ownership boundary before childcare_copy_take_up rewrites.","id":"childcare_copy_take_up.boundary","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay","student_loan_plan"],"entity":"person","rows":"all"}],"kernel":"uk.identity@1","mass":"conserve","outputs":[],"params":{},"population":null,"sources":[],"structural":"filter","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage childcare_copy_take_up.","id":"childcare_copy_take_up","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_uc_childcare","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay","student_loan_plan"],"entity":"person","rows":"all"}],"kernel":"uk.stage.childcare_copy_take_up@1","mass":"conserve","outputs":[{"column":"would_claim_tfc","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_extended_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_universal_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"would_claim_targeted_childcare","dtype":"bool","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"maximum_extended_childcare_hours_usage","dtype":"float64","entity":"benunit","ownership":"produced","rewrite":true,"rows":"all"},{"column":"max_free_entitlement_hours_used","dtype":"float64","entity":"person","ownership":"produced","rewrite":true,"rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"childcare_copy_take_up","stage_contract_sha256":"cdbb7e135b16fac7ca1bcd6c54222821e2976b4da99f10a60913efd0ba03c13c","time_period":"2024"},"population":"childcare_copy_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage private_school_attendance.","id":"private_school_attendance","inputs":[{"columns":["frs_benunit_capital","is_married","dependent_children","liable_for_share_of_household_rent","would_claim_child_benefit","child_benefit_opts_out","would_claim_pc","would_claim_uc","would_claim_tfc","would_claim_extended_childcare","would_claim_universal_childcare","would_claim_targeted_childcare","would_claim_uc_childcare","maximum_extended_childcare_hours_usage","benunit_source_id","benunit_support_channel","benunit_support_clone_index","uc_reported_capital","pension_credit_reported_capital","would_claim_uc_at_legacy_closure","has_mixed_age_couple_pension_credit_saving","uc_deduction_random_draw","uc_deduction_type_random_draw","uc_latent_deduction_rate","uc_deduction_combination"],"entity":"benunit","rows":"all"},{"columns":["region","tenure_type","accommodation_type","num_bedrooms","council_tax_reported","council_tax_band","council_tax_rebate","council_tax_single_adult_raw","water_and_sewerage_charges","domestic_rates","rent","subrent","mortgage_interest_repayment","mortgage_capital_repayment","structural_insurance_payments","housing_service_charges","external_child_payments","ons_household_type","council_tax","household_owns_tv","would_evade_tv_licence_fee","main_residential_property_purchased_is_first_home","property_purchased","brma","source_household_id","source_year","source_household_key","household_source_id","household_support_channel","household_support_clone_index","household_is_spi_synthetic","household_is_spi_income_band_donor","spi_income_band_donor_lower_bound","owned_land","property_wealth","corporate_wealth","private_pension_wealth","gross_financial_wealth","net_financial_wealth","main_residence_value","other_residential_property_value","non_residential_property_value","savings","num_vehicles","cash_isa","stocks_and_shares_isa","mortgage_debt","consumer_debt","directly_held_shares","unit_and_investment_trusts","other_residential_property_secured_debt","non_residential_property_secured_debt","household_lifetime_isa_balance","household_is_high_value_support_copy","high_value_support_copies","high_value_support_copy_index","main_residence_value_rank_basis","additional_residential_property_purchased","non_residential_property_purchased","household_local_bus_trips","food_and_non_alcoholic_beverages_consumption","alcohol_and_tobacco_consumption","clothing_and_footwear_consumption","housing_water_and_electricity_consumption","household_furnishings_consumption","health_consumption","transport_consumption","communication_consumption","recreation_consumption","education_consumption","restaurants_and_hotels_consumption","miscellaneous_consumption","petrol_spending","diesel_spending","bus_fare_spending","domestic_energy_consumption","electricity_consumption","gas_consumption","liquid_fuel_consumption","solid_fuel_consumption","has_fuel_consumption","uses_energy_prepayment_meter","electricity_kwh","gas_kwh","beer_litres","cider_litres","wine_litres","spirits_litres","other_fermented_litres","beer_draught_share","cider_draught_share","cigarettes_per_week","hand_rolling_tobacco_grams_per_week","cigars_grams_per_week","other_tobacco_grams_per_week","remote_gaming_net_losses","pool_betting_net_receipts","bingo_net_receipts","national_lottery_ticket_spending","land_based_casino_net_losses","machine_games_lower_rate_net_takings","machine_games_standard_rate_net_takings","machine_games_higher_rate_net_takings","land_based_fixed_odds_betting_net_losses","remote_uk_horseracing_betting_net_losses","remote_other_betting_net_losses","betting_exchange_commission","horse_and_dog_pool_betting_net_losses","full_rate_vat_expenditure_rate","dfe_education_spending","rail_subsidy_spending","bus_subsidy_spending","rail_usage","household_is_cgt_support_copy","cgt_support_copies","cgt_support_copy_index","household_is_capital_gains_clone","household_is_cgt_residential_clone","cgt_residential_clone_index"],"entity":"household","rows":"all"},{"columns":["age","gender","months_since_last_birthday","marital_status","hours_worked","care_hours","frs_care_hours_in_household","frs_care_recipients","is_household_head","is_benunit_head","is_parent","is_blind","is_uc_claimant","is_claimant_or_partner","is_hbai_dependent_child","uc_is_in_startup_period","frs_uc_lcw_status","frs_uc_carer_element","uc_is_in_gainful_self_employment","rent_paid_as_boarder","rent_paid_as_lodger","employment_income","self_employment_income","trading_loss","loss_relief","ni_class_4_losses_brought_forward","private_pension_income","annuity_and_trust_income","individual_savings_account_interest_income","savings_interest_income","dividend_income","other_investment_income","stands_as_sole_owner_or_partner_of_company","is_engaged_in_owned_company_trade","owned_company_is_main_employment","owned_company_carries_on_trade","owned_company_carries_on_property_business","owned_company_income_share","property_income","reports_rent_from_other_property","maintenance_income","spousal_maintenance_income","miscellaneous_income","private_transfer_income","lump_sum_income","student_loan_repayments","statutory_sick_pay","statutory_maternity_pay","statutory_paternity_pay","student_loans","access_fund","education_grants","healthy_start_vouchers","free_school_breakfasts","free_school_fruit_veg","free_school_meals","council_tax_benefit_reported","maintenance_expenses","childcare_expenses","personal_pension_contributions","employee_pension_contributions","pension_contributions_via_salary_sacrifice","salary_sacrifice_reported","salary_sacrifice_asked","frs_bonus_amount","frs_company_car_price_band","frs_company_car_fuel_code","frs_company_car_private_fuel","frs_company_car_contribution","child_benefit_reported","income_support_reported","housing_benefit_reported","attendance_allowance_reported","dla_sc_reported","dla_m_reported","iidb_reported","carers_allowance_reported","would_claim_carers_allowance","sda_reported","afcs_reported","ssmg_reported","pension_credit_reported","child_tax_credit_reported","working_tax_credit_reported","state_pension_reported","winter_fuel_allowance_reported","incapacity_benefit_reported","universal_credit_reported","pip_m_reported","pip_dl_reported","jsa_contrib_reported","jsa_income_reported","esa_contrib_reported","esa_income_reported","esa_includes_support_component","bsp_reported","war_widows_pension_reported","widowed_parents_allowance_reported","relationship_to_head","ons_family_role","ons_family_index","is_looked_after_by_local_authority","child_limit_non_parental_caring_exception","employment_status","employment_sector","sic_industry_division","soc2020_major_group","aa_category","dla_sc_category","dla_m_category","pip_m_category","pip_dl_category","is_disabled_for_benefits","is_enhanced_disabled_for_benefits","cares_for_severely_disabled_person","current_education","highest_education","is_in_non_advanced_education","is_in_approved_training","age_started_or_accepted_current_education_or_training","is_before_universal_credit_qualifying_young_person_terminal_date","adult_ema","child_ema","receives_benefits_in_own_right","reports_outstanding_student_loan","age_left_full_time_education","is_in_full_time_education","legacy_jobseeker_proxy","esa_health_condition_proxy","esa_support_group_proxy","disabled_students_allowance_eligible_expenses","max_free_entitlement_hours_used","would_claim_marriage_allowance","would_claim_scp","attends_private_school_random_draw","tax_free_childcare_spend_routed_share","is_apprentice","hmrc_spi_pay","hmrc_spi_unemployment_benefit_income","hmrc_spi_incapacity_benefit_income","ossben_identifiable_subset","srp_regular_code5","employer_pension_contributions","employment_income_annual_share","employment_income_other_spells","self_employment_income_annual_share","self_employment_income_other_spells","private_pension_income_annual_share","contributory_benefits_annual_share","person_source_id","person_support_channel","person_support_clone_index","person_is_spi_income_band_carrier","charitable_investment_gifts","gift_aid","hmrc_spi_employment_benefits","hmrc_spi_employment_expenses","hmrc_spi_other_social_security_income","hmrc_spi_taxable_termination_pay","hmrc_spi_miscellaneous_employment_income","hmrc_spi_other_income","hmrc_spi_state_pension_income","property_finance_costs","hmrc_spi_employed_income","hmrc_spi_total_earned_income","hmrc_spi_total_investment_income","hmrc_spi_assessable_income","person_is_spi_income_recipient","company_car_list_price","company_car_co2_emissions","company_car_fuel_type","company_car_electric_range","company_car_capital_contributions","company_car_private_fuel_provided","soc2020_sub_major_group","student_loan_balance","has_lifetime_isa","lifetime_isa_balance","property_rental_income","local_bus_use_band","bus_in_london_trips","other_local_bus_trips","local_bus_trips","bus_pass_eligible","local_bus_single_fare_share","car_fuel_type","car_co2_emissions","car_engine_size","car_first_registration_date","car_is_ved_exempt","a_and_e_visits","admitted_patient_visits","outpatient_visits","nhs_a_and_e_spending","nhs_admitted_patient_spending","nhs_outpatient_spending","uc_limited_capability_for_WRA","uc_limited_capability_for_work","capital_gains","cgt_residential_probability","capital_gains_residential_property","capital_gains_asset_type","capital_gains_badr","pension_contributions_via_bonus_sacrifice","salary_sacrifice_pre_conversion_pay","student_loan_plan"],"entity":"person","rows":"all"}],"kernel":"uk.stage.private_school_attendance@1","mass":"conserve","outputs":[{"column":"attends_private_school","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"private_school_attendance","stage_contract_sha256":"7e44379c0331fe4c9de05cd76a075c1a6aa22cf0dec6cd2f91b277e70f14a038","time_period":"2024"},"population":"childcare_copy_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage isa_subscriptions.","id":"isa_subscriptions","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["cash_isa","region","stocks_and_shares_isa"],"entity":"household","rows":"all"},{"columns":["age","attends_private_school","dividend_income","employment_income","gender","has_lifetime_isa","individual_savings_account_interest_income","lifetime_isa_balance","loss_relief","miscellaneous_income","private_pension_income","property_income","savings_interest_income","self_employment_income","state_pension_reported"],"entity":"person","rows":"all"}],"kernel":"uk.stage.isa_subscriptions@1","mass":"conserve","outputs":[{"column":"cash_isa_balance","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"stocks_and_shares_isa_balance","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"cash_isa_subscriptions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"stocks_and_shares_isa_subscriptions","dtype":"float64","entity":"person","ownership":"produced","rows":"all"},{"column":"lifetime_isa_payments","dtype":"float64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"isa_subscriptions","stage_contract_sha256":"6bdc671fde73a35dcf32e78d492e695d97c1d2f83226108c77d774a91bf61785","time_period":"2024"},"population":"childcare_copy_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage pip_points.","id":"pip_points","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["region","source_household_id"],"entity":"household","rows":"all"},{"columns":["age","lifetime_isa_payments","pip_dl_category","pip_m_category"],"entity":"person","rows":"all"}],"kernel":"uk.stage.pip_points@1","mass":"conserve","outputs":[{"column":"pip_dl_points","dtype":"int64","entity":"person","ownership":"produced","rows":"all"},{"column":"pip_m_points","dtype":"int64","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"pip_points","stage_contract_sha256":"43f97d6ffe248c3038c31ed9767548c656c0668c6624e9da06b8b28f815f9cfd","time_period":"2024"},"population":"childcare_copy_take_up.boundary","sources":["frs"],"structural":"none","weights":null},{"artifact_outputs":[{"name":"stage_evidence","type":{"name":"microcosm.stage-evidence","schema_version":1}}],"base":null,"citation":"","description":"Run UK spine stage trading_allowance_receipts.","id":"trading_allowance_receipts","inputs":[{"columns":["frs_benunit_capital"],"entity":"benunit","rows":"all"},{"columns":["household_is_spi_synthetic","region","source_household_id"],"entity":"household","rows":"all"},{"columns":["age","pip_m_points","self_employment_income"],"entity":"person","rows":"all"}],"kernel":"uk.stage.trading_allowance_receipts@1","mass":"conserve","outputs":[{"column":"trading_allowance_claim_status","dtype":"string","entity":"person","ownership":"produced","rows":"all"},{"column":"trading_allowance_full_relief","dtype":"bool","entity":"person","ownership":"produced","rows":"all"}],"params":{"numerical_dependencies":[["policyengine-uk","2.177.7"],["policyengine-core","3.34.10"],["numpy","2.4.6"],["pandas","3.0.3"],["scikit-learn","1.8.0"],["quantile-forest","1.4.2"]],"stage":"trading_allowance_receipts","stage_contract_sha256":"50582c6c9e3d5d6300ff8058e3fbc77ce6adf13a487b3c3cf7f674367fcf4d9d","time_period":"2024"},"population":"childcare_copy_take_up.boundary","sources":["frs"],"structural":"none","weights":null}],"sources":[{"codec":"csv-tables","description":"Content-bound UK FRS and donor fixture/source bundle.","name":"frs"}]} From 70e5ac1ed4f5220ace296bc10ea519f60f7beb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Juaristi?= <127882282+juaristi22@users.noreply.github.com> Date: Sun, 15 Nov 2026 12:58:28 +0000 Subject: [PATCH 20/20] Give main's newer tests the true source this branch's floors count by (#931) The first CI run on the rebased head failed where main's newer code meets this branch's strict true-source reader. Main's input-mass carriers, reference surface and release-input coverage, and its pip points and UC limited-capability stages, count support through receipt_counts, which here reads source_household_id. Their test frames carried only household_source_id. This commit gives those frames the column. The code needs no change: every built frame carries source_household_id. - These frames gain source_household_id: the battery, reference-surface and weighted-integrity tests, the coverage helper in test_support, and the pip-points and UC limited-capability engine tests. - The docstrings of the coverage's source reader and the input-mass carriers now name the true source. - test_uk_target_compile_modules records, for the three target-kernel groups, the four imports receipt_counts makes here: source_lineage, household_lineage, national_frame and frame.concepts. Main's target kernels hash receipt_counts (8ea0ee182), so the walk now meets them. Main records its other edges into national_frame the same way, and the move's derived binding rule replaces the record. CI stops at the first failure (--maxfail=1), so its two lists ran locally without that limit: all 809 engine-free files, and the 30 engine-UK files from the first failure on. With this commit both pass, apart from five tests that fail only in this environment: four Orrery tests that need tools/orrery-contract/node_modules, and the CGT projection's check that the UK engine extra is absent. What moves: the two docstring edits move the hashes of the kernels that hash weighted_integrity or release_input_coverage. No value moves. Co-Authored-By: Claude Opus 5.5 --- .../uk_runtime/release_input_coverage.py | 5 ++-- .../build/uk_runtime/weighted_integrity.py | 8 +++--- .../uk/test_uk_pip_points_categories.py | 2 ++ .../uk/test_uk_uc_limited_capability.py | 2 ++ .../uk/test_uk_battery_bindings.py | 4 ++- .../uk/test_uk_reference_surface.py | 4 +++ .../uk/test_uk_target_compile_modules.py | 25 +++++++++++++++++++ .../uk/test_uk_weighted_integrity.py | 2 ++ .../uk_release_input_coverage.py | 2 ++ 9 files changed, 48 insertions(+), 6 deletions(-) diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/release_input_coverage.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/release_input_coverage.py index a1fcd4ad41..7df435f725 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/release_input_coverage.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/release_input_coverage.py @@ -896,8 +896,9 @@ def _source_households_by_entity( """Each entity's rows' source household, or None without lineage. A benefit unit takes its first member's household's source. Every built - frame carries ``household_source_id`` (the input-mass gate fails closed - without it); a hand-made fixture may not. + frame carries the true source, ``source_household_id`` + (``receipt_counts.SOURCE_HOUSEHOLD_COLUMN``; the input-mass gate fails + closed without it, microcosm#931); a hand-made fixture may not. """ from microcosm.build.uk_runtime.receipt_counts import SOURCE_HOUSEHOLD_COLUMN diff --git a/packages/microcosm-build/src/microcosm/build/uk_runtime/weighted_integrity.py b/packages/microcosm-build/src/microcosm/build/uk_runtime/weighted_integrity.py index 160a5858f3..f44a5d8ae6 100644 --- a/packages/microcosm-build/src/microcosm/build/uk_runtime/weighted_integrity.py +++ b/packages/microcosm-build/src/microcosm/build/uk_runtime/weighted_integrity.py @@ -1167,9 +1167,11 @@ def uk_input_mass_carriers( ) -> dict[str, int]: """Distinct source households carrying each column :func:`uk_input_mass_totals` sums. - A column's carriers are the distinct ``household_source_id`` values among - rows of positive weight whose value is nonzero (a boolean: ``True``), - counted as the stage receipts count support + A column's carriers are the distinct true source households + (``source_household_id``, read by + :func:`~microcosm.build.uk_runtime.receipt_counts.source_household_ids`; + microcosm#931) among rows of positive weight whose value is nonzero (a + boolean: ``True``), counted as the stage receipts count support (:func:`~microcosm.build.uk_runtime.receipt_counts.distinct_count`): support copies and clones repeat their source household, so they count once. A person or benefit unit row counts its household's source. A diff --git a/packages/microcosm-build/tests/engine/uk/test_uk_pip_points_categories.py b/packages/microcosm-build/tests/engine/uk/test_uk_pip_points_categories.py index 11e86b33b2..7c0d10a141 100644 --- a/packages/microcosm-build/tests/engine/uk/test_uk_pip_points_categories.py +++ b/packages/microcosm-build/tests/engine/uk/test_uk_pip_points_categories.py @@ -65,6 +65,8 @@ def _stage_frame(): "household_id": list(range(1, count + 1)), "region": ["WALES", "SCOTLAND", "LONDON"] * (count // 3), "household_source_id": list(range(count)), + # The true source each floor counts (microcosm#931). + "source_household_id": list(range(count)), } ) return uk_national_frame( diff --git a/packages/microcosm-build/tests/engine/uk/test_uk_uc_limited_capability.py b/packages/microcosm-build/tests/engine/uk/test_uk_uc_limited_capability.py index 7391f5955f..233b37693a 100644 --- a/packages/microcosm-build/tests/engine/uk/test_uk_uc_limited_capability.py +++ b/packages/microcosm-build/tests/engine/uk/test_uk_uc_limited_capability.py @@ -48,6 +48,8 @@ def _frame(): "household_id": [1, 2, 3], "region": ["WALES", "WALES", "WALES"], "household_source_id": [1, 2, 3], + # The true source each floor counts (microcosm#931). + "source_household_id": [1, 2, 3], "household_is_spi_synthetic": [False, False, False], # The engine adapter's dataset reads these on every household. "council_tax": [0.0, 0.0, 0.0], diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_battery_bindings.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_battery_bindings.py index 09a81d4448..5674dee327 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_battery_bindings.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_battery_bindings.py @@ -202,8 +202,10 @@ def _tables(*, n: int = 4, weights=None): "household_id": household_ids, "household_weight": np.asarray(weights, dtype=float), # Each household its own survey source, as the input-mass gate's - # carriers read them (microcosm#1095). + # carriers read them (microcosm#1095), by its true source + # (microcosm#931). "household_source_id": household_ids + 1000, + "source_household_id": household_ids + 1000, "household_is_spi_synthetic": np.arange(n) % 2 == 1, "household_is_capital_gains_clone": np.arange(n) % 4 >= 2, "owned_land": land, diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_reference_surface.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_reference_surface.py index 7553590962..a78f09830b 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_reference_surface.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_reference_surface.py @@ -84,6 +84,8 @@ def _reference_frame(): { "household_id": np.arange(1, 6, dtype="int64"), "household_source_id": np.asarray([101, 101, 102, 103, 104]), + # The true source each floor counts (microcosm#931). + "source_household_id": np.asarray([101, 101, 102, 103, 104]), } ) person = pd.DataFrame( @@ -210,6 +212,8 @@ def test_the_evidence_reads_a_dense_line_file(tmp_path: Path) -> None: { "household_id": [1, 2, 3], "household_source_id": [11, 12, 13], + # The true source each floor counts (microcosm#931). + "source_household_id": [11, 12, 13], "household_weight": [10.0, 20.0, 30.0], "region": ["LONDON", "WALES", "LONDON"], } diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_target_compile_modules.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_target_compile_modules.py index 145c7e4790..faa142ec88 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_target_compile_modules.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_target_compile_modules.py @@ -478,6 +478,31 @@ def test_national_target_kernels_hash_the_fact_decoder(monkeypatch): FULL_PROBLEM, NATIONAL, ), + # The target kernels hash receipt_counts beside weighted_integrity + # (8ea0ee182), and its floors read true sources through the shared + # lineage reader on the UK's declaration, the national schema and the + # shared source column (microcosm#931). The move's derived binding + # rule replaces this record. + "microcosm.build.uk_runtime.receipt_counts -> microcosm.build.source_lineage": ( + FULL_TARGETS, + FULL_PROBLEM, + NATIONAL, + ), + "microcosm.build.uk_runtime.receipt_counts -> microcosm.build.uk_runtime.household_lineage": ( + FULL_TARGETS, + FULL_PROBLEM, + NATIONAL, + ), + "microcosm.build.uk_runtime.receipt_counts -> microcosm.build.uk_runtime.national_frame": ( + FULL_TARGETS, + FULL_PROBLEM, + NATIONAL, + ), + "microcosm.build.uk_runtime.receipt_counts -> microcosm.frame.concepts": ( + FULL_TARGETS, + FULL_PROBLEM, + NATIONAL, + ), "microcosm.build.uk_runtime.full_measure -> microcosm.build.uk_runtime.rowwise_dataset": ( FULL_TARGETS, FULL_PROBLEM, diff --git a/packages/microcosm-build/tests/engine_free/uk/test_uk_weighted_integrity.py b/packages/microcosm-build/tests/engine_free/uk/test_uk_weighted_integrity.py index 271c2bac07..7c4d40f7d8 100644 --- a/packages/microcosm-build/tests/engine_free/uk/test_uk_weighted_integrity.py +++ b/packages/microcosm-build/tests/engine_free/uk/test_uk_weighted_integrity.py @@ -965,6 +965,8 @@ def test_carriers_count_source_households_not_rows() -> None: "council_tax": np.full(4, 10.0), # Two clones of one source household, and two others. "household_source_id": np.array([7, 7, 8, 9], dtype=np.int64), + # The true source each floor counts (microcosm#931). + "source_household_id": np.array([7, 7, 8, 9], dtype=np.int64), } ), time_period="2023", diff --git a/test_support/microcosm_build/uk_release_input_coverage.py b/test_support/microcosm_build/uk_release_input_coverage.py index 66e407c1f2..d3eecd49f1 100644 --- a/test_support/microcosm_build/uk_release_input_coverage.py +++ b/test_support/microcosm_build/uk_release_input_coverage.py @@ -80,6 +80,8 @@ def _weighted_person_frame( household = pd.DataFrame({"household_id": ids}) if source_ids is not None: household["household_source_id"] = np.asarray(source_ids) + # The true source each floor counts (microcosm#931). + household["source_household_id"] = np.asarray(source_ids) person = pd.DataFrame( { "person_id": ids,