mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
testing different weight methods - to run full test on
This commit is contained in:
parent
15ec6460d2
commit
1b4ae239a3
2 changed files with 18 additions and 8 deletions
|
|
@ -472,13 +472,21 @@ class SearchEpc:
|
|||
epc_data["house_number_distance"] = abs(
|
||||
epc_data["numeric_house_number"] - self.numeric_house_number
|
||||
)
|
||||
# We add 1, just in case we have a 0 weight (e.g. comparing house number 7a to 7b, or 9A to 9)
|
||||
epc_data["weight"] = 1 / (epc_data["house_number_distance"] + 1)
|
||||
# If we have a home without a house number, fill that weight with average
|
||||
epc_data["weight"] = epc_data["weight"].fillna(epc_data["weight"].mean())
|
||||
# Finally, we might not have any house numbers whatsoever so everything could be
|
||||
# missing, so we fill with 1
|
||||
epc_data["weight"] = epc_data["weight"].fillna(1)
|
||||
# # We add 1, just in case we have a 0 weight (e.g. comparing house number 7a to 7b, or 9A to 9)
|
||||
# epc_data["weight"] = 1 / (epc_data["house_number_distance"] + 1)
|
||||
# # If we have a home without a house number, fill that weight with average
|
||||
# epc_data["weight"] = epc_data["weight"].fillna(epc_data["weight"].mean())
|
||||
# # Finally, we might not have any house numbers whatsoever so everything could be
|
||||
# # missing, so we fill with 1
|
||||
# epc_data["weight"] = epc_data["weight"].fillna(1)
|
||||
# TODO: Testing
|
||||
# If the postcode is different from the initial postcode, it doesn't make sense to have
|
||||
# any weightings
|
||||
if all(pd.isnull(epc_data["house_number_distance"])) or (postcode != initial_postcode):
|
||||
epc_data["weight"] = 1
|
||||
else:
|
||||
epc_data["weight"] = 1 / np.sqrt(epc_data["house_number_distance"] + 1)
|
||||
epc_data["weight"] = epc_data["weight"].fillna(epc_data["weight"].mean())
|
||||
|
||||
estimation_property_type = self._estimate_str(
|
||||
key="property-type", estimation_data=epc_data
|
||||
|
|
@ -621,7 +629,7 @@ class SearchEpc:
|
|||
|
||||
@staticmethod
|
||||
def _estimate_float(estimation_data, key):
|
||||
return np.average(a=estimation_data[key], weights=estimation_data["weight"])
|
||||
return round(np.average(a=estimation_data[key], weights=estimation_data["weight"]), 2)
|
||||
|
||||
@staticmethod
|
||||
def _estimate_str(estimation_data, key):
|
||||
|
|
|
|||
|
|
@ -155,6 +155,8 @@ class Recommendations:
|
|||
# For the moment, we cap the number of SAP points that can be achieved by ventilation at 2
|
||||
rec["sap_points"] = min(rec["sap_points"], VentilationRecommendations.SAP_LIMIT)
|
||||
|
||||
# Round to 2 decimal places
|
||||
rec["sap_points"] = round(rec["sap_points"], 2)
|
||||
rec["co2_equivalent_savings"] = float(property_instance.data["co2-emissions-current"]) - new_carbon
|
||||
|
||||
# Energy consumption current is per meter squared, so we need to multiply by the floor area to get
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue