Look at frequencies of screen statuses and explain (un)lock sequences.

communication
junos 2021-05-05 17:20:19 +02:00
parent db66d2201b
commit 056db73786
2 changed files with 130 additions and 9 deletions

View File

@ -14,3 +14,4 @@ dependencies:
- python-dotenv - python-dotenv
- seaborn - seaborn
- sqlalchemy - sqlalchemy
- tabulate

View File

@ -7,6 +7,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"import os, sys\n", "import os, sys\n",
"from tabulate import tabulate\n",
"nb_dir = os.path.split(os.getcwd())[0]\n", "nb_dir = os.path.split(os.getcwd())[0]\n",
"if nb_dir not in sys.path:\n", "if nb_dir not in sys.path:\n",
" sys.path.append(nb_dir)" " sys.path.append(nb_dir)"
@ -91,13 +92,18 @@
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/html": [
"<table>\n",
"<tbody>\n",
"<tr><td>off </td><td style=\"text-align: right;\">70243</td></tr>\n",
"<tr><td>on </td><td style=\"text-align: right;\">70012</td></tr>\n",
"<tr><td>locked </td><td style=\"text-align: right;\">63080</td></tr>\n",
"<tr><td>unlocked</td><td style=\"text-align: right;\">36666</td></tr>\n",
"</tbody>\n",
"</table>"
],
"text/plain": [ "text/plain": [
"screen_status\n", "'<table>\\n<tbody>\\n<tr><td>off </td><td style=\"text-align: right;\">70243</td></tr>\\n<tr><td>on </td><td style=\"text-align: right;\">70012</td></tr>\\n<tr><td>locked </td><td style=\"text-align: right;\">63080</td></tr>\\n<tr><td>unlocked</td><td style=\"text-align: right;\">36666</td></tr>\\n</tbody>\\n</table>'"
"0 70243\n",
"1 70012\n",
"2 63080\n",
"3 36666\n",
"dtype: int64"
] ]
}, },
"execution_count": 6, "execution_count": 6,
@ -106,7 +112,121 @@
} }
], ],
"source": [ "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": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>screen_status</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>-1.0</th>\n",
" <td>810</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2.0</th>\n",
" <td>779</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-3.0</th>\n",
" <td>238</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1.0</th>\n",
" <td>44</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-2.0</th>\n",
" <td>38</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0.0</th>\n",
" <td>6</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"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", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.9.2" "version": "3.9.4"
} }
}, },
"nbformat": 4, "nbformat": 4,