From 135831febb322d7b9e28bab0e8f1cf2fef19e8f5 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 16 Oct 2024 19:55:15 +0100 Subject: [PATCH] increasing the number of tests in generate_scenarios_data --- etl/epc/generate_scenarios_data.py | 145 ++++++++++++++++++++++++----- 1 file changed, 123 insertions(+), 22 deletions(-) diff --git a/etl/epc/generate_scenarios_data.py b/etl/epc/generate_scenarios_data.py index fe27cc91..fb3177a2 100644 --- a/etl/epc/generate_scenarios_data.py +++ b/etl/epc/generate_scenarios_data.py @@ -71,6 +71,18 @@ scenario_properties = [ {}, [0], ], + [ + ["internal_wall_insulation", "suspended_floor_insulation"], + "13", + {}, + [0, 1], + ], + [ + ["external_wall_insulation", "suspended_floor_insulation"], + "13", + {}, + [0, 1], + ], [["solar", "windows"], "15", {"photo_supply_ending": 50}, [0, 1]], ], }, @@ -85,6 +97,24 @@ scenario_properties = [ {}, [0, 1], ], + [ + ["loft_insulation"], + "2", + {}, + [0], + ], + [ + ["cavity_wall_insulation", "loft_insulation", "solid_floor_insulation"], + "12", + {}, + [0], + ], + [ + ["cavity_wall_insulation", "loft_insulation", "solid_floor_insulation", "low_energy_lighting"], + "13", + {}, + [0], + ], ], }, { @@ -287,7 +317,19 @@ scenario_properties = [ ], [ ["double_glazing", "internal_wall_insulation", "suspended_floor_insulation"], - "11", + "10", + {}, + [0, 1, 2] + ], + [ + ["internal_wall_insulation"], + "5", + {}, + [0] + ], + [ + ["internal_wall_insulation", "suspended_floor_insulation"], + "7", {}, [0, 1, 2] ], @@ -533,6 +575,18 @@ scenario_properties = [ {}, [0, 1, 2] ], + [ + ["internal_wall_insulation"], + "5", + {}, + [0] + ], + [ + ["internal_wall_insulation", "low_energy_lighting"], + "5", + {}, + [0, 1] + ], ], }, @@ -653,17 +707,35 @@ scenario_properties = [ "measures": [ [["secondary_glazing", "low_energy_lighting"], "2", {}, [0, 1]], [ - ["secondary_glazing", "low_energy_lighting", "internal_wall_insulation", "suspending_floor_insulation"], + ["secondary_glazing", "low_energy_lighting", "internal_wall_insulation", "suspended_floor_insulation"], "9", {}, [0, 1, 2, 3] ], [ - ["double_glazing", "low_energy_lighting", "internal_wall_insulation", "suspending_floor_insulation"], + ["double_glazing", "low_energy_lighting", "internal_wall_insulation", "suspended_floor_insulation"], "11", {}, [0, 1, 2, 3] ], + [ + ["internal_wall_insulation"], + "6", + {}, + [0] + ], + [ + ["internal_wall_insulation", "suspended_floor_insulation"], + "7", + {}, + [0, 1] + ], + [ + ["internal_wall_insulation", "suspended_floor_insulation", "low_energy_lighting"], + "8", + {}, + [0, 1, 2] + ], ], }, @@ -795,6 +867,18 @@ scenario_properties = [ {}, [0, 1, 2] ], + [ + ["internal_wall_insulation"], + "8", + {}, + [0] + ], + [ + ["low_energy_lighting", "internal_wall_insulation"], + "10", + {}, + [0, 1, 2] + ], ], }, @@ -963,6 +1047,18 @@ scenario_properties = [ {}, [0, 1, 2] ], + [ + ["internal_wall_insulation"], + "6", + {}, + [0, 1, 2] + ], + [ + ["internal_wall_insulation", "low_energy_lighting"], + "7", + {}, + [0, 1, 2] + ], ], }, @@ -1164,7 +1260,6 @@ scenario_properties = [ ], }, ] - recommendations_scoring_data = [] for scenario_property in tqdm(scenario_properties): @@ -1230,20 +1325,7 @@ for scenario_property in tqdm(scenario_properties): ) } - recommender = Recommendations(property_instance=p, materials=materials, default_u_values=True) - property_recommendations = recommender.recommend() - - wall_recommendations = recommender.wall_recomender.recommendations - loft_recommendations = recommender.roof_recommender.recommendations - floor_recommendations = recommender.floor_recommender.recommendations - solar_recommendations = recommender.solar_recommender.recommendation - windows_recommendations = recommender.windows_recommender.recommendation - led_recommendations = recommender.lighting_recommender.recommendation - - p.create_base_difference_epc_record(cleaned_lookup=cleaned) - scoring_list = [] - # Create the record for each of the different measures for measure_impact_override in scenario_property["measures"]: @@ -1251,6 +1333,20 @@ for scenario_property in tqdm(scenario_properties): impact = measure_impact_override[1] override = measure_impact_override[2] + recommender = Recommendations( + property_instance=p, materials=materials, default_u_values=True, inclusions=measure + ) + property_recommendations = recommender.recommend() + + wall_recommendations = recommender.wall_recomender.recommendations.copy() + loft_recommendations = recommender.roof_recommender.recommendations.copy() + floor_recommendations = recommender.floor_recommender.recommendations.copy() + solar_recommendations = recommender.solar_recommender.recommendation.copy() + windows_recommendations = recommender.windows_recommender.recommendation.copy() + led_recommendations = recommender.lighting_recommender.recommendation.copy() + + p.create_base_difference_epc_record(cleaned_lookup=cleaned) + wall_recs = [] loft_recs = [] floor_recs = [] @@ -1299,7 +1395,12 @@ for scenario_property in tqdm(scenario_properties): if rec["type"] == "suspended_floor_insulation": floor_recs.append(rec) - combi_list = [wall_recs, loft_recs, solar_recs, windows_recs, lighting_recs, floor_recs] + if "solid_floor_insulation" in measure: + for rec in floor_recommendations: + if rec["type"] == "solid_floor_insulation": + floor_recs.append(rec) + + combi_list = [wall_recs, loft_recs, floor_recs, solar_recs, windows_recs, lighting_recs] combi_list = [element for element in combi_list if len(element) != 0] all_combi_recommendations = list(itertools.product(*combi_list)) @@ -1312,7 +1413,7 @@ for scenario_property in tqdm(scenario_properties): property_id=i, primary_recommendation_id=i, recommendation_record=recommendation_record, - recommendations=combi, + recommendations=list(combi), ) if override is not None: @@ -1372,11 +1473,11 @@ sap_impact = sap_impact[ # Get some metrics - MAPE for local testing mae = mean_absolute_error(sap_impact["actual_post_sap"], sap_impact["predicted_post_sap"]) -# 2.2958333333333347 +# 1.6828571428571433 mape = mean_absolute_percentage_error(sap_impact["actual_post_sap"], sap_impact["predicted_post_sap"]) -# 0.034359867214274246 +# 0.02510877585853886 mape_impact = mean_absolute_percentage_error(sap_impact["actual_impact"], sap_impact["predicted_impact"]) -# 0.4853675375550377 +# 0.35805350998208146 save_dataframe_to_s3_parquet( recommendations_scoring_data,