Contains projects associated to the development of modeling products
Find a file
Khalim Conn-Kowlessar 76e24bbdc3 Slice S0380.107: window vs roof window routing via BP roof type (RdSAP 10 §3.7.1)
Replaces the U > 3.0 W/m²K heuristic with a 3-rule cascade
discriminator that uses the BP's lodged §8 roof type alongside the
glazing type. Closes cert 000565 windows misrouting where the
previous heuristic mis-classified 3 of 6 windows.

RdSAP 10 §3.7.1 (PDF p.21) verbatim:

  "Window data
   Window area is assessed by measuring all windows and roof windows
   throughout the dwelling. ...
   Additional information to be noted: ...
     • window or roof window;
     • orientation"

RdSAP 10 §8.2 (PDF p.50) verbatim (Glazed walls + glazed roof):

  "Glazed walls are taken as windows, glazed roof as rooflight, see
   window U-values in Table 24"

The source RdSAP data set carries the "Window (vertical) / Roof
window (inclined)" classification as a discrete assessor lodgement.
The Elmhurst Summary PDF §11.0 flattens that signal — every row's
Location column reads "External wall" regardless of physical
position. The mapper must therefore reconstruct the classification.

New heuristic, in priority order:

  1. "Single glazing" → never a rooflight. Approved Document L
     (2006+) disallows single-glazed rooflights on energy-efficiency
     grounds; SAP convention assumes Table 6c double-glazing minimum
     for any (27a) entry.

  2. BP roof type ∈ {"A Another dwelling above", "NR Non-residential
     space above"} → rooflight. These BPs have their own structural
     external roof distinct from a pitched dwelling roof — the
     worksheet (30) External roof + (27a) Roof Windows treatment
     follows this routing.

  3. U > 3.0 W/m²K → rooflight (cohort backstop, catches cohort cert
     000516 W6 Wood-frame Double pre-2002 U=3.10 on Main PA, the
     only U > 3 vertical-glazing reading the cohort lodges that the
     worksheet routes via (27a)).

  4. Otherwise vertical.

Cohort verification: all 6 cohort certs have BPs with only PA/PN
pitched roof types (no NR/A). Rule 2 doesn't fire on cohort certs;
rule 1 doesn't block any cohort rooflights (all cohort high-U
windows are Double glazed). Rule 3 catches cohort 000516 W6
unchanged. No cohort regressions on cert→inputs cascade pins.

