{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example of *EventStream*" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# import openLA as la\n", "import OpenLA as la\n", "course_info = la.CourseInformation(files_dir=\"dataset_sample\", course_id=\"A\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load event stream" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "event_stream = course_info.load_eventstream()" ] }, { "cell_type": "code", "execution_count": 3, "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", " \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", " \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", " \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", "
useridcontentsidoperationnamepagenomarkermemo_lengthdevicecodeeventtime
0U1C1OPEN1NaN0tablet2018-04-08 17:53:47
1U1C1PAGE_JUMP1NaN0tablet2018-04-08 17:53:50
2U1C1NEXT1NaN0tablet2018-04-08 17:54:01
3U1C1NEXT2NaN0tablet2018-04-08 17:54:21
4U1C1NEXT3NaN0tablet2018-04-08 17:54:24
...........................
263279U99C8NEXT18NaN0pc2018-06-05 16:07:23
263280U99C8PREV19NaN0pc2018-06-05 16:07:26
263281U99C8PREV18NaN0pc2018-06-05 16:07:28
263282U99C8PREV17NaN0pc2018-06-05 16:07:30
263283U99C8CLOSE16NaN0pc2018-06-05 16:07:30
\n", "

263284 rows × 8 columns

\n", "
" ], "text/plain": [ " userid contentsid operationname pageno marker memo_length devicecode \\\n", "0 U1 C1 OPEN 1 NaN 0 tablet \n", "1 U1 C1 PAGE_JUMP 1 NaN 0 tablet \n", "2 U1 C1 NEXT 1 NaN 0 tablet \n", "3 U1 C1 NEXT 2 NaN 0 tablet \n", "4 U1 C1 NEXT 3 NaN 0 tablet \n", "... ... ... ... ... ... ... ... \n", "263279 U99 C8 NEXT 18 NaN 0 pc \n", "263280 U99 C8 PREV 19 NaN 0 pc \n", "263281 U99 C8 PREV 18 NaN 0 pc \n", "263282 U99 C8 PREV 17 NaN 0 pc \n", "263283 U99 C8 CLOSE 16 NaN 0 pc \n", "\n", " eventtime \n", "0 2018-04-08 17:53:47 \n", "1 2018-04-08 17:53:50 \n", "2 2018-04-08 17:54:01 \n", "3 2018-04-08 17:54:21 \n", "4 2018-04-08 17:54:24 \n", "... ... \n", "263279 2018-06-05 16:07:23 \n", "263280 2018-06-05 16:07:26 \n", "263281 2018-06-05 16:07:28 \n", "263282 2018-06-05 16:07:30 \n", "263283 2018-06-05 16:07:30 \n", "\n", "[263284 rows x 8 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_stream.df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Aggregate Information" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "118" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_stream.num_users()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['U1', 'U10', 'U100', 'U101', 'U102', 'U103', 'U104', 'U105', 'U106', 'U107']" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_stream.user_id()[:10]" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['C1', 'C2', 'C3', 'C4', 'C5', 'C7', 'C8', 'C6']" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_stream.contents_id()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['OPEN',\n", " 'PAGE_JUMP',\n", " 'NEXT',\n", " 'PREV',\n", " 'ADD BOOKMARK',\n", " 'DELETE BOOKMARK',\n", " 'CLOSE',\n", " 'BOOKMARK_JUMP',\n", " 'ADD MARKER',\n", " 'DELETE MARKER',\n", " 'ADD MEMO',\n", " 'DELETE_MEMO',\n", " 'CHANGE MEMO',\n", " 'SEARCH',\n", " 'SEARCH_JUMP',\n", " 'LINK_CLICK']" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_stream.operation_name()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'NEXT': 936,\n", " 'PREV': 463,\n", " 'PAGE_JUMP': 25,\n", " 'OPEN': 22,\n", " 'ADD BOOKMARK': 8,\n", " 'CLOSE': 8,\n", " 'BOOKMARK_JUMP': 3,\n", " 'ADD MARKER': 2,\n", " 'DELETE BOOKMARK': 1,\n", " 'DELETE MARKER': 1}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_stream.operation_count(user_id=\"U1\")" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "147" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_stream.operation_count(operation_name=\"NEXT\",\n", " user_id=\"U2\",\n", " contents_id=\"C1\")" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['difficult', 'important']" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_stream.marker_type()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['tablet', 'pc', 'mobile']" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_stream.device_code()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" }, "pycharm": { "stem_cell": { "cell_type": "raw", "source": [], "metadata": { "collapsed": false } } } }, "nbformat": 4, "nbformat_minor": 2 }