From dbf57f43f3f51a40f206f4bf82fb8673ff3039ba Mon Sep 17 00:00:00 2001 From: abhineethreddyk Date: Sun, 31 Jan 2021 20:24:43 -0500 Subject: [PATCH] Updated battery feature and its testing for periodic --- src/features/phone_battery/rapids/main.py | 4 +++- .../features/periodic/test01/phone_battery.csv | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/features/phone_battery/rapids/main.py b/src/features/phone_battery/rapids/main.py index 52b5199e..bc897719 100644 --- a/src/features/phone_battery/rapids/main.py +++ b/src/features/phone_battery/rapids/main.py @@ -26,6 +26,7 @@ def rapids_features(sensor_data_files, time_segment, provider, filter_data_by_se # for discharge episodes battery_discharge_episodes = battery_episodes[(battery_episodes["battery_status"] == 3) | (battery_episodes["battery_status"] == 4)] + battery_discharge_episodes = battery_discharge_episodes[battery_discharge_episodes['battery_consumption_rate'] !=0 ] battery_discharge_features = pd.DataFrame() if "countdischarge" in features_to_compute: battery_discharge_features["countdischarge"] = battery_discharge_episodes.groupby(["local_segment"])["episode_id"].count() @@ -38,6 +39,7 @@ def rapids_features(sensor_data_files, time_segment, provider, filter_data_by_se # for charge episodes battery_charge_episodes = battery_episodes[(battery_episodes["battery_status"] == 2) | (battery_episodes["battery_status"] == 5)] + battery_charge_episodes = battery_charge_episodes[battery_charge_episodes['battery_consumption_rate'] !=0 ] battery_charge_features = pd.DataFrame() if "countcharge" in features_to_compute: battery_charge_features["countcharge"] = battery_charge_episodes.groupby(["local_segment"])["episode_id"].count() @@ -50,4 +52,4 @@ def rapids_features(sensor_data_files, time_segment, provider, filter_data_by_se battery_features.index.rename("local_segment", inplace=True) battery_features = battery_features.reset_index() - return battery_features + return battery_features \ No newline at end of file diff --git a/tests/data/processed/features/periodic/test01/phone_battery.csv b/tests/data/processed/features/periodic/test01/phone_battery.csv index 7a7b0524..1ca6d8ac 100644 --- a/tests/data/processed/features/periodic/test01/phone_battery.csv +++ b/tests/data/processed/features/periodic/test01/phone_battery.csv @@ -1,6 +1,6 @@ "local_segment","local_segment_label","local_segment_start_datetime","local_segment_end_datetime","phone_battery_rapids_countdischarge","phone_battery_rapids_sumdurationdischarge","phone_battery_rapids_avgconsumptionrate","phone_battery_rapids_maxconsumptionrate","phone_battery_rapids_countcharge","phone_battery_rapids_sumdurationcharge" -"afternoon#2020-07-01 12:00:00,2020-07-01 17:59:59","afternoon","2020-07-01 12:00:00","2020-07-01 17:59:59",3,72.1543666666666,0.110607001356668,0.253301361072647,2,79.4708833333333 -"daily#2020-07-01 00:00:00,2020-07-01 23:59:59","daily","2020-07-01 00:00:00","2020-07-01 23:59:59",10,354.814433333333,0.0460723079161749,0.0809973837845038,5,199.701516666667 -"evening#2020-07-01 18:00:00,2020-07-01 23:59:59","evening","2020-07-01 18:00:00","2020-07-01 23:59:59",3,105.130116666667,0.0443305579467856,0.079525673538274,1,37.5236666666667 -"morning#2020-07-01 06:00:00,2020-07-01 11:59:59","morning","2020-07-01 06:00:00","2020-07-01 11:59:59",3,105.56345,0.0436773097317394,0.0731286084397727,2,42.61665 -"night#2020-07-01 00:00:00,2020-07-01 05:59:59","night","2020-07-01 00:00:00","2020-07-01 05:59:59",3,71.9664666666666,0.158782604300746,0.400338953647421,1,40.0903 +"afternoon#2020-07-01 12:00:00,2020-07-01 17:59:59","afternoon","2020-07-01 12:00:00","2020-07-01 17:59:59",2,42.1548666666667,0.165910502035002,0.253301361072647,2,79.4708833333333 +"daily#2020-07-01 00:00:00,2020-07-01 23:59:59","daily","2020-07-01 00:00:00","2020-07-01 23:59:59",6,234.816433333333,0.0767871798602915,0.0809973837845038,5,199.701516666667 +"evening#2020-07-01 18:00:00,2020-07-01 23:59:59","evening","2020-07-01 18:00:00","2020-07-01 23:59:59",2,75.1306166666666,0.0664958369201784,0.079525673538274,1,37.5236666666667 +"morning#2020-07-01 06:00:00,2020-07-01 11:59:59","morning","2020-07-01 06:00:00","2020-07-01 11:59:59",2,75.56395,0.065515964597609,0.0731286084397727,2,42.61665 +"night#2020-07-01 00:00:00,2020-07-01 05:59:59","night","2020-07-01 00:00:00","2020-07-01 05:59:59",2,41.9669666666667,0.23817390645112,0.400338953647421,1,40.0903