{"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":"markdown","source":"<div style=\"color:#FE938C;margin:0;font-size:50px;font-family:'Montserrat', sans-serif;text-align:center;display:fill;border-radius:10px;overflow:hidden;font-weight:800;background-color:#FEE9E1;\"> \n  From Game Play <br>\n  Predict Student Performance\n</div>\n\n<h2 style=\"text-align:center;font-family:'Lato', sans-serif;font-weight:700;text-transform:uppercase;letter-spacing:2px;color:#254E58;margin-top:50px;\">AUTHOR: Mojahid Ahmad</h2>\n\n<br>    \n\n<p style=\"text-align:center;\">\n  <img src=\"https://www.rochester.edu/newscenter/wp-content/uploads/2014/11/fea-video-gam-controller.jpg\" style='width: 400px; height: 400px; border-radius:10px; box-shadow: 0 0 10px rgba(0,0,0,0.3);'>\n</p>\n","metadata":{}},{"cell_type":"markdown","source":"<a id=\"top\"></a>\n\n<div style=\"padding:20px;color:white;margin:0;font-size:40px;font-family:'Montserrat', sans-serif;text-align:left;display:fill;border-radius:10px;background-color:#FF6B6B;overflow:hidden\"><b>Table of Contents</b></div>\n\n<div style=\"background-color:#F8F9FA; padding:30px; font-size:16px;color:#495057; font-family:'Open Sans', sans-serif;\">\n\n<ul style=\"list-style-type:none;\">\n  <li><a href=\"#1\" style=\"text-decoration:none;color:#6C757D;\">1. Introduction</a>\n    <ul>\n      <li><a href=\"#1.1\" style=\"text-decoration:none;color:#6C757D;\">Problem Statement</a></li>\n      <li><a href=\"#1.2\" style=\"text-decoration:none;color:#6C757D;\">Data Description</a></li>\n    </ul>\n  </li>\n  <li><a href=\"#2\" style=\"text-decoration:none;color:#6C757D;\">2. Import Libraries</a></li>\n  <li><a href=\"#3\" style=\"text-decoration:none;color:#6C757D;\">3. Basic Exploration</a>\n    <ul>\n      <li><a href=\"#3.1\" style=\"text-decoration:none;color:#6C757D;\">Read Dataset</a></li>\n      <li><a href=\"#3.2\" style=\"text-decoration:none;color:#6C757D;\">Some Information</a></li>\n      <li><a href=\"#3.3\" style=\"text-decoration:none;color:#6C757D;\">Data Visualization</a></li>\n    </ul>\n  </li>\n  <li><a href=\"#4\" style=\"text-decoration:none;color:#6C757D;\">4. Machine Learning Model</a></li>\n  <li><a href=\"#5\" style=\"text-decoration:none;color:#6C757D;\">5. Conclusion</a></li>\n  <li><a href=\"#6\" style=\"text-decoration:none;color:#6C757D;\">6. Author Message</a></li>\n</ul>\n\n</div>\n","metadata":{}},{"cell_type":"markdown","source":"<a id=\"1\"></a>\n\n<div style=\"padding:20px;color:#fff;margin:0;font-size:40px;font-family:'Montserrat', sans-serif;text-align:left;display:fill;border-radius:10px;background-color:#FF6B6B;overflow:hidden\"><b>Introduction</b></div>\n","metadata":{}},{"cell_type":"markdown","source":"<a id=\"1.2\"></a>\n\n<div style=\"padding:20px;color:#fff;margin:0;font-size:25px;font-family:'Montserrat', sans-serif;text-align:left;display:fill;border-radius:10px;background-color:#FF6B6B;overflow:hidden\"><b>Problem Statement</b></div>","metadata":{}},{"cell_type":"markdown","source":"<div style=\"font-size:16px; font-family:Verdana;\">\n<p style=\"margin-bottom:20px; text-align:justify;\">Learning is meant to be fun, which is where game-based learning comes in. This educational approach allows students to engage with educational content inside a game framework, making it enjoyable and dynamic. Although game-based learning is being used in a growing number of educational settings, there are still a limited number of open datasets available to apply data science and learning analytic principles to improve game-based learning.</p>\n<p style=\"margin-bottom:20px; text-align:justify;\">Most game-based learning platforms do not sufficiently make use of knowledge tracing to support individual students. Knowledge tracing methods have been developed and studied in the context of online learning environments and intelligent tutoring systems. But there has been less focus on knowledge tracing in educational games.</p>\n<p style=\"margin-bottom:20px; text-align:justify;\">Competition host Field Day Lab is a publicly-funded research lab at the Wisconsin Center for Educational Research. They design games for many subjects and age groups that bring contemporary research to the public, making use of the game data to understand how people learn. Field Day Lab's commitment to accessibility ensures all of its games are free and available to anyone. The lab also partners with nonprofits like The Learning Agency Lab, which is focused on developing science of learning-based tools and programs for the social good.</p>\n<p style=\"margin-bottom:0px; text-align:justify;\">If successful, you'll enable game developers to improve educational games and further support the educators who use these games with dashboards and analytic tools. In turn, we might see broader support for game-based learning platforms.</p>\n</div>\n","metadata":{}},{"cell_type":"markdown","source":"<h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #1E4D2B; background-color: #FF6B6B;overflow:hidden\"><b>Data</b> description</h2>","metadata":{}},{"cell_type":"markdown","source":"<span style=\"font-size:14px; font-family:Verdana;\"> This competition uses the Kaggle's time series API. Test data will be delivered in groupings that do not allow access to future data. The objective of this competition is to use time series data generated by an online educational game to determine whether players will answer questions correctly. There are three question checkpoints (level 4, level 12, and level 22), each with a number of questions. At each checkpoint, you will have access to all previous test data for that section.</span>\n\n|No  | Columns name |  Meaning |\n|:---| :---         |:---      |\n| 1  | <font color=\"#254441\"> session_id </font>  |  the ID of the session the event took place in |\n| 2  | <font color=\"#254441\"> index </font>  |  the index of the event for the session |\n| 3  | <font color=\"#254441\"> elapsed_time </font>  |  how much time has passed (in milliseconds) between the start of the session <br>and when the event was recorded  |\n| 4  | <font color=\"#254441\"> event_name </font>  | the name of the event type  |\n| 5  | <font color=\"#254441\"> name </font>  |  the event name (e.g. identifies whether a notebook_click is is opening<br> or closing the notebook) |\n| 6  | <font color=\"#254441\"> level </font>  |  what level of the game the event occurred in (0 to 22)  |\n| 7  | <font color=\"#254441\"> page </font>  |   the page number of the event (only for notebook-related events) |\n| 8  | <font color=\"#254441\"> room_coor_x </font>  | the coordinates of the click in reference to the in-game room (only for click events)  |\n| 9  | <font color=\"#254441\"> room_coor_y </font>  |  the coordinates of the click in reference to the in-game room (only for click events) |\n| 10  | <font color=\"#254441\"> screen_coor_x </font>  | the coordinates of the click in reference to the player’s screen (only for click events)  |\n| 11  | <font color=\"#254441\"> screen_coor_y </font>  |  the coordinates of the click in reference to the player’s screen (only for click events) |\n| 12  | <font color=\"#254441\"> hover_duration </font>  |  how long (in milliseconds) the hover happened for (only for hover events) |\n| 13  | <font color=\"#254441\"> text </font>  | the text the player sees during this event  |\n| 14  | <font color=\"#254441\"> fqid  </font>  | the fully qualified ID of the event  |\n| 15  | <font color=\"#254441\"> room_fqid  </font>  | the fully qualified ID of the room the event took place in  |\n| 16 | <font color=\"#254441\">  text_fqid </font>  |  the fully qualified ID of the  |\n| 17  | <font color=\"#254441\">  fullscreen  </font>  |  whether the player is in fullscreen mode |\n| 18  | <font color=\"#254441\">  hq  </font>  |  whether the game is in high-quality |\n| 19  | <font color=\"#254441\">  music </font>  |   whether the game music is on or off |\n| 20  | <font color=\"#254441\"> level_group  </font>  | which group of levels - and group of questions - this row belongs to (0-4, 5-12, 13-22)  |","metadata":{}},{"cell_type":"markdown","source":"<a id=\"2\"></a>\n\n<div style=\"padding:20px;color:#fff;margin:0;font-size:25px;font-family:'Montserrat', sans-serif;text-align:left;display:fill;border-radius:10px;background-color:#FF6B6B;overflow:hidden\"><b>Import libraries</b></div>","metadata":{}},{"cell_type":"code","source":"import plotly.express as px\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport missingno as msno\nimport pandas as pd\nimport numpy as np\nimport matplotlib\nfrom plotly.subplots import make_subplots\nimport plotly.graph_objects as go\n#theme_colors = ['#901272', '#94A832', '#6C7CD3', '#F16262', '#4C5760']\ntheme_colors = ['#901272', '#94A832', '#6C7CD3', '#F16262', '#4C5760', '#DB8F00',\n                '#008B8B', '#8B008B', '#9ACD32', '#4682B4']\n\n%matplotlib inline\n\nimport warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:33:28.462994Z","iopub.execute_input":"2023-04-08T09:33:28.463843Z","iopub.status.idle":"2023-04-08T09:33:35.595424Z","shell.execute_reply.started":"2023-04-08T09:33:28.463803Z","shell.execute_reply":"2023-04-08T09:33:35.594422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"3\"></a>\n\n<div style=\"padding:20px;color:#fff;margin:0;font-size:25px;font-family:'Montserrat', sans-serif;text-align:left;display:fill;border-radius:10px;background-color:#FF6B6B;overflow:hidden\"><b>Data Exploration</b></div>","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3.1\"></a>\n<h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #1E4D2B; background-color: #FF6B6B;overflow:hidden\"><b>Read</b> Dataset</h2>","metadata":{}},{"cell_type":"code","source":"def read_dataset():\n    train = pd.read_csv(\"/kaggle/input/predict-student-performance-from-game-play/train.csv\")\n    print('Train data imported successfully!')\n    train_labels = pd.read_csv(\"/kaggle/input/predict-student-performance-from-game-play/train_labels.csv\")\n    print('Train labels data imported successfully!')\n    test=pd.read_csv(\"/kaggle/input/predict-student-performance-from-game-play/test.csv\")\n    print('Test data imported sucessfully!')\n    return train, train_labels, test","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:34:57.094473Z","iopub.execute_input":"2023-04-08T09:34:57.094844Z","iopub.status.idle":"2023-04-08T09:34:57.100373Z","shell.execute_reply.started":"2023-04-08T09:34:57.094810Z","shell.execute_reply":"2023-04-08T09:34:57.099381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"raw_train_df, raw_train_labels_df, raw_test_df=read_dataset()","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:34:59.743728Z","iopub.execute_input":"2023-04-08T09:34:59.744133Z","iopub.status.idle":"2023-04-08T09:37:00.877988Z","shell.execute_reply.started":"2023-04-08T09:34:59.744095Z","shell.execute_reply":"2023-04-08T09:37:00.876018Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"raw_train_df.shape","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:39:29.199671Z","iopub.execute_input":"2023-04-08T09:39:29.200347Z","iopub.status.idle":"2023-04-08T09:39:29.206771Z","shell.execute_reply.started":"2023-04-08T09:39:29.200308Z","shell.execute_reply":"2023-04-08T09:39:29.205615Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"raw_train_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:39:12.504569Z","iopub.execute_input":"2023-04-08T09:39:12.504969Z","iopub.status.idle":"2023-04-08T09:39:12.526127Z","shell.execute_reply.started":"2023-04-08T09:39:12.504935Z","shell.execute_reply":"2023-04-08T09:39:12.524918Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_num_rows, train_num_cols = raw_train_df.shape\nprint(f'Train data \\nNumber of rows : {train_num_rows}\\nNumber of columns: {train_num_cols}')","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:40:18.304338Z","iopub.execute_input":"2023-04-08T09:40:18.305316Z","iopub.status.idle":"2023-04-08T09:40:18.310756Z","shell.execute_reply.started":"2023-04-08T09:40:18.305277Z","shell.execute_reply":"2023-04-08T09:40:18.309618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_num_rows, test_num_cols = raw_test_df.shape\nprint(f'Train data \\nNumber of rows : {test_num_rows}\\nNumber of columns: {test_num_cols}')","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:40:27.794089Z","iopub.execute_input":"2023-04-08T09:40:27.795088Z","iopub.status.idle":"2023-04-08T09:40:27.800479Z","shell.execute_reply.started":"2023-04-08T09:40:27.795039Z","shell.execute_reply":"2023-04-08T09:40:27.799380Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Basic Info","metadata":{}},{"cell_type":"code","source":"print(\"Info of train data:\")\nprint(raw_train_df.info())","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:40:48.565198Z","iopub.execute_input":"2023-04-08T09:40:48.566272Z","iopub.status.idle":"2023-04-08T09:40:48.596799Z","shell.execute_reply.started":"2023-04-08T09:40:48.566230Z","shell.execute_reply":"2023-04-08T09:40:48.595630Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Info of test data:\")\nprint(raw_test_df.info())","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:49:21.395661Z","iopub.execute_input":"2023-04-08T09:49:21.396375Z","iopub.status.idle":"2023-04-08T09:49:21.420689Z","shell.execute_reply.started":"2023-04-08T09:49:21.396338Z","shell.execute_reply":"2023-04-08T09:49:21.419490Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Info of train labels data:\")\nprint(raw_train_labels_df.info())","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:49:31.885161Z","iopub.execute_input":"2023-04-08T09:49:31.885857Z","iopub.status.idle":"2023-04-08T09:49:31.913527Z","shell.execute_reply.started":"2023-04-08T09:49:31.885821Z","shell.execute_reply":"2023-04-08T09:49:31.912203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Null Check","metadata":{}},{"cell_type":"code","source":"raw_train_df.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-04-08T09:50:05.575483Z","iopub.execute_input":"2023-04-08T09:50:05.576202Z","iopub.status.idle":"2023-04-08T09:50:11.846282Z","shell.execute_reply.started":"2023-04-08T09:50:05.576164Z","shell.execute_reply":"2023-04-08T09:50:11.844987Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"null of train.csv\")\nraw_test_df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:00:00.475265Z","iopub.execute_input":"2023-04-08T10:00:00.476334Z","iopub.status.idle":"2023-04-08T10:00:00.490845Z","shell.execute_reply.started":"2023-04-08T10:00:00.476294Z","shell.execute_reply":"2023-04-08T10:00:00.489471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'\\n There are {len(raw_train_df[\"event_name\"].unique())} name event enlisted here.\\n')\nname_event_unique=np.unique(raw_train_df['event_name'])\nname_event_unique=pd.DataFrame(name_event_unique, columns=['event_name'])\nname_event_unique.T.style.set_properties(**{\"background-color\": \"#254441\",\"color\":\"#e9c46a\",\"border\": \"1.5px solid black\"})","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:00:25.145403Z","iopub.execute_input":"2023-04-08T10:00:25.145777Z","iopub.status.idle":"2023-04-08T10:00:46.715201Z","shell.execute_reply.started":"2023-04-08T10:00:25.145744Z","shell.execute_reply":"2023-04-08T10:00:46.713999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"event_name_df = raw_train_df.groupby(['event_name'])['event_name'].count().sort_values()\nsns.set(rc={\"axes.facecolor\":\"#F2EAC5\",\"figure.facecolor\":\"#F2EAC5\"})\npalette = [\"#11264e\",\"#00507A\",\"#026e90\",\"#008b99\",\"#6faea4\",\"#fcdcb0\",\"#FEE08B\",\"#faa96e\",\"#f36b3b\",\"#ef3f28\",\"#CC0028\"]\nplt.subplots(figsize=(20, 10))\np = sns.barplot(x=event_name_df.values, y=event_name_df.index, palette=palette, saturation=1, edgecolor = \"#1c1c1c\", linewidth = 4)\np.axes.set_title(\"\\nName of the event that took place\\n\",fontsize=25)\np.axes.set_xlabel(\"Count\",fontsize=20)\np.axes.set_ylabel(\"Name event\",fontsize=20)\np.axes.set_xticklabels(p.get_xticklabels(),rotation = 90)\nfor container in p.containers:\n    p.bar_label(container,label_type=\"edge\",padding=6,size=20,color=\"black\",rotation=0,\n    bbox={\"boxstyle\": \"round\", \"pad\": 0.4, \"facecolor\": \"orange\", \"edgecolor\": \"#1c1c1c\", \"linewidth\" : 1.5, \"alpha\": 1})\n\nsns.despine(left=True, bottom=True)\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:04:27.191258Z","iopub.execute_input":"2023-04-08T10:04:27.192319Z","iopub.status.idle":"2023-04-08T10:04:30.503892Z","shell.execute_reply.started":"2023-04-08T10:04:27.192280Z","shell.execute_reply":"2023-04-08T10:04:30.502886Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'\\n There are {len(raw_train_df[\"name\"].unique())} name enlisted here.\\n')\nname_unique=np.unique(raw_train_df['name'])\nname_unique=pd.DataFrame(name_unique, columns=['name'])\nname_unique.T.style.set_properties(**{\"background-color\": \"#254441\",\"color\":\"#e9c46a\",\"border\": \"1.5px solid black\"})","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:06:56.965171Z","iopub.execute_input":"2023-04-08T10:06:56.965891Z","iopub.status.idle":"2023-04-08T10:07:18.827720Z","shell.execute_reply.started":"2023-04-08T10:06:56.965847Z","shell.execute_reply":"2023-04-08T10:07:18.826665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"temp=raw_train_df.groupby([\"event_name\",\"name\"])[\"event_name\"].count()\n\nd = {'name': ['basic'], 'count': [temp[0]]}\ncheckpoint = pd.DataFrame(data=d)\n\nd = {'name': ['basic'], 'count': [temp[1]]}\ncutscene_click  = pd.DataFrame(data=d)\n\nd = {'name': ['basic','close','undefined'], 'count': [temp[2],temp[3],temp[4]]}\nmap_click = pd.DataFrame(data=d)\n\nd = {'name': ['basic'], 'count': [temp[5]]}\nmap_hover  = pd.DataFrame(data=d)\n\nd = {'name': ['undenfined'], 'count': [temp[6]]}\nnavigate_click = pd.DataFrame(data=d)\n\nd = {'name': ['basic','close','next','open','prev'], 'count': [temp[7], temp[8], temp[9], temp[10], temp[11]]}\nnotebook_click  = pd.DataFrame(data=d)\n\nd = {'name': ['basic'], 'count': [temp[12]]}\nnotification_click = pd.DataFrame(data=d)\n\nd = {'name': ['basic','close'], 'count': [temp[13], temp[14]]}\nobject_click = pd.DataFrame(data=d)\n\nd = {'name': ['basic','undefined '], 'count': [temp[15], temp[16]]}\nobject_hover = pd.DataFrame(data=d)\n\nd = {'name': ['basic'], 'count': [temp[17]]}\nobservation_click = pd.DataFrame(data=d)\n\nd = {'name': ['basic'], 'count': [temp[18]]}\nperson_click = pd.DataFrame(data=d)","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:21:07.815790Z","iopub.execute_input":"2023-04-08T10:21:07.816281Z","iopub.status.idle":"2023-04-08T10:21:12.704908Z","shell.execute_reply.started":"2023-04-08T10:21:07.816244Z","shell.execute_reply":"2023-04-08T10:21:12.703826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cutscene_click","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:21:31.914838Z","iopub.execute_input":"2023-04-08T10:21:31.915865Z","iopub.status.idle":"2023-04-08T10:21:31.926068Z","shell.execute_reply.started":"2023-04-08T10:21:31.915826Z","shell.execute_reply":"2023-04-08T10:21:31.924818Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = make_subplots(rows=6, cols=2,\n                    specs=[[{'type':'domain'}, {'type':'domain'}],\n                           [{'type':'domain'}, {'type':'domain'}],\n                           [{'type':'domain'}, {'type':'domain'}],\n                           [{'type':'domain'}, {'type':'domain'}],\n                           [{'type':'domain'}, {'type':'domain'}],\n                           [{'type':'domain'}, {'type':'domain'}]\n                          ])\nfig.add_trace(\n    go.Pie(\n        labels=checkpoint['name'],\n        values=checkpoint['count'],\n        hole=.7,\n        title='checkpoint',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=1,col=1\n    )\n\nfig.add_trace(\n    go.Pie(\n        labels=cutscene_click['name'],\n        values=cutscene_click['count'],\n        hole=.7,\n        title='cutscene_click',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=1,col=2\n    )\n\nfig.add_trace(\n    go.Pie(\n        labels=map_click['name'],\n        values=map_click['count'],\n        hole=.7,\n        title='map_click',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=2,col=1\n    )\n\n\nfig.add_trace(\n    go.Pie(\n        labels=map_hover['name'],\n        values=map_hover['count'],\n        hole=.7,\n        title='map_hover',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=2,col=2\n    )\n\nfig.add_trace(\n    go.Pie(\n        labels=navigate_click['name'],\n        values=navigate_click['count'],\n        hole=.7,\n        title='navigate_click',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=3,col=1\n    )\n\nfig.add_trace(\n    go.Pie(\n        labels=notebook_click ['name'],\n        values=notebook_click ['count'],\n        hole=.7,\n        title='notebook_click ',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=3,col=2\n    )\n\nfig.add_trace(\n    go.Pie(\n        labels=notification_click['name'],\n        values=notification_click['count'],\n        hole=.7,\n        title='notification_click',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=4,col=1\n    )\n\nfig.add_trace(\n    go.Pie(\n        labels=object_click['name'],\n        values=object_click['count'],\n        hole=.7,\n        title='object_click',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=4,col=2\n    )\n\nfig.add_trace(\n    go.Pie(\n        labels=object_hover['name'],\n        values=object_hover['count'],\n        hole=.7,\n        title='object_hover',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=5,col=1\n    )\n\nfig.add_trace(\n    go.Pie(\n        labels=observation_click['name'],\n        values=observation_click['count'],\n        hole=.7,\n        title='observation_click',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=5,col=2\n    )\n\nfig.add_trace(\n    go.Pie(\n        labels=person_click['name'],\n        values=person_click['count'],\n        hole=.7,\n        title='person_click',\n        titlefont={'color':None, 'size': 15},\n        ),\n    row=6,col=1\n    )\n\nfig.update_traces(\n    hoverinfo='label+value',\n    textinfo='label+percent',\n    textfont_size=20,\n    marker=dict(\n        colors=theme_colors,\n        line=dict(color='#EEEEEE',\n                  width=2)\n        )\n    )\n\nfig.layout.update(title=\"<b> How many descriptive definitions are there for an event?<b>\",\n                  titlefont={'color':None, 'size': 20, 'family': 'Courier New'},\n                  showlegend=False, \n                  height=1700, \n                  width=600,\n                  template='plotly_dark',\n                  title_x=0.2\n                  )\nfig.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:21:43.858473Z","iopub.execute_input":"2023-04-08T10:21:43.858857Z","iopub.status.idle":"2023-04-08T10:21:46.014009Z","shell.execute_reply.started":"2023-04-08T10:21:43.858826Z","shell.execute_reply":"2023-04-08T10:21:46.012946Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level=pd.DataFrame({'count': raw_train_df.groupby([\"event_name\",\"level\"]).size()}).reset_index()\ncheckpoint=level.loc[level['event_name']=='checkpoint']\nobservation_click=level.loc[level['event_name']=='observation_click']\nmap_click =level.loc[level['event_name']=='map_click']\nnotebook_click=level.loc[level['event_name']=='notebook_click']\nnotification_click=level.loc[level['event_name']=='notification_click']\nmap_hover=level.loc[level['event_name']=='map_hover']\nobject_hover=level.loc[level['event_name']=='object_hover']\nobject_click=level.loc[level['event_name']=='object_click']\ncutscene_click=level.loc[level['event_name']=='cutscene_click']\nperson_click=level.loc[level['event_name']=='person_click']\nnavigate_click=level.loc[level['event_name']=='navigate_click']\n\ncheckpoint['level']=checkpoint['level'].astype(str)\nfig=px.bar(y=checkpoint['count'],\n          x=checkpoint['level'],\n          color=checkpoint['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=checkpoint['count'],\n          title=\"checkpoint\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()\n\nobservation_click['level']=observation_click['level'].astype(str)\nfig=px.bar(y=observation_click['count'],\n          x=observation_click['level'],\n          color=observation_click['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=observation_click['count'],\n          title=\"observation_click\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()\n\nmap_click['level']=map_click['level'].astype(str)\nfig=px.bar(y=map_click['count'],\n          x=map_click['level'],\n          color=map_click['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=map_click['count'],\n          title=\"map_click\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()\n\nnotebook_click['level']=notebook_click['level'].astype(str)\nfig=px.bar(y=notebook_click['count'],\n          x=notebook_click['level'],\n          color=notebook_click['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=notebook_click['count'],\n          title=\"notebook_click\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()\n\nnotification_click['level']=notification_click['level'].astype(str)\nfig=px.bar(y=notification_click['count'],\n          x=notification_click['level'],\n          color=notification_click['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=notification_click['count'],\n          title=\"notification_click\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()\n\nmap_hover['level']=map_hover['level'].astype(str)\nfig=px.bar(y=map_hover['count'],\n          x=map_hover['level'],\n          color=map_hover['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=map_hover['count'],\n          title=\"map_hover\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()\n\nobject_hover['level']=object_hover['level'].astype(str)\nfig=px.bar(y=object_hover['count'],\n          x=object_hover['level'],\n          color=object_hover['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=object_hover['count'],\n          title=\"object_hover\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()\n\nobject_click['level']=object_click['level'].astype(str)\nfig=px.bar(y=object_click['count'],\n          x=object_click['level'],\n          color=object_click['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=object_click['count'],\n          title=\"object_click\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()\n\ncutscene_click['level']=cutscene_click['level'].astype(str)\nfig=px.bar(y=cutscene_click['count'],\n          x=cutscene_click['level'],\n          color=cutscene_click['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=cutscene_click['count'],\n          title=\"cutscene_click\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()\n\nperson_click['level']=person_click['level'].astype(str)\nfig=px.bar(y=person_click['count'],\n          x=person_click['level'],\n          color=person_click['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=person_click['count'],\n          title=\"person_click\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()\n\nnavigate_click['level']=navigate_click['level'].astype(str)\nfig=px.bar(y=navigate_click['count'],\n          x=navigate_click['level'],\n          color=navigate_click['level'],\n          color_discrete_sequence=px.colors.sequential.deep,\n          text=navigate_click['count'],\n          title=\"navigate_click\",\n          template=\"plotly_dark\")\nfig.update_layout(xaxis_title=\"Level\",\n                 yaxis_title=\"Count\",\n                 font=dict(size=17,family=\"Franklin Gpthic\"))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:24:36.641404Z","iopub.execute_input":"2023-04-08T10:24:36.641776Z","iopub.status.idle":"2023-04-08T10:24:40.915719Z","shell.execute_reply.started":"2023-04-08T10:24:36.641742Z","shell.execute_reply":"2023-04-08T10:24:40.914679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level_w_elapsed_time = pd.DataFrame(raw_train_df.groupby(\"level\").agg({\"elapsed_time\": \"mean\"}))\nlevel_w_elapsed_time = level_w_elapsed_time.reset_index(drop=False)\nlevel_w_elapsed_time.columns = [\"level\", \"elapsed_time\"]\nlevel_w_elapsed_time = level_w_elapsed_time.sort_values(by=\"level\", ascending=True)\n\nx, y = level_w_elapsed_time[\"level\"].values, level_w_elapsed_time[\"elapsed_time\"]\nmin_x, max_x = np.min(x), np.max(x)\n\nfigure = plt.figure(figsize=(20, 7))\naxis = figure.add_subplot()\naxis.grid(axis=\"both\", zorder=0)\nsns.lineplot(x=x, y=y, color=\"#fff\", linewidth=2, alpha=1.0, ax=axis, zorder=2)\naxis.yaxis.set_tick_params(labelsize=14)\naxis.set_ylabel(\"elapsed_time\", fontsize=15)\naxis.set_xlabel(\"level\", fontsize=15)\naxis.xaxis.set_tick_params(labelsize=12)\naxis.yaxis.set_tick_params(labelsize=12)\naxis.fill_between(x, y, color=\"#2F718C\", edgecolor=\"#fff\", alpha=1.0, zorder=2)\naxis.set_xticks(range(min_x, max_x+1, 1))\naxis.set_xlim(min_x, max_x)\naxis.set_ylim(0.0)\nfigure.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:25:15.855882Z","iopub.execute_input":"2023-04-08T10:25:15.856947Z","iopub.status.idle":"2023-04-08T10:25:16.810657Z","shell.execute_reply.started":"2023-04-08T10:25:15.856905Z","shell.execute_reply":"2023-04-08T10:25:16.809680Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\npage = raw_train_df['page'].value_counts()\nfig = px.pie(values=page.values, \n             names=page.index, \n             color_discrete_sequence=px.colors.sequential.PuBu,\n             title= 'Page distribution',template='plotly_dark')\nfig.update_traces(textinfo='label+percent+value', textfont_size=14,\n                  marker=dict(line=dict(color='#100000', width=0.2)))\n\nfig.data[0].marker.line.width = 2\nfig.data[0].marker.line.color='gray'\nfig.update_layout(\n    font=dict(size=20,family=\"Franklin Gothic\"))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:25:31.865107Z","iopub.execute_input":"2023-04-08T10:25:31.865842Z","iopub.status.idle":"2023-04-08T10:25:31.984506Z","shell.execute_reply.started":"2023-04-08T10:25:31.865805Z","shell.execute_reply":"2023-04-08T10:25:31.983359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level_group = raw_train_df['level_group'].value_counts()\nfig = px.pie(values=level_group.values,\n             names=level_group.index,\n             color_discrete_sequence=px.colors.sequential.PuBu,\n             title= 'Level group distribution',template='plotly_dark')\n\nfig.update_traces(textinfo='label+percent+value', textfont_size=14,\n                  marker=dict(line=dict(color='#100000', width=0.2)))\n\nfig.data[0].marker.line.width = 2\nfig.data[0].marker.line.color='gray'\nfig.update_layout(\n    font=dict(size=20,family=\"Franklin Gothic\"))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:25:42.145780Z","iopub.execute_input":"2023-04-08T10:25:42.146274Z","iopub.status.idle":"2023-04-08T10:25:43.453151Z","shell.execute_reply.started":"2023-04-08T10:25:42.146238Z","shell.execute_reply":"2023-04-08T10:25:43.452188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}