Small corrections.
parent
a6d8f70e7f
commit
b8301ca458
|
@ -212,7 +212,7 @@ class Call(Base, AWAREsensor):
|
|||
call_type: int
|
||||
One of the Android’s call types (1 – incoming, 2 – outgoing, 3 – missed).
|
||||
call_duration: int
|
||||
Length of the call session.
|
||||
Length of the call session in seconds.
|
||||
trace: str(40)
|
||||
A hash value SHA-1 of the phone number (source or target) of the call
|
||||
"""
|
||||
|
|
|
@ -62,7 +62,7 @@ df_calls_features.describe()
|
|||
|
||||
# %%
|
||||
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",
|
||||
j="call_type",
|
||||
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(
|
||||
df_calls_features.reset_index(),
|
||||
df_calls_features[
|
||||
["duration_total_incoming", "duration_total_outgoing"]
|
||||
].reset_index(),
|
||||
i="participant_id",
|
||||
j="call_type",
|
||||
stubnames="duration",
|
||||
|
@ -114,7 +116,7 @@ df_sms_features.describe()
|
|||
|
||||
# %%
|
||||
sms_number = pd.wide_to_long(
|
||||
df_sms_features.reset_index(),
|
||||
df_sms_features[["no_received", "no_sent"]].reset_index(),
|
||||
i="participant_id",
|
||||
j="message_type",
|
||||
stubnames="no",
|
||||
|
|
|
@ -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.
|
||||
|
||||
# %%
|
||||
session_counts = df_esm_preprocessed.groupby(
|
||||
["participant_id", "device_id", "esm_session"]
|
||||
).count()["id"]
|
||||
session_counts = df_esm_preprocessed.groupby(["participant_id", "esm_session"]).count()[
|
||||
"id"
|
||||
]
|
||||
|
||||
# %% [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.
|
||||
|
@ -145,11 +145,7 @@ df_esm_preprocessed.query("participant_id == 31 & esm_session == 77")[
|
|||
df_esm_2 = (
|
||||
df_session_counts[df_session_counts["esm_session_count"] == 2]
|
||||
.reset_index()
|
||||
.merge(
|
||||
df_esm_preprocessed,
|
||||
how="left",
|
||||
on=["participant_id", "device_id", "esm_session"],
|
||||
)
|
||||
.merge(df_esm_preprocessed, how="left", on=["participant_id", "esm_session"],)
|
||||
)
|
||||
# with pd.option_context('display.max_rows', None, 'display.max_columns', None): # more options can be specified also
|
||||
# display(df_esm_2)
|
||||
|
@ -318,7 +314,7 @@ df_session_counts.loc[
|
|||
df_session_counts.session_response.isna(), "esm_session_count"
|
||||
].value_counts().sort_index()
|
||||
|
||||
# %%
|
||||
# %% tags=[]
|
||||
df_session_7 = df_session_counts[
|
||||
(df_session_counts["esm_session_count"] == 7)
|
||||
& 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"]])
|
||||
|
||||
# %% [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_time = classify_sessions_by_time(df_esm_preprocessed)
|
||||
|
||||
# %%
|
||||
df_session_time
|
||||
|
||||
# %% [markdown]
|
||||
# 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.
|
||||
|
|
|
@ -180,7 +180,7 @@ def contact_features():
|
|||
# TODO Implement a method that takes a DF with enumerated contacts as argument and calculates:
|
||||
# * Duration of calls per caller (for most common callers)
|
||||
# * Determine work vs non-work contacts by work hours heuristics
|
||||
# * Numer of people contacted
|
||||
# * Number of people contacted
|
||||
# And similarly for SMS.
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue