stress_at_work_analysis/exploration/expl_proximity.py

70 lines
1.9 KiB
Python

# ---
# jupyter:
# jupytext:
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.11.4
# kernelspec:
# display_name: straw2analysis
# language: python
# name: straw2analysis
# ---
# %%
# %matplotlib inline
import datetime
import os
import sys
import seaborn as sns
from pytz import timezone
from tabulate import tabulate
nb_dir = os.path.split(os.getcwd())[0]
if nb_dir not in sys.path:
sys.path.append(nb_dir)
import participants.query_db
TZ_LJ = timezone("Europe/Ljubljana")
# %%
from features.proximity import *
# %% [markdown]
# # Basic characteristics
# %%
df_proximity_nokia = get_proximity_data(["nokia_0000003"])
print(df_proximity_nokia)
# %%
df_proximity_nokia.double_proximity.value_counts()
# %% [markdown]
# `double_proximity` is "the distance to an object in front of the mobile device or binary presence (**manufacturer dependent**)."
#
# "Most proximity sensors return [the absolute distance, in cm](https://developer.android.com/guide/topics/sensors/sensors_position#sensors-pos-prox), but some return only near and far values.
#
# Note: Some proximity sensors return binary values that represent "near" or "far." In this case, the sensor usually reports its maximum range value in the far state and a lesser value in the near state. Typically, the far value is a value > 5 cm, but this can vary from sensor to sensor. You can determine a sensor's maximum range by using the getMaximumRange() method."
# %%
participants_inactive_usernames = participants.query_db.get_usernames()
df_proximity_inactive = get_proximity_data(participants_inactive_usernames)
# %%
df_proximity_inactive.double_proximity.describe()
# %%
sns.displot(
data=df_proximity_inactive, x="double_proximity", binwidth=0.2, height=8,
)
# %%
df_proximity_inactive.double_proximity.value_counts()
# %%