{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nfrom matplotlib import pyplot as plt\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport warnings\nwarnings.filterwarnings(\"ignore\")\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-04-02T13:45:41.126567Z","iopub.execute_input":"2023-04-02T13:45:41.127007Z","iopub.status.idle":"2023-04-02T13:45:41.139652Z","shell.execute_reply.started":"2023-04-02T13:45:41.126971Z","shell.execute_reply":"2023-04-02T13:45:41.138689Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PATH_IMAGE_LEVEL0_1 = \"/kaggle/input/single-session-20090312431273200/level0_store.jpg\"","metadata":{"execution":{"iopub.status.busy":"2023-04-02T14:01:47.210681Z","iopub.execute_input":"2023-04-02T14:01:47.211090Z","iopub.status.idle":"2023-04-02T14:01:47.216017Z","shell.execute_reply.started":"2023-04-02T14:01:47.211055Z","shell.execute_reply":"2023-04-02T14:01:47.214960Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Single session game analysis\n\n##### In this notebook I took only a single session id from the full data set and tried to do an analysis for level 0","metadata":{}},{"cell_type":"code","source":"#reading csv for session id : 20090312431273200\nsingle_session_id = pd.read_csv(\"/kaggle/input/single-session-20090312431273200/20090312431273200_session.csv\")\nsingle_session_id.head()","metadata":{"execution":{"iopub.status.busy":"2023-04-02T13:41:50.431707Z","iopub.execute_input":"2023-04-02T13:41:50.432093Z","iopub.status.idle":"2023-04-02T13:41:50.470633Z","shell.execute_reply.started":"2023-04-02T13:41:50.432061Z","shell.execute_reply":"2023-04-02T13:41:50.469628Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Check all the variables","metadata":{}},{"cell_type":"markdown","source":"#### unique event_name","metadata":{}},{"cell_type":"code","source":"single_session_id.groupby(by=\"event_name\",as_index=False)[\"event_name\"].first()","metadata":{"execution":{"iopub.status.busy":"2023-04-02T13:42:27.713633Z","iopub.execute_input":"2023-04-02T13:42:27.714022Z","iopub.status.idle":"2023-04-02T13:42:27.740646Z","shell.execute_reply.started":"2023-04-02T13:42:27.713985Z","shell.execute_reply":"2023-04-02T13:42:27.739587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"##### Total entry for each level","metadata":{}},{"cell_type":"code","source":"single_session_id.groupby(by='level')['session_id','level'] \\\n.count()['level'] \\\n.plot(kind='bar',xlabel='Level')","metadata":{"execution":{"iopub.status.busy":"2023-04-02T13:45:45.677542Z","iopub.execute_input":"2023-04-02T13:45:45.678692Z","iopub.status.idle":"2023-04-02T13:45:45.957164Z","shell.execute_reply.started":"2023-04-02T13:45:45.678641Z","shell.execute_reply":"2023-04-02T13:45:45.955768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"##### Notebook pages\n- No notebook for this session","metadata":{}},{"cell_type":"code","source":"print(\"Null page = \",single_session_id['page'].isna().sum(), \"\\nTOTAL = \", len(single_session_id))","metadata":{"execution":{"iopub.status.busy":"2023-04-02T13:46:34.806434Z","iopub.execute_input":"2023-04-02T13:46:34.806842Z","iopub.status.idle":"2023-04-02T13:46:34.813766Z","shell.execute_reply.started":"2023-04-02T13:46:34.806808Z","shell.execute_reply":"2023-04-02T13:46:34.812474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Hover duration","metadata":{}},{"cell_type":"code","source":"single_session_id.groupby(by='hover_duration')['session_id','hover_duration']\\\n    .count()['hover_duration']\\\n        .plot(kind='barh',xlabel='hover_duration(ms)'\n              ,ylabel='Count'\n              ,fontsize=10,figsize=(20,10))","metadata":{"execution":{"iopub.status.busy":"2023-04-02T13:48:36.398763Z","iopub.execute_input":"2023-04-02T13:48:36.399193Z","iopub.status.idle":"2023-04-02T13:48:37.379508Z","shell.execute_reply.started":"2023-04-02T13:48:36.399156Z","shell.execute_reply":"2023-04-02T13:48:37.378184Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Check text\n- some text are not in ascii , I guess they are unicode","metadata":{}},{"cell_type":"code","source":"single_session_id.groupby(by='text')['session_id','text']\\\n    .count()['text']\\","metadata":{"execution":{"iopub.status.busy":"2023-04-02T13:49:16.841561Z","iopub.execute_input":"2023-04-02T13:49:16.842048Z","iopub.status.idle":"2023-04-02T13:49:16.854249Z","shell.execute_reply.started":"2023-04-02T13:49:16.842007Z","shell.execute_reply":"2023-04-02T13:49:16.853266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### fqid, Name","metadata":{}},{"cell_type":"code","source":"single_session_id.groupby(by='fqid')[['session_id']]\\\n    .count().reset_index(drop=False)\\\n        .rename({\"session_id\":\"count\"},axis=1)\\\n.plot(x=\"fqid\", y=\"count\", kind=\"bar\", rot=90, fontsize=10,figsize=(20,10))\n","metadata":{"execution":{"iopub.status.busy":"2023-04-02T13:54:14.641955Z","iopub.execute_input":"2023-04-02T13:54:14.642344Z","iopub.status.idle":"2023-04-02T13:54:16.699200Z","shell.execute_reply.started":"2023-04-02T13:54:14.642311Z","shell.execute_reply":"2023-04-02T13:54:16.697800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"single_session_id.groupby(by=\"name\",as_index=True)[[\"session_id\"]]\\\n    .count().reset_index(drop=False)\\\n        .rename({\"session_id\":\"count\"},axis=1)\\\n    .plot(x=\"name\", y=\"count\", kind=\"bar\", rot=90, fontsize=10)","metadata":{"execution":{"iopub.status.busy":"2023-04-02T13:52:33.445875Z","iopub.execute_input":"2023-04-02T13:52:33.446257Z","iopub.status.idle":"2023-04-02T13:52:33.615459Z","shell.execute_reply.started":"2023-04-02T13:52:33.446225Z","shell.execute_reply":"2023-04-02T13:52:33.614089Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### room_fqid\nHow many events per ***room_fqid***","metadata":{}},{"cell_type":"code","source":"single_session_id.groupby(by=\"room_fqid\",as_index=True)[[\"session_id\"]]\\\n    .count().reset_index(drop=False)\\\n        .rename({\"session_id\":\"count\"},axis=1)\\","metadata":{"execution":{"iopub.status.busy":"2023-04-02T14:05:20.552553Z","iopub.execute_input":"2023-04-02T14:05:20.552963Z","iopub.status.idle":"2023-04-02T14:05:20.573940Z","shell.execute_reply.started":"2023-04-02T14:05:20.552927Z","shell.execute_reply":"2023-04-02T14:05:20.572860Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"single_session_id.groupby(by=\"room_fqid\",as_index=True)[[\"session_id\"]]\\\n    .count().reset_index(drop=False)\\\n        .rename({\"session_id\":\"count\"},axis=1)\\\n    .plot(x=\"room_fqid\", y=\"count\", kind=\"bar\", rot=90, fontsize=10)","metadata":{"execution":{"iopub.status.busy":"2023-04-02T13:55:20.140188Z","iopub.execute_input":"2023-04-02T13:55:20.142762Z","iopub.status.idle":"2023-04-02T13:55:20.490081Z","shell.execute_reply.started":"2023-04-02T13:55:20.142627Z","shell.execute_reply":"2023-04-02T13:55:20.488937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Click events \n#### Work with click events with coordinate\n\n\n- **room_coor_x** - the coordinates of the click in reference to the in-game room (only for click events)\n- **room_coor_y** - the coordinates of the click in reference to the in-game room (only for click events)\n- **screen_coor_x** - the coordinates of the click in reference to the player’s screen (only for click events)\n- **screen_coor_y** - the coordinates of the click in reference to the player’s screen (only for click events)\n- **event_name** - the name of the event type","metadata":{}},{"cell_type":"code","source":"## take only click event\nsingle_session_id.groupby(by='event_name',as_index=False).first()['event_name'].values","metadata":{"execution":{"iopub.status.busy":"2023-04-02T13:59:41.727626Z","iopub.execute_input":"2023-04-02T13:59:41.728070Z","iopub.status.idle":"2023-04-02T13:59:41.744322Z","shell.execute_reply.started":"2023-04-02T13:59:41.728032Z","shell.execute_reply":"2023-04-02T13:59:41.743071Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"click_event = ['cutscene_click', 'map_click', 'navigate_click', 'notification_click', 'object_click', 'observation_click', 'person_click']\n\nsingle_session_id_click_event1  =single_session_id[single_session_id['event_name'].isin(click_event)]","metadata":{"execution":{"iopub.status.busy":"2023-04-02T14:11:14.839572Z","iopub.execute_input":"2023-04-02T14:11:14.839979Z","iopub.status.idle":"2023-04-02T14:11:14.846243Z","shell.execute_reply.started":"2023-04-02T14:11:14.839943Z","shell.execute_reply":"2023-04-02T14:11:14.845270Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"single_session_id_click_event1[single_session_id_click_event1.level==0]","metadata":{"execution":{"iopub.status.busy":"2023-04-02T14:11:35.798216Z","iopub.execute_input":"2023-04-02T14:11:35.798654Z","iopub.status.idle":"2023-04-02T14:11:35.846668Z","shell.execute_reply.started":"2023-04-02T14:11:35.798606Z","shell.execute_reply":"2023-04-02T14:11:35.845617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### LEVEL 0 ROOMS","metadata":{}},{"cell_type":"code","source":"level_0_rooms = single_session_id_click_event1[single_session_id_click_event1.level==0] ","metadata":{"execution":{"iopub.status.busy":"2023-04-02T14:13:22.329854Z","iopub.execute_input":"2023-04-02T14:13:22.330249Z","iopub.status.idle":"2023-04-02T14:13:22.336673Z","shell.execute_reply.started":"2023-04-02T14:13:22.330213Z","shell.execute_reply":"2023-04-02T14:13:22.335338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level_0_rooms\\\n.groupby(by=\"room_fqid\",as_index=True)[[\"session_id\"]]\\\n    .count().reset_index(drop=False)\\\n        .rename({\"session_id\":\"count\"},axis=1)\\","metadata":{"execution":{"iopub.status.busy":"2023-04-02T14:13:23.029616Z","iopub.execute_input":"2023-04-02T14:13:23.030012Z","iopub.status.idle":"2023-04-02T14:13:23.043570Z","shell.execute_reply.started":"2023-04-02T14:13:23.029977Z","shell.execute_reply":"2023-04-02T14:13:23.042407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"single_session_id_click_event1 = level_0_rooms\n\n\nfig, ax1 = plt.subplots(figsize=(20,10))\nimg = plt.imread(PATH_IMAGE_LEVEL0_1)\nax1.imshow(img,extent=[0,900,0, 900])\n\nax1.scatter(single_session_id_click_event1.screen_coor_x,\n single_session_id_click_event1.screen_coor_y,\n  s=30, c='r', marker=\"o\")\n\n\n\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-02T14:13:44.469921Z","iopub.execute_input":"2023-04-02T14:13:44.470341Z","iopub.status.idle":"2023-04-02T14:13:45.192241Z","shell.execute_reply.started":"2023-04-02T14:13:44.470306Z","shell.execute_reply":"2023-04-02T14:13:45.191097Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Will continue ...**","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}