From 548672cc1039efede9d53886ce616a747dd25cff Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 4 Jun 2024 11:36:28 +0100 Subject: [PATCH] refine conditions for recommending ewi in mds --- etl/epc/Dataset.py | 18 +++++++++--------- recommendations/Mds.py | 9 ++++++++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/etl/epc/Dataset.py b/etl/epc/Dataset.py index ee3e357c..83a85b78 100644 --- a/etl/epc/Dataset.py +++ b/etl/epc/Dataset.py @@ -203,11 +203,11 @@ class TrainingDataset(BaseDataset): common_cols = [[col + "_starting", col + "_ending"] for col in common_cols] self.df = self.df.loc[ - :, - no_suffix_cols - + only_ending_cols - + [col for cols in common_cols for col in cols], - ] + :, + no_suffix_cols + + only_ending_cols + + [col for cols in common_cols for col in cols], + ] def _remove_abnormal_change_in_floor_area(self): """ @@ -511,7 +511,7 @@ class TrainingDataset(BaseDataset): expanded_df["is_sandstone_or_limestone"] == expanded_df["is_sandstone_or_limestone_ending"] ) - ] + ] elif component == "floor": expanded_df = expanded_df[ (expanded_df["is_suspended"] == expanded_df["is_suspended_ending"]) @@ -528,7 +528,7 @@ class TrainingDataset(BaseDataset): expanded_df["is_to_external_air"] == expanded_df["is_to_external_air_ending"] ) - ] + ] elif component == "roof": expanded_df = expanded_df[ (expanded_df["is_pitched"] == expanded_df["is_pitched_ending"]) @@ -541,7 +541,7 @@ class TrainingDataset(BaseDataset): expanded_df["has_dwelling_above"] == expanded_df["has_dwelling_above_ending"] ) - ] + ] return expanded_df @@ -742,7 +742,7 @@ class TrainingDataset(BaseDataset): self.df[col] = self.df[col].fillna("Unknown") def _null_validation(self, information: str): - print(f"Null validation after {information}") + # print(f"Null validation after {information}") if pd.isnull(self.df).sum().sum(): raise ValueError(f"Null values found in dataset, after step {information}") diff --git a/recommendations/Mds.py b/recommendations/Mds.py index 02ed3d06..e9e5cad8 100644 --- a/recommendations/Mds.py +++ b/recommendations/Mds.py @@ -124,7 +124,10 @@ class Mds: # There are certain measures where we need to if measure == "external_wall_insulation": # Check if the wall is not cavity since the other wall types can take external wall insulation - if self.wall_recommender.ewi_valid(): + if ( + self.wall_recommender.ewi_valid() and + not self.property_instance.walls["insulation_thickness"] in ["average", "above average"] + ): pruned_measures.append(measure) continue @@ -177,9 +180,13 @@ class Mds: if measure == "solar_pv": if self.solar_recommender.is_solar_pv_valid(): pruned_measures.append(measure) + continue raise NotImplementedError("Implement me") + if not pruned_measures: + continue + pruned_measures_formatted = [] for pm in pruned_measures: pruned_measures_formatted.append({pm: self.format_map[pm]})