handling missing weight possibilities and 0 weights

This commit is contained in:
Khalim Conn-Kowlessar 2024-01-02 18:15:29 +00:00
parent 81621eb1de
commit 748dc14271

View file

@ -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)