Cert 000565 routing fix (Summary §11.0 6-window list):
  - Items 1, 6 (Main, Double, U=2.0) — vertical (unchanged)
  - Item 3 (Ext1, Double, U=1.74) — vertical (unchanged; Ext1 roof
    "S Same dwelling above" doesn't fire rule 2)
  - Item 4 (Main, Single, U=3.35) — vertical (rule 1; was wrongly
    classified as rooflight by U > 3 backstop)
  - Item 2 (Ext2 NR, Triple, U=2.0) — rooflight (rule 2)
  - Item 5 (Ext4 A, Double, U=2.0) — rooflight (rule 2)

Movement at HEAD `8effa2d0` → post-slice (cert 000565):

Fabric (cascade vs ws):
  walls         601.22 → 602.53 (Δ -2.85 → -1.54 W/K; closes 46%)
  windows         9.60 →  11.48 (Δ -1.87 →  0.00 W/K; ✓ EXACT vs ws)
  roof_windows    5.02 →   3.15 (Δ +1.44 → -0.43 W/K; cascade U
                                  formula gap exposed, see TODO below)
  net fabric    HTC Δ -0.99 → +0.33 W/K (magnitude improved 67%)

End-result pins:
  sap_score_continuous   28.5269 → 28.4959 (Δ +0.0182 → -0.0128;
                                            magnitude improved 30%)
  ecf                     5.3850 →  5.3881 (Δ -0.0016 → +0.0015)
  total_fuel_cost_gbp   4678.64  → 4681.39 (Δ -1.62 → +1.13)
  co2_kg_per_yr         6445.51  → 6449.13 (Δ -2.12 → +1.51)
  space_heating_kwh    58980.82  → 59028.80 (Δ -27.5 → +20.5)
  main_heating_fuel    34694.60  → 34722.83 (Δ -16.2 → +12.0)
  lighting_kwh          1387.02  → 1382.67 (Δ +2.19 → -2.17, sign
                                            flips: cascade DF now uses
                                            correct rooflight area;
                                            remaining gap is the
                                            rooflight g×FF default-vs-
                                            lodged drift, separate
                                            slice)
  pumps_fans_kwh ✓ EXACT (unchanged)

**Transient sap_score (integer) regression**: continuous SAP crossed
the 28.5 rounding boundary downward (28.5269 → 28.4959), so the
integer rounds to 28 instead of 29. This is a rounding artifact —
the continuous metric IS closer to ws (Δ magnitude 0.0182 → 0.0128).
Per user direction (NEXT_AGENT_PROMPT): primary metric is continuous,
transient drift OK while closing a true intermediate-value bug.
The integer pin returns to 29 once continuous SAP closes above the
ws value 28.5087.

S0380.103 cost test reframed: previously asserted total_fuel_cost
delta < +£0.05 over ws — a snapshot threshold that the SH-cascade
sign flip naturally breaks. The MEV cost split rate (12.4467
p/kWh kWh-weighted blend) is what S0380.103 specifically closes;
the test now pins that rate directly via `inputs.pumps_fans_
fuel_cost_gbp_per_kwh`, decoupled from downstream SH cascade
effects.

3-layer fix:
1. Mapper `_is_elmhurst_roof_window` predicate now takes the survey
   for BP roof type lookup; new `_elmhurst_bp_roof_type` helper.
2. Two call sites at lines 327, 331 pass `survey` through.
3. New AAA test `test_summary_000565_window_routing_uses_bp_roof_
   type_per_rdsap_10_section_3_7_1` pins the 4-vertical + 2-roof
   classification.

Test count: 605 pass + 7 expected 000565 fails → **606 pass + 8
000565 fails** (new window-routing test + S0380.103 test reframe
both GREEN; sap_score added to work queue as a rounding-boundary
artifact). Pyright net-zero per touched file (45 baseline →
45 post-change).

Open work (in decreasing leverage on continuous SAP):
  - Roof BP[1] Ext1 RR area formula refinement (+1.59 W/K over,
    deferred to a separate slice per the original handover)
  - Walls -1.54 W/K residual (Detailed-RR per-element investigation)
  - Roof window U formula gap (-0.43 W/K; cascade formula 1/(1/U +
    0.04) gives 1.852 for U_raw=2.0 but ws shows 2.1062)
  - Lighting rooflight g×FF default-vs-lodged drift (-2.17 kWh)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-01 16:28:47 +00:00
.devcontainer pr review, move domain and orhcestration 2026-06-01 14:00:31 +00:00
.github/workflows added landlord description overrides 2026-05-29 12:12:54 +00:00
.idea scaffolding for ml pipeline 2026-05-16 14:15:56 +00:00
.vscode added utils to allow easier subtask management 2026-03-02 15:15:39 +00:00
applications move landlord overrides 2026-06-01 15:46:46 +00:00
asset_list Remove EPC and asset_list changes unrelated to SAL handler 2026-05-22 15:36:46 +00:00
backend Slice S0380.107: window vs roof window routing via BP roof type (RdSAP 10 §3.7.1) 2026-06-01 16:28:47 +00:00
backlog implemented onboarding 2026-04-21 20:23:33 +00:00
datatypes Slice S0380.107: window vs roof window routing via BP roof type (RdSAP 10 §3.7.1) 2026-06-01 16:28:47 +00:00
deployment/terraform added landlord description overrides 2026-05-29 12:12:54 +00:00
docs/adr move landlord overrides 2026-06-01 15:46:46 +00:00
domain Slice S0380.106: MEV fans PE split via Table 12a Grid 2 + Table 12e (SAP 10.2 §10a / §10c) 2026-06-01 16:28:47 +00:00
epr_data_exports allowing carbon and energy otimisation by removing slack 2025-07-31 19:13:16 +01:00
etl booking status 2026-06-01 16:28:47 +00:00
infrastructure GoogleSolarApiClient raises BuildingInsightsNotFoundError on 404 entity-not-found 🟩 2026-06-01 16:28:47 +00:00
model_data/requirements its working the way khalim wanted wiht postcode and then search that 2026-01-22 15:17:13 +00:00
orchestration moved classifier data transformation to an easy one 2026-06-01 14:53:34 +00:00
recommendations save 2026-05-07 15:55:44 +00:00
repositories move landlord overrides 2026-06-01 15:46:46 +00:00
scripts Slice S0380.39: bulk-fetch 38 cohort-2 EPC API JSONs for cross-mapper parity 2026-06-01 16:28:47 +00:00
sfr/principal_pitch added added historic epc data class with shape 2026-05-08 12:03:35 +00:00
survey_report quidos site notes extraction 2025-02-18 19:49:29 +00:00
tests GoogleSolarApi translates BuildingInsightsNotFoundError to sentinel dict 🟩 2026-06-01 16:28:47 +00:00
utilities get rid of comments 2026-05-20 13:21:11 +00:00
utils rename files in sharepoint to desired structure 2026-05-20 16:26:07 +00:00
.coveragerc fixed unit tests 2023-10-05 16:04:12 +01:00
.dockerignore deployment from infrastructure 2026-05-19 12:55:30 +00:00
.gitignore fixed merge conflicts from main 2026-05-26 11:21:09 +00:00
__init__.py added checking for directory before creation and made some minor style changes 2023-08-25 15:21:17 +01:00
ara_backend_design.md refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
BaseUtility.py fixed missing task and subtask for single remote assessments 2025-11-27 17:50:26 +00:00
CLAUDE.md fixed merge conflicts from main 2026-05-26 11:21:09 +00:00
conftest.py working on integrating new EPC api into address2UPRN 2026-04-27 11:32:44 +00:00
CONTEXT.md refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
devcontainer.sh add dev container 2026-04-17 14:50:57 +00:00
Dockerfile.test fix: address 22 project-wide test failures from previous sweep 2026-05-26 13:34:51 +00:00
Dockerfile.test.dockerignore deployment from infrastructure 2026-05-19 12:55:30 +00:00
Makefile adding to dev container to create shared network on start up 2026-04-25 15:03:07 +00:00
MEMORY.md memory 2026-04-02 10:24:31 +00:00
package-lock.json restructuring openUrpn code 2023-07-20 11:41:43 +01:00
package.json restructuring openUrpn code 2023-07-20 11:41:43 +01:00
pyproject.toml slice 14a: ml_training_data pkg + sample.py (CSV filter + random sample) 2026-05-16 17:39:43 +00:00
pyrightconfig.json slice 14d: build_features wires bulk reader -> mapper -> EpcMlTransform 2026-05-16 18:38:41 +00:00
pytest.ini refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
README.md adding to dev container to create shared network on start up 2026-04-25 15:03:07 +00:00
run_lambda_local.sh debugging local lambda run and updating the sap point checking condition 2023-09-13 18:47:12 +01:00
serverless.yml added logic to add to serverless 2026-04-22 12:39:44 +00:00
test.requirements.txt tests wrong environemnt 2026-05-29 16:17:06 +00:00
tox.ini removing playright install for integration test 2026-04-30 20:08:13 +00:00
UBIQUITOUS_LANGUAGE.md postcode_splitter: pure domain (UserAddress, sanitise_postcode, postcode_batching) 2026-05-19 16:45:47 +00:00

Model Repository

This repository contains the code pertaining to the development of the data science and machine learning products being utilised by Hestia.

The different folders in this repository relate to services that can be used independently, or can be imported and used as part of a larger application

Getting Started

Prerequisites

Dev Container Setup

This repo uses a Docker Compose-based dev container. The model-backend service joins a shared-dev Docker network so it can communicate with other local services (e.g. a frontend container) running on your machine.

VS Code users: The initializeCommand in devcontainer.json creates the shared-dev network automatically before the container starts. No manual step required — just open the repo and select Reopen in Container.

Non-VS Code / CI workflows: Run the following once before starting the container:

make dev-setup

This is idempotent and safe to re-run if the network already exists.

Folders

backend/

This folder contains the code for the fastapi backend service, which provides an interface to much of the functionality in this repository, for the frontend

model_data/

This folder contains related to the reading and preparation of assessment model data, including pulling out epc attributes

Testing

All tests can be run, against the configuration in pytest.ini running

pytest

This will run the complete panel of tests and report on coverage in the locations specified by the pytest.ini file.

To run tests in a specific service, e.g. inside of model_data, simply run

pytest --cov-config=model_data/.coveragerc --cov=model_data

This will produce the test results and coverage reports