diff --git a/modules/ml-pipeline/src/pipeline/configs/feature_processor_logic.py b/modules/ml-pipeline/src/pipeline/configs/feature_processor_logic.py index 103168d..35e496f 100644 --- a/modules/ml-pipeline/src/pipeline/configs/feature_processor_logic.py +++ b/modules/ml-pipeline/src/pipeline/configs/feature_processor_logic.py @@ -5,7 +5,7 @@ During the feature processor step, we can apply additional business logic and fe """ Business Logic dict + functions """ - +import pandas as pd def remove_starting_columns(df): keep_column_index = [ @@ -44,6 +44,20 @@ def keep_non_zero_rdsap(df): df = df[df["rdsap_change"] != 0] return df +def bin_photo_supply(df): + # Define the bins in increments of 5 + bins = [-1, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100] + # bins = [-1, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] + + # Define the labels of increments of 5 + labels = ['0', '1-5', '6-10', '11-15', '16-20', '21-25', '26-30', '31-35', '36-40', '41-45', '46-50', '51-55', '56-60', '61-65', '66-70', '71-75', '76-80', '81-85', '86-90', '91-95', '96-100'] + # labels = ['0', '1-10', '11-20', '21-30', '31-40', '41-50', '51-60', '61-70', '71-80', '81-90', '91-100'] + + # Create a new column with the binned data + df['photo_supply_starting'] = pd.cut(df['photo_supply_starting'], bins=bins, labels=labels) + df['photo_supply_ending'] = pd.cut(df['photo_supply_ending'], bins=bins, labels=labels) + + return df # def keep_ending_columns(df): # ending_column_index = [ col_name.endswith("_ENDING") for col_name in list(df.columns)] @@ -54,12 +68,7 @@ def keep_non_zero_rdsap(df): # return df business_logic = { - # "keep_non_zero_rdsap": keep_non_zero_rdsap, - # "keep_flats": keep_flats, - # "remove_minimum_habitable_room_size": remove_minimum_habitable_room_size, - # "remove_floor_height_ending": remove_floor_height_ending - # "remove_starting_columns": remove_starting_columns - # "keep_ENDING_COLUMNS": keep_ending_columns + # "bin_photo_supply": bin_photo_supply } """ diff --git a/modules/ml-pipeline/src/pipeline/configs/settings.yaml b/modules/ml-pipeline/src/pipeline/configs/settings.yaml index 9e52a1d..5f22d3a 100644 --- a/modules/ml-pipeline/src/pipeline/configs/settings.yaml +++ b/modules/ml-pipeline/src/pipeline/configs/settings.yaml @@ -18,11 +18,7 @@ default: prepare_data: input_dataclient_type: aws-s3 output_dataclient_type: local - # data_filepath: s3://retrofit-data-dev/sap_change_model/2024-03-22-18-56-53/dataset_rooms.parquet - # data_filepath: s3://retrofit-data-dev/sap_change_model/2024-05-25-08-36-36/dataset_rooms.parquet - # data_filepath: s3://retrofit-data-dev/sap_change_model/2024-05-26-10-31-39/dataset_rooms.parquet - # data_filepath: s3://retrofit-data-dev/sap_change_model/2024-05-28-19-08-25/dataset_rooms.parquet - data_filepath: s3://retrofit-data-dev/sap_change_model/2024-07-03-23-11-39/dataset_rooms.parquet + data_filepath: s3://retrofit-data-dev/sap_change_model/2024-08-06-11-19-49/dataset_rooms.parquet train_proportion: 0.9 output_train_filepath: ./data/prepared_data/train.parquet output_test_filepath: ./data/prepared_data/test.parquet @@ -34,37 +30,13 @@ default: subsample_seed: 0 target: heating_cost_ending identifier_columns: ["uprn"] - # drop_columns: ["heat_demand_change", "carbon_change", "rdsap_change", "heat_demand_ending", "carbon_ending", "days_to_starting", "days_to_ending"] drop_columns: [ "sap_ending", "heat_demand_change", "carbon_change", "rdsap_change", "heat_demand_ending", "carbon_ending", "lighting_cost_ending", "hot_water_cost_ending", - # "days_to_starting", "days_to_ending", + "days_to_ending", "days_to_starting", 'number_habitable_rooms_starting', 'number_habitable_rooms_ending', 'number_heated_rooms_starting', 'number_heated_rooms_ending', 'number_habitable_rooms', 'number_heated_rooms'] retain_features: null - # retain_features: ['uprn', 'sap_starting', 'hot_water_energy_eff_ending', - # 'mainheat_energy_eff_ending', 'constituency', 'roof_energy_eff_ending', - # 'walls_energy_eff_ending', 'secondheat_description_ending', - # 'property_type', 'mainheatc_energy_eff_ending', 'built_form', - # 'walls_insulation_thickness_ending', 'potential_energy_efficiency', - # 'transaction_type_ending', - # 'floor_thermal_transmittance_ending', - # 'low_energy_lighting_ending', 'heat_demand_starting', - # 'photo_supply_ending', 'carbon_starting', - # 'walls_thermal_transmittance_ending', - # 'roof_insulation_thickness_ending', - # 'total_floor_area_ending', 'number_open_fireplaces_ending', - # 'windows_energy_eff_ending', - # 'floor_height_ending', - # 'extension_count_ending', - # 'has_air_source_heat_pump_ending', - # 'charging_system_ending', 'construction_age_band', 'glazed_type_ending', - # 'roof_thermal_transmittance_ending', - # 'floor_insulation_thickness_ending', 'has_mains_gas_ending', - # 'estimated_perimeter_starting', 'energy_consumption_potential', - # 'environment_impact_potential', 'heater_type_ending', - # 'multi_glaze_proportion_ending', - # 'lighting_energy_eff_ending', 'fixed_lighting_outlets_count'] generate_predictions: input_dataclient_type: local diff --git a/modules/ml-pipeline/src/pipeline/dvc.lock b/modules/ml-pipeline/src/pipeline/dvc.lock index 917288c..4e82c62 100644 --- a/modules/ml-pipeline/src/pipeline/dvc.lock +++ b/modules/ml-pipeline/src/pipeline/dvc.lock @@ -29,6 +29,8 @@ stages: - carbon_ending - lighting_cost_ending - hot_water_cost_ending + - days_to_ending + - days_to_starting - number_habitable_rooms_starting - number_habitable_rooms_ending - number_heated_rooms_starting @@ -41,7 +43,7 @@ stages: default.feature_processor.feature_processor_config.target: heating_cost_ending default.feature_processor.feature_processor_type: dataframe default.prepare_data.data_filepath: - s3://retrofit-data-dev/sap_change_model/2024-07-03-23-11-39/dataset_rooms.parquet + s3://retrofit-data-dev/sap_change_model/2024-08-06-11-19-49/dataset_rooms.parquet default.prepare_data.input_dataclient_type: aws-s3 default.prepare_data.output_dataclient_type: local default.prepare_data.output_test_filepath: ./data/prepared_data/test.parquet @@ -50,8 +52,8 @@ stages: outs: - path: data/prepared_data/ hash: md5 - md5: c470ebd5aad4f86b99de53ae4778daac.dir - size: 49274194 + md5: 13346c4e055a5ffdb182ec25c8c58544.dir + size: 53753539 nfiles: 2 build_model: cmd: python 2_build_model.py @@ -62,8 +64,8 @@ stages: size: 4820 - path: data/prepared_data hash: md5 - md5: c470ebd5aad4f86b99de53ae4778daac.dir - size: 49274194 + md5: 13346c4e055a5ffdb182ec25c8c58544.dir + size: 53753539 nfiles: 2 params: configs/build_model.yaml: @@ -95,18 +97,18 @@ stages: outs: - path: data/fit_predictions/ hash: md5 - md5: 41bd7d095c49076861fc242121173c9e.dir - size: 3445925 + md5: 9c13222c2db372b376d7e7d3f778cf9b.dir + size: 3550468 nfiles: 1 - path: data/model/ hash: md5 - md5: 03fc0b07da59a7f1ba6d2fbb5502ae90.dir - size: 780161990 + md5: c653c6d2eedb97aeea67ff8a15af825a.dir + size: 832419878 nfiles: 36 - path: metrics/fit_metrics.json hash: md5 - md5: dc94170c8db0bde6239046def42e616e - size: 225 + md5: 45e1e99b6125b9c97978402c62165cf6 + size: 221 generate_predictions: cmd: python 3_generate_predictions.py deps: @@ -116,13 +118,13 @@ stages: size: 2464 - path: data/model hash: md5 - md5: 03fc0b07da59a7f1ba6d2fbb5502ae90.dir - size: 780161990 + md5: c653c6d2eedb97aeea67ff8a15af825a.dir + size: 832419878 nfiles: 36 - path: data/prepared_data hash: md5 - md5: c470ebd5aad4f86b99de53ae4778daac.dir - size: 49274194 + md5: 13346c4e055a5ffdb182ec25c8c58544.dir + size: 53753539 nfiles: 2 params: configs/settings.yaml: @@ -134,8 +136,8 @@ stages: outs: - path: data/predictions/ hash: md5 - md5: 17f2f6b46e486ecce4453eaa32b80509.dir - size: 480739 + md5: 81434d05d87171aa43b16eb20705ddcd.dir + size: 497824 nfiles: 1 generate_metrics: cmd: python 4_generate_metrics.py @@ -146,13 +148,13 @@ stages: size: 3484 - path: data/predictions hash: md5 - md5: 17f2f6b46e486ecce4453eaa32b80509.dir - size: 480739 + md5: 81434d05d87171aa43b16eb20705ddcd.dir + size: 497824 nfiles: 1 - path: data/prepared_data hash: md5 - md5: c470ebd5aad4f86b99de53ae4778daac.dir - size: 49274194 + md5: 13346c4e055a5ffdb182ec25c8c58544.dir + size: 53753539 nfiles: 2 params: configs/settings.yaml: @@ -162,7 +164,7 @@ stages: outs: - path: metrics/metrics.json hash: md5 - md5: 2d9cf9eb1bb35878d2be076b34bb6cf5 + md5: 370ca59a842b3ebc8adf6d1ed11314ec size: 220 generate_scenerio_metrics: cmd: python 5_generate_scenarios.py