mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
52 lines
2.5 KiB
Python
52 lines
2.5 KiB
Python
class Recommendations:
|
|
"""
|
|
High level recommendations class, which sits above the measure specific recommendation classes
|
|
"""
|
|
|
|
@classmethod
|
|
def calculate_recommendation_impact(cls, property_instance, all_predictions, recommendations):
|
|
|
|
"""
|
|
Given predictions from the model apis, with method will update the recommendations with the predicted
|
|
impact of the recommendation on the property
|
|
|
|
:param property_instance: Instance of the Property class, for the home associated to property_id
|
|
:param all_predictions: dictionary of predictions from the model apis
|
|
:param recommendations: dictionary of recommendations for the property
|
|
:return:
|
|
"""
|
|
|
|
property_sap_predictions = all_predictions["sap_change_predictions"][
|
|
all_predictions["sap_change_predictions"]["property_id"] == str(property_instance.id)
|
|
]
|
|
property_heat_predictions = all_predictions["heat_demand_predictions"][
|
|
all_predictions["heat_demand_predictions"]["property_id"] == str(property_instance.id)
|
|
]
|
|
property_carbon_predictions = all_predictions["carbon_change_predictions"][
|
|
all_predictions["carbon_change_predictions"]["property_id"] == str(property_instance.id)
|
|
]
|
|
|
|
property_recommendations = recommendations[property_instance.id].copy()
|
|
|
|
for recommendations_by_type in property_recommendations:
|
|
for rec in recommendations_by_type:
|
|
new_sap = property_sap_predictions[property_sap_predictions["recommendation_id"] == str(
|
|
rec["recommendation_id"]
|
|
)]["predictions"].values[0]
|
|
|
|
new_heat_demand = property_heat_predictions[property_heat_predictions["recommendation_id"] == str(
|
|
rec["recommendation_id"]
|
|
)]["predictions"].values[0]
|
|
|
|
new_carbon = property_carbon_predictions[property_carbon_predictions["recommendation_id"] == str(
|
|
rec["recommendation_id"]
|
|
)]["predictions"].values[0]
|
|
|
|
rec["sap_points"] = new_sap - float(property_instance.data["current-energy-efficiency"])
|
|
rec["co2_equivalent_savings"] = float(property_instance.data["co2-emissions-current"]) - new_carbon
|
|
rec["heat_demand"] = float(property_instance.data["co2-emissions-current"]) - new_heat_demand
|
|
|
|
if rec["sap_points"] is None:
|
|
raise ValueError("Sap points missing")
|
|
|
|
return property_recommendations
|