Add logic for target selection in ERS processing.

imputation_and_cleaning
Primoz 2022-11-03 09:30:12 +00:00
parent 0ce8723bdb
commit 02264b21fd
2 changed files with 5 additions and 9 deletions

View File

@ -26,7 +26,7 @@ TIME_SEGMENTS: &time_segments
INCLUDE_PAST_PERIODIC_SEGMENTS: TRUE # Only relevant if TYPE=PERIODIC, see docs INCLUDE_PAST_PERIODIC_SEGMENTS: TRUE # Only relevant if TYPE=PERIODIC, see docs
TAILORED_EVENTS: # Only relevant if TYPE=EVENT TAILORED_EVENTS: # Only relevant if TYPE=EVENT
COMPUTE: True COMPUTE: True
PARAMETER_ONE: "something" TARGETS_METHOD: "none"
# See https://www.rapids.science/latest/setup/configuration/#timezone-of-your-study # See https://www.rapids.science/latest/setup/configuration/#timezone-of-your-study
TIMEZONE: TIMEZONE:

View File

@ -28,17 +28,13 @@ def extract_ers_from_file(esm_df, device_id):
pd.set_option("display.max_rows", None) pd.set_option("display.max_rows", None)
pd.set_option("display.max_columns", None) pd.set_option("display.max_columns", None)
# extracted_ers = pd.DataFrame(columns=["label", "event_timestamp", "length", "shift", "shift_direction", "device_id"]) with open('config.yaml', 'r') as stream:
config = yaml.load(stream, Loader=yaml.FullLoader)
targets_method = config["TIME_SEGMENTS"]["TAILORED_EVENTS"]["TARGETS_METHOD"]
# esm_df = clean_up_esm(preprocess_esm(esm_df))
esm_preprocessed = clean_up_esm(preprocess_esm(esm_df)) esm_preprocessed = clean_up_esm(preprocess_esm(esm_df))
# Take only during work sessions
# during_work = esm_df[esm_df["esm_trigger"].str.contains("during_work", na=False)]
# esm_trigger_group = esm_df.groupby("esm_session").agg(pd.Series.mode)['esm_trigger'] # Get most frequent esm_trigger within particular session
# esm_filtered_sessions = list(esm_trigger_group[esm_trigger_group == 'during_work'].index) # Take only sessions that contains during work
# Take only ema_completed sessions responses # Take only ema_completed sessions responses
classified = classify_sessions_by_completion_time(esm_preprocessed) classified = classify_sessions_by_completion_time(esm_preprocessed)
esm_filtered_sessions = classified[classified["session_response"] == 'ema_completed'].reset_index()['esm_session'] esm_filtered_sessions = classified[classified["session_response"] == 'ema_completed'].reset_index()['esm_session']