add restriction to datast

This commit is contained in:
Michael Duong 2023-11-28 14:51:55 +00:00
parent 7f984e6cbf
commit 9271df34e0
2 changed files with 55 additions and 20 deletions

View file

@ -23,6 +23,37 @@ def keep_negative_heat_change(df):
return df
def keep_negative_carbon_change(df):
df = df[df["CARBON_CHANGE"] < 0]
return df
# TODO: Move to ETL pipeline
def remove_unreasonable_habitable_rooms(df):
"""
Assumption is that proportion of floor area to habitable rooms should be at least 6.5m2
"""
minimum_room_size_index = (
df["TOTAL_FLOOR_AREA_ENDING"] / df["NUMBER_HABITABLE_ROOMS"] >= 6.5
)
df = df[minimum_room_size_index]
return df
def remove_top_1_percent_heat_demand(df):
# threshold_value = df.describe(percentiles=[0.99])['HEAT_DEMAND_STARTING']['99%']
threshold_value = 860
df = df[df["HEAT_DEMAND_STARTING"] < threshold_value]
return df
def remove_top_1_percent_carbon(df):
# threshold_value = df.describe(percentiles=[0.99])['CARBON_STARTING']['99%']
threshold_value = 18
df = df[df["CARBON_STARTING"] < threshold_value]
return df
# def keep_ending_columns(df):
# ending_column_index = [ col_name.endswith("_ENDING") for col_name in list(df.columns)]
# keep_columns = df.columns[ending_column_index].to_list()
@ -32,7 +63,11 @@ def keep_negative_heat_change(df):
# return df
business_logic = {
"keep_negative_heat_change": keep_negative_heat_change
"remove_unreasonable_habitable_rooms": remove_unreasonable_habitable_rooms,
"keep_negative_heat_change": keep_negative_heat_change,
"keep_negative_carbon_change": keep_negative_carbon_change,
"remove_top_1_percent_heat_demand": remove_top_1_percent_heat_demand,
"remove_top_1_percent_carbon": remove_top_1_percent_carbon,
# "remove_starting_columns": remove_starting_columns
# "keep_ENDING_COLUMNS": keep_ending_columns
}

View file

@ -29,8 +29,8 @@ stages:
outs:
- path: data/prepared_data/
hash: md5
md5: 6f9c63363ad52a836524dbb6fae7a2ac.dir
size: 34480114
md5: f235f38714fefcf6e4927ae95ba912c3.dir
size: 30774760
nfiles: 2
build_model:
cmd: python 2_build_model.py
@ -41,8 +41,8 @@ stages:
size: 4149
- path: data/prepared_data
hash: md5
md5: 6f9c63363ad52a836524dbb6fae7a2ac.dir
size: 34480114
md5: f235f38714fefcf6e4927ae95ba912c3.dir
size: 30774760
nfiles: 2
params:
configs/build_model.yaml:
@ -68,13 +68,13 @@ stages:
outs:
- path: data/model/
hash: md5
md5: 452eba2d92233e81d321814aacefe5c2.dir
size: 323127043
md5: a868845999b46e0272dc27f5cb5bc618.dir
size: 310555147
nfiles: 24
- path: metrics/fit_metrics.json
hash: md5
md5: 888124b56e0c5008a6423e290fc5cc71
size: 222
md5: 809f27735c77cbcb62866b96018eedea
size: 216
generate_predictions:
cmd: python 3_generate_predictions.py
deps:
@ -84,13 +84,13 @@ stages:
size: 2464
- path: data/model
hash: md5
md5: 452eba2d92233e81d321814aacefe5c2.dir
size: 323127043
md5: a868845999b46e0272dc27f5cb5bc618.dir
size: 310555147
nfiles: 24
- path: data/prepared_data
hash: md5
md5: 6f9c63363ad52a836524dbb6fae7a2ac.dir
size: 34480114
md5: f235f38714fefcf6e4927ae95ba912c3.dir
size: 30774760
nfiles: 2
params:
configs/settings.yaml:
@ -102,8 +102,8 @@ stages:
outs:
- path: data/predictions/
hash: md5
md5: f852550a0a51f0c2b120b0680c1a9b54.dir
size: 325890
md5: 2098fe82304751025e427f2cc241a2ff.dir
size: 295849
nfiles: 1
generate_metrics:
cmd: python 4_generate_metrics.py
@ -114,13 +114,13 @@ stages:
size: 3448
- path: data/predictions
hash: md5
md5: f852550a0a51f0c2b120b0680c1a9b54.dir
size: 325890
md5: 2098fe82304751025e427f2cc241a2ff.dir
size: 295849
nfiles: 1
- path: data/prepared_data
hash: md5
md5: 6f9c63363ad52a836524dbb6fae7a2ac.dir
size: 34480114
md5: f235f38714fefcf6e4927ae95ba912c3.dir
size: 30774760
nfiles: 2
params:
configs/settings.yaml:
@ -130,7 +130,7 @@ stages:
outs:
- path: metrics/metrics.json
hash: md5
md5: ed3012943593fac4ac7ad9a5499ac18f
md5: aa671878e1bd8c6a8d4b5f9788c817c4
size: 219
startup_cleanup:
cmd: python 0_startup_cleanup.py