Start to test empatica_data_yield precieved error.

imputation_and_cleaning
Primoz 2022-10-26 14:18:08 +00:00
parent 936324d234
commit a31fdd1479
1 changed files with 17 additions and 9 deletions

View File

@ -4,23 +4,31 @@ from datetime import datetime
import sys import sys
def calculate_empatica_data_yield(features): def calculate_empatica_data_yield(features): # TODO
# Get time segment duration in seconds from dataframe # Get time segment duration in seconds from dataframe
datetime_start = datetime.strptime(features.loc[0, 'local_segment_start_datetime'], '%Y-%m-%d %H:%M:%S') datetime_start = datetime.strptime(features.loc[0, 'local_segment_start_datetime'], '%Y-%m-%d %H:%M:%S')
datetime_end = datetime.strptime(features.loc[0, 'local_segment_end_datetime'], '%Y-%m-%d %H:%M:%S') datetime_end = datetime.strptime(features.loc[0, 'local_segment_end_datetime'], '%Y-%m-%d %H:%M:%S')
tseg_duration = (datetime_end - datetime_start).total_seconds() tseg_duration = (datetime_end - datetime_start).total_seconds()
features["acc_data_yield"] = (features['empatica_accelerometer_cr_SO_windowsCount'] * 15) / tseg_duration \ features["acc_data_yield"] = (features['empatica_accelerometer_cr_SO_windowsCount'] * 15) / tseg_duration if 'empatica_accelerometer_cr_SO_windowsCount' in features else 0
if 'empatica_accelerometer_cr_SO_windowsCount' in features else 0 features["temp_data_yield"] = (features['empatica_temperature_cr_SO_windowsCount'] * 300) / tseg_duration if 'empatica_temperature_cr_SO_windowsCount' in features else 0
features["temp_data_yield"] = (features['empatica_temperature_cr_SO_windowsCount'] * 300) / tseg_duration \ features["eda_data_yield"] = (features['empatica_electrodermal_activity_cr_SO_windowsCount'] * 60) / tseg_duration if 'empatica_electrodermal_activity_cr_SO_windowsCount' in features else 0
if 'empatica_temperature_cr_SO_windowsCount' in features else 0 features["ibi_data_yield"] = (features['empatica_inter_beat_interval_cr_SO_windowsCount'] * 300) / tseg_duration if 'empatica_inter_beat_interval_cr_SO_windowsCount' in features else 0
features["eda_data_yield"] = (features['empatica_electrodermal_activity_cr_SO_windowsCount'] * 60) / tseg_duration \
if 'empatica_electrodermal_activity_cr_SO_windowsCount' in features else 0
features["ibi_data_yield"] = (features['empatica_inter_beat_interval_cr_SO_windowsCount'] * 300) / tseg_duration \
if 'empatica_inter_beat_interval_cr_SO_windowsCount' in features else 0
empatica_data_yield_cols = ['acc_data_yield', 'temp_data_yield', 'eda_data_yield', 'ibi_data_yield'] empatica_data_yield_cols = ['acc_data_yield', 'temp_data_yield', 'eda_data_yield', 'ibi_data_yield']
pd.set_option('display.max_rows', None)
print(tseg_duration)
print(features['empatica_accelerometer_cr_SO_windowsCount'])
print(features['empatica_temperature_cr_SO_windowsCount'])
print(features['empatica_electrodermal_activity_cr_SO_windowsCount'])
print(features['empatica_inter_beat_interval_cr_SO_windowsCount'])
# print((features['empatica_inter_beat_interval_cr_SO_windowsCount'] * 300) / tseg_duration)
sys.exit()
features["empatica_data_yield"] = features[empatica_data_yield_cols].mean(axis=1).fillna(0) features["empatica_data_yield"] = features[empatica_data_yield_cols].mean(axis=1).fillna(0)
features.drop(empatica_data_yield_cols, axis=1, inplace=True) # In case of if the advanced operations will later not be needed (e.g., weighted average) features.drop(empatica_data_yield_cols, axis=1, inplace=True) # In case of if the advanced operations will later not be needed (e.g., weighted average)
return features return features