mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Added missing files
This commit is contained in:
parent
68f3911ff8
commit
f321f46e54
7 changed files with 120 additions and 3 deletions
2
.idea/Model.iml
generated
2
.idea/Model.iml
generated
|
|
@ -7,7 +7,7 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/open_uprn" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/open_uprn" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/recommendations" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/recommendations" isTestSource="false" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.10 (backend)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.10 (model_data)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PyNamespacePackagesService">
|
<component name="PyNamespacePackagesService">
|
||||||
|
|
|
||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
|
@ -3,7 +3,7 @@
|
||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.10 (backend)" />
|
<option name="sdkName" value="Python 3.10 (backend)" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (backend)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (model_data)" project-jdk-type="Python SDK" />
|
||||||
<component name="PythonCompatibilityInspectionAdvertiser">
|
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
82
backend/tests/test_annual_bill_savings.py
Normal file
82
backend/tests/test_annual_bill_savings.py
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
import numpy as np
|
||||||
|
import pytest
|
||||||
|
from backend.ml_models.AnnualBillSavings import AnnualBillSavings
|
||||||
|
|
||||||
|
appliance_consumption_cases = [
|
||||||
|
{
|
||||||
|
"total_floor_area": 13.9,
|
||||||
|
"n_occupants": 1,
|
||||||
|
"consumption": 718.4795859263703
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 20,
|
||||||
|
"n_occupants": 1.0306381042556767,
|
||||||
|
"consumption": 865.2316409517844
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 30,
|
||||||
|
"n_occupants": 1.1731577598127325,
|
||||||
|
"consumption": 1113.5965321501362
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 50,
|
||||||
|
"n_occupants": 1.6901008890848956,
|
||||||
|
"consumption": 1683.31305074609
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 75,
|
||||||
|
"n_occupants": 2.361158387531988,
|
||||||
|
"consumption": 2386.2935599981865
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 100,
|
||||||
|
"n_occupants": 2.739525875076067,
|
||||||
|
"consumption": 2931.6076153011486
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 125,
|
||||||
|
"n_occupants": 2.8807344137165405,
|
||||||
|
"consumption": 3335.143110751552
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 150,
|
||||||
|
"n_occupants": 2.934188599837662,
|
||||||
|
"consumption": 3666.3228057866513
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 200,
|
||||||
|
"n_occupants": 3.001920087128373,
|
||||||
|
"consumption": 4244.625403339813
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 300,
|
||||||
|
"n_occupants": 3.1319299999993095,
|
||||||
|
"consumption": 5243.086106676302
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 500,
|
||||||
|
"n_occupants": 3.39193,
|
||||||
|
"consumption": 6927.400500420533
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"total_floor_area": 1000,
|
||||||
|
"n_occupants": 4.04193,
|
||||||
|
"consumption": 10434.755635642652
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class TestAnnualBillSavings:
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"test_case",
|
||||||
|
appliance_consumption_cases
|
||||||
|
)
|
||||||
|
def test_appliance_estimation(self, test_case):
|
||||||
|
n_occupants = AnnualBillSavings.calculate_occupants(test_case["total_floor_area"])
|
||||||
|
assert np.isclose(n_occupants, test_case["n_occupants"])
|
||||||
|
|
||||||
|
appliance_consumption = AnnualBillSavings.estimate_electrical_appliances(
|
||||||
|
n_occupants, test_case["total_floor_area"]
|
||||||
|
)
|
||||||
|
assert np.isclose(appliance_consumption, test_case["consumption"])
|
||||||
17
etl/customers/vander_elliot/non_intrusives.py
Normal file
17
etl/customers/vander_elliot/non_intrusives.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
from etl.non_intrusive_surveys.upload.UploadNonIntrusives import UploadNonIntrusives
|
||||||
|
|
||||||
|
|
||||||
|
def app():
|
||||||
|
"""
|
||||||
|
This script handles the creation of the portfolio for the non-intrusive surveys
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
|
||||||
|
non_intrusive_s3_filename = (
|
||||||
|
"customers/Vander Elliot/Non-intrusive survey template V2 - Amazon Management Services.xlsx"
|
||||||
|
)
|
||||||
|
|
||||||
|
non_intrusive = UploadNonIntrusives(
|
||||||
|
s3_template_location=non_intrusive_s3_filename,
|
||||||
|
s3_bucket="retrofit-datalake-dev",
|
||||||
|
)
|
||||||
|
|
@ -15,5 +15,5 @@ pip install -r requirements.txt
|
||||||
The main application is found in the app.py file. To run the application, use the following command:
|
The main application is found in the app.py file. To run the application, use the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python app.py
|
python UploadNonIntrusives.py
|
||||||
```
|
```
|
||||||
18
etl/non_intrusive_surveys/upload/UploadNonIntrusives.py
Normal file
18
etl/non_intrusive_surveys/upload/UploadNonIntrusives.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
from utils.s3 import read_excel_from_s3
|
||||||
|
|
||||||
|
|
||||||
|
class UploadNonIntrusives:
|
||||||
|
"""
|
||||||
|
This class handles the upload of findings from the non-intrusive surveys, to the database
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, s3_template_location, s3_bucket):
|
||||||
|
self.s3_template_location = s3_template_location
|
||||||
|
self.s3_bucket = s3_bucket
|
||||||
|
self.template = self.read_template()
|
||||||
|
|
||||||
|
def read_template(self):
|
||||||
|
"""
|
||||||
|
This method reads the template from S3
|
||||||
|
"""
|
||||||
|
return read_excel_from_s3(file_key=self.s3_template_location, bucket_name=self.s3_bucket, header_row=0)
|
||||||
0
etl/non_intrusive_surveys/upload/__init__.py
Normal file
0
etl/non_intrusive_surveys/upload/__init__.py
Normal file
Loading…
Add table
Reference in a new issue