mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
working on the estimate epc method
This commit is contained in:
parent
eeb3653afa
commit
7f9b4da56f
4 changed files with 1801 additions and 8 deletions
48
backend/OrdnanceSurvey.py
Normal file
48
backend/OrdnanceSurvey.py
Normal 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
|
||||||
1751
backend/SearchEpc.py
1751
backend/SearchEpc.py
File diff suppressed because it is too large
Load diff
|
|
@ -35,4 +35,5 @@ mip==1.15.0
|
||||||
boto3==1.28.3
|
boto3==1.28.3
|
||||||
pandas==1.5.3
|
pandas==1.5.3
|
||||||
pyarrow==12.0.1
|
pyarrow==12.0.1
|
||||||
textblob
|
textblob
|
||||||
|
usaddress==0.5.10
|
||||||
|
|
@ -637,13 +637,6 @@ def app():
|
||||||
file_key="sap_change_model/dataset_test.parquet",
|
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__":
|
if __name__ == "__main__":
|
||||||
app()
|
app()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue