Begin the ERS logic for 90-minutes events.
parent
1da72a7cbe
commit
2d83f7ddec
|
@ -39,7 +39,6 @@ def extract_ers_from_file(esm_df, device_id):
|
||||||
esm_df = esm_preprocessed.loc[(esm_preprocessed['device_id'].isin(esm_filtered_sessions['device_id'])) & (esm_preprocessed['esm_session'].isin(esm_filtered_sessions['esm_session']))]
|
esm_df = esm_preprocessed.loc[(esm_preprocessed['device_id'].isin(esm_filtered_sessions['device_id'])) & (esm_preprocessed['esm_session'].isin(esm_filtered_sessions['esm_session']))]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Problem ne bo ekstrahiranje posameznih začetkov in trajanj stresnih dogodkov - večji problem je pridobitev ustreznega targeta,
|
# Problem ne bo ekstrahiranje posameznih začetkov in trajanj stresnih dogodkov - večji problem je pridobitev ustreznega targeta,
|
||||||
# tako da bo poravnan s tem dogodkom, saj se lahko zgodi, da je timestamp zabeležene intenzitete stresnega dogodka ne pade v okno stresnega dogodka.
|
# tako da bo poravnan s tem dogodkom, saj se lahko zgodi, da je timestamp zabeležene intenzitete stresnega dogodka ne pade v okno stresnega dogodka.
|
||||||
# Edina izjema tega so, če je označen odgovor "1 - Še vedno traja" pri vprašanju appraisal_event_duration
|
# Edina izjema tega so, če je označen odgovor "1 - Še vedno traja" pri vprašanju appraisal_event_duration
|
||||||
|
@ -71,9 +70,11 @@ def extract_ers_from_file(esm_df, device_id):
|
||||||
extracted_ers['diffs'] = extracted_ers['event_timestamp'].astype('int64') - extracted_ers['end_event_timestamp'].shift(1, fill_value=0).astype('int64')
|
extracted_ers['diffs'] = extracted_ers['event_timestamp'].astype('int64') - extracted_ers['end_event_timestamp'].shift(1, fill_value=0).astype('int64')
|
||||||
extracted_ers.loc[extracted_ers['diffs'] > time_before_questionnaire * 1000, 'diffs'] = time_before_questionnaire * 1000
|
extracted_ers.loc[extracted_ers['diffs'] > time_before_questionnaire * 1000, 'diffs'] = time_before_questionnaire * 1000
|
||||||
|
|
||||||
# TODO: združi celotno trajanje in formatiraj v HH:MM:SS
|
extracted_ers["diffs"] = (extracted_ers["diffs"] / 1000).apply(lambda x: math.ceil(x))
|
||||||
|
|
||||||
|
extracted_ers["length"] = (extracted_ers["timestamp"] + extracted_ers["diffs"]).apply(lambda x: format_timestamp(x))
|
||||||
|
extracted_ers["shift"] = extracted_ers["diffs"].apply(lambda x: format_timestamp(x))
|
||||||
|
|
||||||
sys.exit()
|
|
||||||
elif targets_method == "stress_events":
|
elif targets_method == "stress_events":
|
||||||
pass
|
pass
|
||||||
# VV Testiranje različnih povpraševanj za VV
|
# VV Testiranje različnih povpraševanj za VV
|
||||||
|
@ -83,9 +84,9 @@ def extract_ers_from_file(esm_df, device_id):
|
||||||
# print(filter_esm.shape)
|
# print(filter_esm.shape)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
raise Exception("Please select correct target method for the event-related segments.")
|
||||||
extracted_ers = pd.DataFrame(columns=["label", "event_timestamp", "length", "shift", "shift_direction", "device_id"])
|
extracted_ers = pd.DataFrame(columns=["label", "event_timestamp", "length", "shift", "shift_direction", "device_id"])
|
||||||
|
|
||||||
sys.exit()
|
|
||||||
return extracted_ers[["label", "event_timestamp", "length", "shift", "shift_direction", "device_id"]]
|
return extracted_ers[["label", "event_timestamp", "length", "shift", "shift_direction", "device_id"]]
|
||||||
|
|
||||||
if snakemake.params["stage"] == "extract":
|
if snakemake.params["stage"] == "extract":
|
||||||
|
|
Loading…
Reference in New Issue