From 056db737861cac9dc00fef04b8bc06e4d3bc087f Mon Sep 17 00:00:00 2001 From: junos Date: Wed, 5 May 2021 17:20:19 +0200 Subject: [PATCH] Look at frequencies of screen statuses and explain (un)lock sequences. --- config/environment.yml | 3 +- exploration/screen.ipynb | 136 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 130 insertions(+), 9 deletions(-) diff --git a/config/environment.yml b/config/environment.yml index 4ff921d..d0d9b66 100644 --- a/config/environment.yml +++ b/config/environment.yml @@ -13,4 +13,5 @@ dependencies: - psycopg2 - python-dotenv - seaborn - - sqlalchemy \ No newline at end of file + - sqlalchemy + - tabulate \ No newline at end of file diff --git a/exploration/screen.ipynb b/exploration/screen.ipynb index c69682c..c903116 100644 --- a/exploration/screen.ipynb +++ b/exploration/screen.ipynb @@ -7,6 +7,7 @@ "outputs": [], "source": [ "import os, sys\n", + "from tabulate import tabulate\n", "nb_dir = os.path.split(os.getcwd())[0]\n", "if nb_dir not in sys.path:\n", " sys.path.append(nb_dir)" @@ -91,13 +92,18 @@ "outputs": [ { "data": { + "text/html": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
off 70243
on 70012
locked 63080
unlocked36666
" + ], "text/plain": [ - "screen_status\n", - "0 70243\n", - "1 70012\n", - "2 63080\n", - "3 36666\n", - "dtype: int64" + "'\\n\\n\\n\\n\\n\\n\\n
off 70243
on 70012
locked 63080
unlocked36666
'" ] }, "execution_count": 6, @@ -106,7 +112,121 @@ } ], "source": [ - "df_screen_inactive.value_counts(\"screen_status\")" + "df_screen_inactive[\"screen_status\"] = df_screen_inactive[\"screen_status\"].astype(\"category\").cat.rename_categories(screen_status)\n", + "screen_freq = df_screen_inactive.value_counts(\"screen_status\")\n", + "tabulate(screen_freq.to_frame(), tablefmt='html')" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{0: 'off', 1: 'on', 2: 'locked', 3: 'unlocked'}" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "screen_status" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A typical sequence might be: off -> locked -> on -> unlocked (0 -> 2 -> 1 -> 3)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
screen_status
-1.0810
2.0779
-3.0238
1.044
-2.038
0.06
\n", + "
" + ], + "text/plain": [ + " screen_status\n", + "-1.0 810\n", + " 2.0 779\n", + "-3.0 238\n", + " 1.0 44\n", + "-2.0 38\n", + " 0.0 6" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "status_diff = df_screen_nokia.sort_values(\"timestamp\")[\"screen_status\"].diff()\n", + "status_diff.value_counts().to_frame()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "But I have also seen off -> on -> unlocked (with 2 - locked missing) and off -> locked -> on -> off -> locked (*again*)." ] } ], @@ -126,7 +246,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.2" + "version": "3.9.4" } }, "nbformat": 4,