diff --git a/backend/SearchEpc.py b/backend/SearchEpc.py index 6a0f3389..07a7de23 100644 --- a/backend/SearchEpc.py +++ b/backend/SearchEpc.py @@ -450,7 +450,10 @@ class SearchEpc: epc_data["house_number_distance"] = abs( epc_data["numeric_house_number"] - self.numeric_house_number ) - epc_data["weight"] = 1 / epc_data["house_number_distance"] + # 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()) epc_built_form = self._estimate_str(key="built-form", estimation_data=epc_data) epc_property_type = self._estimate_str(key="property-type", estimation_data=epc_data)