{"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":"\n<h1 style=\"background-color:#ffa7ca;font-family:newtimeroman;font-size:350%;color: white; text-align:center;border-radius: 50px 50px;\">📋 Table of Content</h1>\n\n<div style=\"border-radius:10px;\n            border :#0A0104 solid;\n            padding: 15px;\n            background-color:  ;\n           font-size:110%;\n            text-align: left\">\n    <a id=\"table\"></a>\n    <center>\n        > <a href=\"#8\"> 📈 Step 1: Importing necessary libraries and packages</a>\n        <br>\n        > <a href=\"#9\"> 💻 Step 2: Cleaning data</a>\n        <br>\n        > <a href=\"#6\"> 📥 Step 3: EDA </a>\n        <br>\n    </center>\n</div>","metadata":{}},{"cell_type":"code","source":"import 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":{"execution":{"iopub.status.busy":"2023-03-12T14:37:57.928169Z","iopub.execute_input":"2023-03-12T14:37:57.929127Z","iopub.status.idle":"2023-03-12T14:37:57.941711Z","shell.execute_reply.started":"2023-03-12T14:37:57.929078Z","shell.execute_reply":"2023-03-12T14:37:57.940202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Step 1: Import necessary libraries and packages","metadata":{}},{"cell_type":"code","source":"#Importing necessary libraries and packages\nimport numpy as np # linear algebra\n\nimport pandas as pd\n# data processing, CSV file I/O (e.g. pd.read_csv)\nfrom datetime import datetime\n# returns current date and time\nnow = datetime.now()\n\n#Visualisation\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\n%matplotlib inline\nimport missingno as msno\nfrom sklearn.linear_model import LinearRegression\nfrom scipy import stats\n\nimport plotly.graph_objects as go\nimport plotly.express as px\nfrom wordcloud import WordCloud","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:38:01.501570Z","iopub.execute_input":"2023-03-12T14:38:01.502058Z","iopub.status.idle":"2023-03-12T14:38:01.512892Z","shell.execute_reply.started":"2023-03-12T14:38:01.502014Z","shell.execute_reply":"2023-03-12T14:38:01.511699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:42:47.105580Z","iopub.execute_input":"2023-03-12T14:42:47.106539Z","iopub.status.idle":"2023-03-12T14:42:47.111205Z","shell.execute_reply.started":"2023-03-12T14:42:47.106488Z","shell.execute_reply":"2023-03-12T14:42:47.109888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Step 2: Clean data","metadata":{}},{"cell_type":"code","source":"# Loading data & checking summary stats\ntrain = pd.read_csv('/kaggle/input/predict-student-performance-from-game-play/train.csv')\nprint('Train data shape:', train.shape )\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:42:49.478685Z","iopub.execute_input":"2023-03-12T14:42:49.479553Z","iopub.status.idle":"2023-03-12T14:43:51.973754Z","shell.execute_reply.started":"2023-03-12T14:42:49.479506Z","shell.execute_reply":"2023-03-12T14:43:51.972702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Preprocessing data\n# Get Information about Missing Values\ntrain.isnull().sum() #check how many missing values by variable","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:44:06.069571Z","iopub.execute_input":"2023-03-12T14:44:06.070291Z","iopub.status.idle":"2023-03-12T14:44:10.523494Z","shell.execute_reply.started":"2023-03-12T14:44:06.070249Z","shell.execute_reply":"2023-03-12T14:44:10.522414Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Since the nature of this datast has too many missing values in to many columns, we are not going to remove those records with missing values","metadata":{}},{"cell_type":"code","source":"train.duplicated().sum() # check duplicates","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:44:17.735576Z","iopub.execute_input":"2023-03-12T14:44:17.736330Z","iopub.status.idle":"2023-03-12T14:44:56.465060Z","shell.execute_reply.started":"2023-03-12T14:44:17.736287Z","shell.execute_reply":"2023-03-12T14:44:56.463945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Step 3 - EDA","metadata":{}},{"cell_type":"code","source":"from wordcloud import WordCloud","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:46:09.817851Z","iopub.execute_input":"2023-03-12T14:46:09.818892Z","iopub.status.idle":"2023-03-12T14:46:09.854554Z","shell.execute_reply.started":"2023-03-12T14:46:09.818850Z","shell.execute_reply":"2023-03-12T14:46:09.853202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Visualisation\nimport seaborn as sns\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:48:25.905290Z","iopub.execute_input":"2023-03-12T14:48:25.906572Z","iopub.status.idle":"2023-03-12T14:48:27.013700Z","shell.execute_reply.started":"2023-03-12T14:48:25.906520Z","shell.execute_reply":"2023-03-12T14:48:27.012294Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Start with the eventname column\ntext = \" \".join(x for x in train[\"event_name\"])\n\n# Create and generate a word cloud image:\nwordcloud = WordCloud(width = 800, height = 250, \n            background_color =\"black\",colormap=\"RdYlGn\",max_font_size=100, stopwords =None,repeat= True).generate(text)\nplt.figure(figsize = (10, 8),facecolor= \"#254441\") \n\n# Display the generated image:\nplt.imshow(wordcloud)\nplt.axis(\"off\")\nplt.margins(x=0, y=0)\nplt.tight_layout(pad = 0) \nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:48:32.594203Z","iopub.execute_input":"2023-03-12T14:48:32.594657Z","iopub.status.idle":"2023-03-12T14:49:16.676034Z","shell.execute_reply.started":"2023-03-12T14:48:32.594616Z","shell.execute_reply":"2023-03-12T14:49:16.675037Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"4 most frequently event_type appear in the train dataset are:\n* cutscene_click\n* navigate_click\n* object_click\n* person_click\n\nOther than click event type, people tend to hover over the map and click into it as well  (event_type = map_hover, map_click)","metadata":{}},{"cell_type":"markdown","source":"* cutscene_click \n* navigate_click 43%\n* object_click\n* person_click 23%","metadata":{}},{"cell_type":"markdown","source":"48% of all events are basic , 48% are undefined, and 4% are others.","metadata":{}},{"cell_type":"code","source":"# distribution for level column\nplt.hist(train['level'], bins=20)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:53:40.641836Z","iopub.execute_input":"2023-03-12T14:53:40.642324Z","iopub.status.idle":"2023-03-12T14:53:41.059682Z","shell.execute_reply.started":"2023-03-12T14:53:40.642280Z","shell.execute_reply":"2023-03-12T14:53:41.057303Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# distribution for page column\nplt.hist(train['page'], bins=5)\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:53:47.107620Z","iopub.execute_input":"2023-03-12T14:53:47.108108Z","iopub.status.idle":"2023-03-12T14:53:47.361377Z","shell.execute_reply.started":"2023-03-12T14:53:47.108066Z","shell.execute_reply":"2023-03-12T14:53:47.360342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# distribution for level group column\nplt.hist(train['level_group'], bins=5)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:53:54.049811Z","iopub.execute_input":"2023-03-12T14:53:54.050254Z","iopub.status.idle":"2023-03-12T14:53:58.034112Z","shell.execute_reply.started":"2023-03-12T14:53:54.050214Z","shell.execute_reply":"2023-03-12T14:53:58.032778Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"A histogram is a value distribution plot of numerical columns. It basically creates bins in various ranges in values and plots it where we can visualize how values are distributed. We can have a look where more values lie like in positive, negative, or at the center(mean).","metadata":{}},{"cell_type":"markdown","source":"# Step 3: EDA","metadata":{}},{"cell_type":"code","source":"train.sample(n=10)\n","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:54:34.453301Z","iopub.execute_input":"2023-03-12T14:54:34.454075Z","iopub.status.idle":"2023-03-12T14:54:35.283752Z","shell.execute_reply.started":"2023-03-12T14:54:34.454025Z","shell.execute_reply":"2023-03-12T14:54:35.282751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe()","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:54:37.682663Z","iopub.execute_input":"2023-03-12T14:54:37.683566Z","iopub.status.idle":"2023-03-12T14:54:44.680946Z","shell.execute_reply.started":"2023-03-12T14:54:37.683520Z","shell.execute_reply":"2023-03-12T14:54:44.679821Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Correlation Matrix\ntrain.corr()","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:54:44.684895Z","iopub.execute_input":"2023-03-12T14:54:44.685713Z","iopub.status.idle":"2023-03-12T14:54:49.324339Z","shell.execute_reply.started":"2023-03-12T14:54:44.685668Z","shell.execute_reply":"2023-03-12T14:54:49.323168Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f = plt.figure(figsize=(19, 15))\nplt.matshow(train.corr(), fignum=f.number)\nplt.xticks(range(train.select_dtypes(['number']).shape[1]), train.select_dtypes(['number']).columns, fontsize=14, rotation=45)\nplt.yticks(range(train.select_dtypes(['number']).shape[1]), train.select_dtypes(['number']).columns, fontsize=14)\ncb = plt.colorbar()\ncb.ax.tick_params(labelsize=14)\nplt.title('Correlation Matrix', fontsize=16);","metadata":{"execution":{"iopub.status.busy":"2023-03-12T14:55:10.902339Z","iopub.execute_input":"2023-03-12T14:55:10.902819Z","iopub.status.idle":"2023-03-12T14:55:18.105778Z","shell.execute_reply.started":"2023-03-12T14:55:10.902778Z","shell.execute_reply":"2023-03-12T14:55:18.104712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"(to be continue)","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3\"></a>\n# <p style=\"padding:10px;background-color:#ffa7ca;margin:0;color:white;font-family:newtimeroman;font-size:100%;text-align:center;border-radius: 50px 50px;overflow:hidden;font-weight:500\">Thank you for your time!</p>\n\n<center> <img src=\"https://images.pexels.com/photos/4588010/pexels-photo-4588010.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1\">","metadata":{}}]}