From 6a45789edd94aab73e9fa55c903e864c67f6d105 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Thu, 26 Sep 2024 08:47:53 +0100 Subject: [PATCH] investigating secondary glazing recommendations --- backend/Property.py | 5 +-- backend/app/plan/router.py | 44 ++++++++++++++++--- .../epc_attributes/RoofAttributes.py | 1 + .../epc_attributes/WindowAttributes.py | 1 + 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/backend/Property.py b/backend/Property.py index 0d194a79..77415d0e 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -503,11 +503,10 @@ class Property: output["lighting_energy_eff_ending"] = "Very Good" if recommendation["type"] == "windows_glazing": + is_secondary_glazing = recommendation["is_secondary_glazing"] output["multi_glaze_proportion_ending"] = 100 if output["windows_energy_eff_ending"] not in ["Average", "Good", "Very Good"]: - output["windows_energy_eff_ending"] = "Average" - - is_secondary_glazing = recommendation["is_secondary_glazing"] + output["windows_energy_eff_ending"] = "Average" if not is_secondary_glazing else "Good" if output["glazing_type_ending"] == "multiple": pass diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 3b50d46d..05c79a22 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -843,14 +843,44 @@ async def trigger_plan(body: PlanTriggerRequest): training_fixed = training_fixed.reset_index(drop=True) + # Get the recommendation config for this uprn + uprn = 121016121 + property_instance = [p for p in input_properties if p.uprn == uprn][0] + property_recs = recommendations[property_instance.id] + window_recs = [r for r in property_recs if r[0]["type"] == "windows_glazing"][0] + window_recs[0].keys() + window_recs[0]["description_simulation"]["multi-glaze-proportion"] + # TODO: - In description_simulation for windows, we update glazed-type but in the model training data there + # is a column called "glazing-type". + # - We don't update glazed-area (should be "Much More Than Typical" most likely? Or Normal??) + # TODO: I think we update eveything that we actually need to, when simulating the recommendation impact for the + # ML models + # TODO: Secondary glazing appears to go to "Good", not "Average". Investigate why + # TODO: For the two properties, force recommendations for double glazing and check impact + + z = training_data[training_data["glazed_type_ending"] == "secondary glazing"] + z = z[z["multi_glaze_proportion_ending"] == 100] + z["windows_energy_eff_ending"].value_counts() + # Find the things that change - example = training_fixed.iloc[0] - things_that_change = [] - for c in ending_cols: - if example[c] != example[starting[c]]: - things_that_change.append(c) - # 100051011370 - example[] + example = training_fixed.iloc[3] + for _, example in training_fixed.iterrows(): + things_that_change = [] + for c in ending_cols: + if example[c] != example[starting[c]]: + things_that_change.append(c) + if len(things_that_change) > 4: + print(things_that_change) + print(example["uprn"]) + # blah + + # 100051011370 (doesn't change in actual glazing) + # example["glazed_type_ending"] + # double glazing installed before 2002 + # example["glazed_type_starting"] + # double glazing, unknown install date + + # 100040925015 # We call the API with the scoring epcs scoring_epcs = pd.DataFrame(scoring_epcs) diff --git a/etl/epc_clean/epc_attributes/RoofAttributes.py b/etl/epc_clean/epc_attributes/RoofAttributes.py index 75cb8af1..0fc2156e 100644 --- a/etl/epc_clean/epc_attributes/RoofAttributes.py +++ b/etl/epc_clean/epc_attributes/RoofAttributes.py @@ -15,6 +15,7 @@ class RoofAttributes(Definitions): "ar oleddf, wedi?i inswleiddio (rhagdybiaeth)": "pitched, insulated (assumed)", "ar oleddf, wedigçöi hinswleiddio (rhagdybiaeth)": "pitched, insulated (assumed)", "ar oleddf, wedigçöi inswleiddio": "pitched, insulated", + "ar oleddf, wedi?i inswleiddio": "pitched, insulated", "ar oleddf, inswleiddio cyfyngedig (rhagdybiaeth)": "pitched, limited insulation (assumed)", "ar oleddf, inswleiddio cyfyngedig": "pitched, limited insulation", "ar oleddf, wedigçöi inswleiddio wrth y trawstiau": 'pitched, insulated at rafters', diff --git a/etl/epc_clean/epc_attributes/WindowAttributes.py b/etl/epc_clean/epc_attributes/WindowAttributes.py index 8c4d0c45..2b1dc172 100644 --- a/etl/epc_clean/epc_attributes/WindowAttributes.py +++ b/etl/epc_clean/epc_attributes/WindowAttributes.py @@ -27,6 +27,7 @@ class WindowAttributes(Definitions): "gwydrau triphlyg llawn": "fully triple glazed", "gwydrau triphlyg rhannol": "partial triple glazed", "gwydrau triphlyg mwyaf": "mostly triple glazed", + "gwydrau triphlyg gan mwyaf": "mostly triple glazed", "gwydrau eilaidd llawn": "full secondary glazing", "gwydrau eilaidd mwyaf": "mostly secondary glazing", "gwydrau eilaidd rhannol": "partial secondary glazing",