Small corrections.

communication
junos 2021-07-03 18:45:46 +02:00
parent a6d8f70e7f
commit b8301ca458
4 changed files with 21 additions and 14 deletions

View File

@ -212,7 +212,7 @@ class Call(Base, AWAREsensor):
call_type: int call_type: int
One of the Androids call types (1 incoming, 2 outgoing, 3 missed). One of the Androids call types (1 incoming, 2 outgoing, 3 missed).
call_duration: int call_duration: int
Length of the call session. Length of the call session in seconds.
trace: str(40) trace: str(40)
A hash value SHA-1 of the phone number (source or target) of the call A hash value SHA-1 of the phone number (source or target) of the call
""" """

View File

@ -62,7 +62,7 @@ df_calls_features.describe()
# %% # %%
calls_number = pd.wide_to_long( calls_number = pd.wide_to_long(
df_calls_features.reset_index(), df_calls_features[["no_incoming", "no_outgoing", "no_missed"]].reset_index(),
i="participant_id", i="participant_id",
j="call_type", j="call_type",
stubnames="no", stubnames="no",
@ -75,7 +75,9 @@ sns.displot(calls_number, x="no", hue="call_type", binwidth=5, element="step", h
# %% # %%
calls_duration = pd.wide_to_long( calls_duration = pd.wide_to_long(
df_calls_features.reset_index(), df_calls_features[
["duration_total_incoming", "duration_total_outgoing"]
].reset_index(),
i="participant_id", i="participant_id",
j="call_type", j="call_type",
stubnames="duration", stubnames="duration",
@ -114,7 +116,7 @@ df_sms_features.describe()
# %% # %%
sms_number = pd.wide_to_long( sms_number = pd.wide_to_long(
df_sms_features.reset_index(), df_sms_features[["no_received", "no_sent"]].reset_index(),
i="participant_id", i="participant_id",
j="message_type", j="message_type",
stubnames="no", stubnames="no",

View File

@ -61,9 +61,9 @@ df_esm_preprocessed.columns
# One approach would be to count distinct session IDs which are incremented for each group of EMAs. However, since not every question answered counts as a fulfilled EMA, some unique session IDs should be eliminated first. # One approach would be to count distinct session IDs which are incremented for each group of EMAs. However, since not every question answered counts as a fulfilled EMA, some unique session IDs should be eliminated first.
# %% # %%
session_counts = df_esm_preprocessed.groupby( session_counts = df_esm_preprocessed.groupby(["participant_id", "esm_session"]).count()[
["participant_id", "device_id", "esm_session"] "id"
).count()["id"] ]
# %% [markdown] # %% [markdown]
# Group data by participant_id and esm_session and count the number of instances (by id). Session counts are therefore counts of how many times a specific session ID appears *within* a specific participant. # Group data by participant_id and esm_session and count the number of instances (by id). Session counts are therefore counts of how many times a specific session ID appears *within* a specific participant.
@ -145,11 +145,7 @@ df_esm_preprocessed.query("participant_id == 31 & esm_session == 77")[
df_esm_2 = ( df_esm_2 = (
df_session_counts[df_session_counts["esm_session_count"] == 2] df_session_counts[df_session_counts["esm_session_count"] == 2]
.reset_index() .reset_index()
.merge( .merge(df_esm_preprocessed, how="left", on=["participant_id", "esm_session"],)
df_esm_preprocessed,
how="left",
on=["participant_id", "device_id", "esm_session"],
)
) )
# with pd.option_context('display.max_rows', None, 'display.max_columns', None): # more options can be specified also # with pd.option_context('display.max_rows', None, 'display.max_columns', None): # more options can be specified also
# display(df_esm_2) # display(df_esm_2)
@ -318,7 +314,7 @@ df_session_counts.loc[
df_session_counts.session_response.isna(), "esm_session_count" df_session_counts.session_response.isna(), "esm_session_count"
].value_counts().sort_index() ].value_counts().sort_index()
# %% # %% tags=[]
df_session_7 = df_session_counts[ df_session_7 = df_session_counts[
(df_session_counts["esm_session_count"] == 7) (df_session_counts["esm_session_count"] == 7)
& df_session_counts.session_response.isna() & df_session_counts.session_response.isna()
@ -369,10 +365,19 @@ df_esm_session_6 = df_session_6.join(
# %% # %%
display(df_esm_session_6[["esm_trigger", "esm_instructions", "esm_user_answer"]]) display(df_esm_session_6[["esm_trigger", "esm_instructions", "esm_user_answer"]])
# %% [markdown]
# The 6-question sessions are long interruptions of work during daytime.
# %% [markdown]
# # Count and classify sessions
# %% # %%
df_session_counts = classify_sessions_by_completion(df_esm_preprocessed) df_session_counts = classify_sessions_by_completion(df_esm_preprocessed)
df_session_time = classify_sessions_by_time(df_esm_preprocessed) df_session_time = classify_sessions_by_time(df_esm_preprocessed)
# %%
df_session_time
# %% [markdown] # %% [markdown]
# The sessions were classified by time by taking the **first** record in a session. # The sessions were classified by time by taking the **first** record in a session.
# However, a morning questionnaire could seamlessly transition into a daytime questionnaire, if the participant was already at work. # However, a morning questionnaire could seamlessly transition into a daytime questionnaire, if the participant was already at work.

View File

@ -180,7 +180,7 @@ def contact_features():
# TODO Implement a method that takes a DF with enumerated contacts as argument and calculates: # TODO Implement a method that takes a DF with enumerated contacts as argument and calculates:
# * Duration of calls per caller (for most common callers) # * Duration of calls per caller (for most common callers)
# * Determine work vs non-work contacts by work hours heuristics # * Determine work vs non-work contacts by work hours heuristics
# * Numer of people contacted # * Number of people contacted
# And similarly for SMS. # And similarly for SMS.
pass pass