Implement the basic feature extraction steps.

labels
junos 2022-04-05 15:46:02 +02:00
parent 798ec973b4
commit ed298a9479
2 changed files with 14 additions and 4 deletions

View File

@ -240,7 +240,7 @@ PHONE_ESM:
STRAW:
COMPUTE: True
SCALES: ["PANAS_positive_affect", "PANAS_negative_affect", "JCQ_job_demand", "JCQ_job_control", "JCQ_supervisor_support", "JCQ_coworker_support"]
SRC_SCRIPT: src/features/phone_esm/rapids/main.py
SRC_SCRIPT: src/features/phone_esm/straw/main.py
# See https://www.rapids.science/latest/features/phone-keyboard/
PHONE_KEYBOARD:

View File

@ -2,6 +2,16 @@ import pandas as pd
def straw_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
# empty for now
your_features_df = pd.DataFrame()
return(your_features_df)
esm_data = pd.read_csv(sensor_data_files["sensor_data"])
requested_features = provider["FEATURES"]
# name of the features this function can compute
base_features_names = ["PANAS_positive_affect", "PANAS_negative_affect", "JCQ_job_demand", "JCQ_job_control", "JCQ_supervisor_support", "JCQ_coworker_support"]
# the subset of requested features this function can compute
features_to_compute = list(set(requested_features) & set(base_features_names))
esm_features = pd.DataFrame(columns=["local_segment"] + features_to_compute)
esm_data = filter_data_by_segment(esm_data, time_segment)
esm_features["mean"] = esm_data.groupby(["local_segment"])["esm_user_score"].mean()
#TODO Create the column esm_user_score in esm_clean. Currently, this is only done when reversing.
esm_features = esm_features.reset_index()
return esm_features