working on the estimate epc method

This commit is contained in:
Khalim Conn-Kowlessar 2023-12-29 17:12:15 +00:00
parent eeb3653afa
commit 7f9b4da56f
4 changed files with 1801 additions and 8 deletions

48
backend/OrdnanceSurvey.py Normal file
View file

@ -0,0 +1,48 @@
class OrdnanceSuveyClient:
def __init__(self, address, postcode):
"""
This class is tasked with interaction with the ordnance survey API.
:param address:
:param postcode:
"""
self.address = address
self.postcode = postcode
def get_places_api(self):
"""
This method is tasked with getting the places api from the Ordnance Survey.
:return:
"""
pass
@staticmethod
def parse_classification_code(classification_code: str):
"""
This function will convert the classification code, returned by the OS places api, to a property type that is
compatible with the EPC database.
The various classifications cane be found here:
https://osdatahub.os.uk/docs/places/technicalSpecification
Under LPI Output, CLASSIFICATION_CODE is described, and a link is provided to the full table of classifications
For these purposes, we do not need the full classification as this includes non-residential properties. We only
parse the ones of interest to us
:return:
"""
value_map = {
# In the OS api, "RD" is a "Dwelling" however this is not valid property type in the EPC database
'RD': {},
'RD02': {'property_type': 'House', 'built_form': 'Detatched'},
'RD03': {'property_type': 'House', 'built_form': 'Semi-Detatched'},
'RD04': {'property_type': 'House', 'built_form': 'Mid-Terrace'},
'RD06': {'property_type': 'Flat'},
}
mapped = value_map.get(classification_code, {})
property_type = mapped.get("property_type", "")
built_form = mapped.get("built_form", "")
return property_type, built_form

File diff suppressed because it is too large Load diff

View file

@ -35,4 +35,5 @@ mip==1.15.0
boto3==1.28.3
pandas==1.5.3
pyarrow==12.0.1
textblob
textblob
usaddress==0.5.10

View file

@ -637,13 +637,6 @@ def app():
file_key="sap_change_model/dataset_test.parquet",
)
z = dataset[dataset["CONSTITUENCY"].isin(["E14000707", "E14000909"])]
z["CONSTITUENCY"].value_counts()
z[z["CONSTITUENCY"] == "E14000909"]["UPRN"].sample(1)
self.data[self.data["UPRN"] == "100030549358"]
if __name__ == "__main__":
app()