From d38e4d44a0b522dede8f2e2becc0fde9f5e61767 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 18 Dec 2023 15:17:22 +0000 Subject: [PATCH] built and added condition of insulation, prior to ventilation --- .idea/Model.iml | 2 +- .idea/misc.xml | 2 +- backend/Property.py | 22 +++++++++++++++++++++- backend/app/plan/router.py | 8 ++++++-- backend/ml_models/Valuation.py | 1 + recommendations/Recommendations.py | 8 +++++--- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/.idea/Model.iml b/.idea/Model.iml index 3a3ec5a2..4413bb06 100644 --- a/.idea/Model.iml +++ b/.idea/Model.iml @@ -7,7 +7,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 605a6457..6f308057 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/backend/Property.py b/backend/Property.py index 705ad361..bb545248 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -1,6 +1,8 @@ from datetime import datetime import re import os + +import numpy as np import pandas as pd from etl.epc.DataProcessor import DataProcessor @@ -820,7 +822,25 @@ class Property(Definitions): """ if self.data["fixed-lighting-outlets-count"] == "": - self.number_lighting_outlets = round(cleaned_property_data["FIXED_LIGHTING_OUTLETS_COUNT"].values[0]) + + # We check old EPCs and the full SAP EPC + + lighting_data = [] + + if len(self.old_data): + lighting_data.extend([ + int(x["fixed-lighting-outlets-count"]) for x in self.old_data if + x["fixed-lighting-outlets-count"] != "" + ]) + + if len(self.full_sap_epc): + if self.full_sap_epc["fixed-lighting-outlets-count"] != "": + lighting_data.append(int(self.full_sap_epc["fixed-lighting-outlets-count"])) + + if lighting_data: + self.number_lighting_outlets = round(np.median(lighting_data)) + else: + self.number_lighting_outlets = round(cleaned_property_data["FIXED_LIGHTING_OUTLETS_COUNT"].values[0]) else: self.number_lighting_outlets = float(self.data["fixed-lighting-outlets-count"]) diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index b5acb3c0..7a6df2da 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -478,9 +478,13 @@ async def trigger_plan(body: PlanTriggerRequest): recommendations[property_id] = property_recommendations # For expected adjust energy, we don't include mechanical ventilation so we'll add it back on - expected_adjusted_energy = expected_adjusted_energy + representative_rec_data[ + mechanical_ventilation_rec = representative_rec_data[ representative_rec_data["type"] == "mechanical_ventilation" - ]["heat_demand"].values[0] + ] + if not mechanical_ventilation_rec.empty: + expected_adjusted_energy = ( + expected_adjusted_energy + mechanical_ventilation_rec["heat_demand"].values[0] + ) property_instance.set_adjusted_energy( current_adjusted_energy=current_adjusted_energy, diff --git a/backend/ml_models/Valuation.py b/backend/ml_models/Valuation.py index 522a7067..f5a7e2bb 100644 --- a/backend/ml_models/Valuation.py +++ b/backend/ml_models/Valuation.py @@ -19,6 +19,7 @@ class PropertyValuation: 100070505235: 344000, # Based on Zoopla's estimation of 131 School road, which is also semi-detached 100070513306: 182000, # Based on Zoopla's estimation of 61 Simmons Drive 100071306896: 77000, # Based on Flat 2 of 44 Wedgewood Road on Zoopla + 100021192109: 650000 # Based on Zoopla } # We base our valuation uplifts on a number of sources diff --git a/recommendations/Recommendations.py b/recommendations/Recommendations.py index a169b788..60cdb696 100644 --- a/recommendations/Recommendations.py +++ b/recommendations/Recommendations.py @@ -61,9 +61,11 @@ class Recommendations: property_recommendations.append(self.roof_recommender.recommendations) # Ventilation recommendations - self.ventilation_recomender.recommend() - if self.ventilation_recomender.recommendation: - property_recommendations.append(self.ventilation_recomender.recommendation) + # We only produce a ventilation recommendation if the property is recommended to have wall or roof insulation + if self.wall_recomender.recommendations or self.roof_recommender.recommendations: + self.ventilation_recomender.recommend() + if self.ventilation_recomender.recommendation: + property_recommendations.append(self.ventilation_recomender.recommendation) # Fireplace sealing recommendations self.fireplace_recommender.recommend()