================================== Tutorial of *EventStream* Class ================================== | When you use the method function *CourseInformation*.load_eventstream(), the function returns the instance of *EventStream* class. | The class has the e-Book event log as the member variable and has the method functions to get the information. .. image:: event_stream.png :scale: 70% :align: center .. code-block:: python import openLA as la course_info = la.CourseInformation(files_dir="dataset_sample", course_id="A") event_stream = course_info.load_eventstream() # or course_info, event_stream = la.start_analysis(files_dir="dataset_sample", course_id="A") | The method functions in below table are available now. | You can get the information of the log like ``event_stream.num_users()``. | The documentation is in :doc:`../scripts/event_stream` +-----------------------------+------------------------------------------------------------+ | function | description | +=============================+============================================================+ | num_users | Get the number of users in the log | +-----------------------------+------------------------------------------------------------+ | user_id | Get the unique user ids in the log | +-----------------------------+------------------------------------------------------------+ | contents_id | Get the unique contents ids in the log | +-----------------------------+------------------------------------------------------------+ | operation_name | Get the unique operation name in the log | +-----------------------------+------------------------------------------------------------+ | operation_count | Get the count of each (or specified) operation in the log | +-----------------------------+------------------------------------------------------------+ | marker_type | Get the unique marker type in the log | +-----------------------------+------------------------------------------------------------+ | device_code | Get the unique device code in the log | +-----------------------------+------------------------------------------------------------+ If you want to process other than the above functions, you can get DataFrame type event stream by ``event_stream.df`` and process with Pandas library. .. code-block:: python import openLA as la import pandas as pd USER_ID = "userid" course_info = la.CourseInformation(files_dir="dataset_sample", course_id="A") event_stream = course_info.load_eventstream() event_stream_df = event_stream.df print(event_stream_df) """ userid contentsid operationname pageno marker memo_length devicecode eventtime 0 U1 C1 OPEN 1 NaN 0 tablet 2018-04-08 17:53:47 1 U1 C1 PAGE_JUMP 1 NaN 0 tablet 2018-04-08 17:53:50 2 U1 C1 NEXT 1 NaN 0 tablet 2018-04-08 17:54:01 3 U1 C1 NEXT 2 NaN 0 tablet 2018-04-08 17:54:21 ... ... ... ... ... ... ... ... ... """ # Add "User_" to the beginning of user id event_stream_df[USER_ID] = event_stream_df[USERID].apply(lambda x: f"User_{x}") print(event_stream_df) """ userid contentsid operationname pageno marker memo_length devicecode eventtime 0 User_U1 C1 OPEN 1 NaN 0 tablet 2018-04-08 17:53:47 1 User_U1 C1 PAGE_JUMP 1 NaN 0 tablet 2018-04-08 17:53:50 2 User_U1 C1 NEXT 1 NaN 0 tablet 2018-04-08 17:54:01 3 User_U1 C1 NEXT 2 NaN 0 tablet 2018-04-08 17:54:21 ... ... ... ... ... ... ... ... ... """ Example ============ .. toctree:: :maxdepth: 1 ../jupyter_examples/example_event_stream