Model/backend/ml_models/Valuation.py
2023-11-28 11:41:34 +00:00

43 lines
1.2 KiB
Python

class PropertyValuation:
"""
This is a placeholder class for the property valuation model
"""
UPRN_VALUE_LOOKUP = {
15038202: 202000,
37024763: 213000,
}
VALUE_INCREASE_MAPPING = [
{
"starting_epc": "D",
"ending_epc": "C",
"increase_percentage": 0.057,
},
{
"starting_epc": "D",
"ending_epc": "B",
"increase_percentage": 0.057,
},
]
@classmethod
def estimate(cls, property_instance, target_epc):
current_value = cls.UPRN_VALUE_LOOKUP.get(property_instance.uprn)
if not current_value:
raise ValueError("Have not implemented valuation for this property")
valuation_increases = [
v for v in cls.VALUE_INCREASE_MAPPING if
v["starting_epc"] == property_instance.epc_band and v["ending_epc"] == target_epc
]
if len(valuation_increases) != 1:
raise ValueError("Valuation increase mapping not found")
new_valuation = (1 + valuation_increases[0]["increase_percentage"]) * current_value
increase = round(new_valuation - current_value, 2)
return increase