Fix the bug of location doryab features when a participant is moving during the whole time segment

models
Meng Li 2021-11-18 18:42:19 -05:00
parent 3d34036eae
commit 296960f425
1 changed files with 5 additions and 2 deletions

View File

@ -180,6 +180,9 @@ def doryab_features(sensor_data_files, time_segment, provider, filter_data_by_se
location_features = location_features.merge(location_entropy(stationary_data_without_outliers), how="outer", left_index=True, right_index=True)
# time at home
if stationary_data.empty:
location_features["timeathome"] = 0
else:
stationary_data["time_at_home"] = stationary_data.apply(lambda row: row["duration"] if row["distance_from_home"] <= radius_from_home else 0, axis=1)
location_features["timeathome"] = stationary_data[["local_segment", "time_at_home"]].groupby(["local_segment"])["time_at_home"].sum()