{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":16531,"sourceType":"competition"},{"sourceId":45533,"databundleVersionId":5748852,"sourceType":"competition"}],"dockerImageVersionId":30587,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"#importing the Libraries\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport plotly.express as px\ntrain=pd.read_csv(\"/kaggle/input/predict-student-performance-from-game-play/test.csv\")\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:39.767434Z","iopub.execute_input":"2023-12-05T07:29:39.767798Z","iopub.status.idle":"2023-12-05T07:29:39.812964Z","shell.execute_reply.started":"2023-12-05T07:29:39.767771Z","shell.execute_reply":"2023-12-05T07:29:39.811526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"****ANALYSING THE DATA****","metadata":{}},{"cell_type":"code","source":"#Getting the Data\ntrain.head(100)","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:39.836616Z","iopub.execute_input":"2023-12-05T07:29:39.836973Z","iopub.status.idle":"2023-12-05T07:29:39.869579Z","shell.execute_reply.started":"2023-12-05T07:29:39.836945Z","shell.execute_reply":"2023-12-05T07:29:39.868091Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Shape of the Data\nprint(\"The shape of the data\")\ntrain.shape","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:39.912101Z","iopub.execute_input":"2023-12-05T07:29:39.912493Z","iopub.status.idle":"2023-12-05T07:29:39.923141Z","shell.execute_reply.started":"2023-12-05T07:29:39.912462Z","shell.execute_reply":"2023-12-05T07:29:39.921411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Description of the Data\nprint(\"The data is described as\")\ntrain.describe()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:39.968864Z","iopub.execute_input":"2023-12-05T07:29:39.96928Z","iopub.status.idle":"2023-12-05T07:29:40.023061Z","shell.execute_reply.started":"2023-12-05T07:29:39.969249Z","shell.execute_reply":"2023-12-05T07:29:40.021426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating session id\nprint(\"The session_id is\")\ntrain[\"session_id\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.025238Z","iopub.execute_input":"2023-12-05T07:29:40.025527Z","iopub.status.idle":"2023-12-05T07:29:40.036113Z","shell.execute_reply.started":"2023-12-05T07:29:40.025502Z","shell.execute_reply":"2023-12-05T07:29:40.034688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating elapsed time\nprint(\"The elapsed time is \")\ntrain[\"elapsed_time\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.062397Z","iopub.execute_input":"2023-12-05T07:29:40.062823Z","iopub.status.idle":"2023-12-05T07:29:40.074026Z","shell.execute_reply.started":"2023-12-05T07:29:40.062796Z","shell.execute_reply":"2023-12-05T07:29:40.072665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"****ANALYSING THE VALUES****","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:03:35.988879Z","iopub.execute_input":"2023-12-04T17:03:35.98934Z","iopub.status.idle":"2023-12-04T17:03:35.99369Z","shell.execute_reply.started":"2023-12-04T17:03:35.989313Z","shell.execute_reply":"2023-12-04T17:03:35.992542Z"}}},{"cell_type":"code","source":"#Calculating room coor x\nprint(\"The room_coor_x is \")\ntrain[\"room_coor_x\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.102448Z","iopub.execute_input":"2023-12-05T07:29:40.102818Z","iopub.status.idle":"2023-12-05T07:29:40.114775Z","shell.execute_reply.started":"2023-12-05T07:29:40.102787Z","shell.execute_reply":"2023-12-05T07:29:40.113292Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating room_coor_y\nprint(\"The room_coor_y is\")\ntrain[\"room_coor_y\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.146822Z","iopub.execute_input":"2023-12-05T07:29:40.147841Z","iopub.status.idle":"2023-12-05T07:29:40.157739Z","shell.execute_reply.started":"2023-12-05T07:29:40.147785Z","shell.execute_reply":"2023-12-05T07:29:40.156756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calcutaing screen_coor_x\nprint(\"The screen_coor_x is \")\ntrain[\"screen_coor_x\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.187033Z","iopub.execute_input":"2023-12-05T07:29:40.188312Z","iopub.status.idle":"2023-12-05T07:29:40.200707Z","shell.execute_reply.started":"2023-12-05T07:29:40.188262Z","shell.execute_reply":"2023-12-05T07:29:40.198672Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"level_group\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.221635Z","iopub.execute_input":"2023-12-05T07:29:40.222032Z","iopub.status.idle":"2023-12-05T07:29:40.232734Z","shell.execute_reply.started":"2023-12-05T07:29:40.221982Z","shell.execute_reply":"2023-12-05T07:29:40.230363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Plotting the Graphs of the level group\nfig = px.histogram(train,\"level_group\")\nfig.show()\n#Plotting the graph of screen_coor_x\nfig = px.histogram(train,\"screen_coor_x\")\nfig.show()\n#Plotting the graph of room_coor_y\nfig=px.histogram(train,\"room_coor_y\")\nfig.show()\n#Plotting the graph of room_coor_x\nfig=px.histogram(train,\"room_coor_x\")\nfig.show()\n\n","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.301761Z","iopub.execute_input":"2023-12-05T07:29:40.302186Z","iopub.status.idle":"2023-12-05T07:29:40.517182Z","shell.execute_reply.started":"2023-12-05T07:29:40.302153Z","shell.execute_reply":"2023-12-05T07:29:40.516203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating full screen values\nprint(\"The full screen data is\")\ntrain[\"fullscreen\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.519224Z","iopub.execute_input":"2023-12-05T07:29:40.522357Z","iopub.status.idle":"2023-12-05T07:29:40.534416Z","shell.execute_reply.started":"2023-12-05T07:29:40.522303Z","shell.execute_reply":"2023-12-05T07:29:40.532715Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating hq values\nprint(\"The hq values are \")\ntrain[\"hq\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.535973Z","iopub.execute_input":"2023-12-05T07:29:40.536426Z","iopub.status.idle":"2023-12-05T07:29:40.549082Z","shell.execute_reply.started":"2023-12-05T07:29:40.536393Z","shell.execute_reply":"2023-12-05T07:29:40.547751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating music values\nprint(\"The value of music is\")\ntrain[\"music\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.552179Z","iopub.execute_input":"2023-12-05T07:29:40.553247Z","iopub.status.idle":"2023-12-05T07:29:40.565609Z","shell.execute_reply.started":"2023-12-05T07:29:40.553211Z","shell.execute_reply":"2023-12-05T07:29:40.563067Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating session level\nprint(\"The session_level is \")\ntrain[\"session_level\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.567095Z","iopub.execute_input":"2023-12-05T07:29:40.567681Z","iopub.status.idle":"2023-12-05T07:29:40.579724Z","shell.execute_reply.started":"2023-12-05T07:29:40.567622Z","shell.execute_reply":"2023-12-05T07:29:40.578389Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"****Using Linear Regression on the Dataset****\n","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:51:56.441527Z","iopub.execute_input":"2023-12-04T17:51:56.441858Z","iopub.status.idle":"2023-12-04T17:51:56.464604Z","shell.execute_reply.started":"2023-12-04T17:51:56.441832Z","shell.execute_reply":"2023-12-04T17:51:56.463409Z"}},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Plotting the Pie Graph\nfig= px.pie(wc,\"room_coor_x,room_coor_y)\nf\n","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.581566Z","iopub.execute_input":"2023-12-05T07:29:40.581956Z","iopub.status.idle":"2023-12-05T07:29:40.59126Z","shell.execute_reply.started":"2023-12-05T07:29:40.581925Z","shell.execute_reply":"2023-12-05T07:29:40.59008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Declaring the variable x\nx = train[[\"elapsed_time\"]]","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.592213Z","iopub.status.idle":"2023-12-05T07:29:40.592493Z","shell.execute_reply.started":"2023-12-05T07:29:40.592353Z","shell.execute_reply":"2023-12-05T07:29:40.592368Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Declaring the variable y\ny = train[[\"session_level\"]]","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.593698Z","iopub.status.idle":"2023-12-05T07:29:40.593958Z","shell.execute_reply.started":"2023-12-05T07:29:40.593826Z","shell.execute_reply":"2023-12-05T07:29:40.593839Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#importing the teain_test_split\nfrom sklearn.model_selection import train_test_split\nx_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.5)","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.594952Z","iopub.status.idle":"2023-12-05T07:29:40.595285Z","shell.execute_reply.started":"2023-12-05T07:29:40.595135Z","shell.execute_reply":"2023-12-05T07:29:40.595152Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating initial test values for x \nx_test.head()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.596631Z","iopub.status.idle":"2023-12-05T07:29:40.596925Z","shell.execute_reply.started":"2023-12-05T07:29:40.596785Z","shell.execute_reply":"2023-12-05T07:29:40.596799Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating initail test_values for y\ny_test.head()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.601494Z","iopub.execute_input":"2023-12-05T07:29:40.601926Z","iopub.status.idle":"2023-12-05T07:29:40.611078Z","shell.execute_reply.started":"2023-12-05T07:29:40.601893Z","shell.execute_reply":"2023-12-05T07:29:40.609628Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating initial train values for x\nx_train.head()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.661849Z","iopub.execute_input":"2023-12-05T07:29:40.662282Z","iopub.status.idle":"2023-12-05T07:29:40.673639Z","shell.execute_reply.started":"2023-12-05T07:29:40.662249Z","shell.execute_reply":"2023-12-05T07:29:40.672097Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating initial train values for y\ny_train.head()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.675922Z","iopub.execute_input":"2023-12-05T07:29:40.676309Z","iopub.status.idle":"2023-12-05T07:29:40.685211Z","shell.execute_reply.started":"2023-12-05T07:29:40.676283Z","shell.execute_reply":"2023-12-05T07:29:40.684158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#importing the algorithm\nfrom sklearn.linear_model import LinearRegression\n","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.686334Z","iopub.execute_input":"2023-12-05T07:29:40.686882Z","iopub.status.idle":"2023-12-05T07:29:40.693582Z","shell.execute_reply.started":"2023-12-05T07:29:40.68682Z","shell.execute_reply":"2023-12-05T07:29:40.692337Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lr = LinearRegression()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.694785Z","iopub.execute_input":"2023-12-05T07:29:40.695262Z","iopub.status.idle":"2023-12-05T07:29:40.707344Z","shell.execute_reply.started":"2023-12-05T07:29:40.695228Z","shell.execute_reply":"2023-12-05T07:29:40.705691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lr.fit(x_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.710262Z","iopub.execute_input":"2023-12-05T07:29:40.710606Z","iopub.status.idle":"2023-12-05T07:29:40.728892Z","shell.execute_reply.started":"2023-12-05T07:29:40.710581Z","shell.execute_reply":"2023-12-05T07:29:40.726696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred=lr.predict(x_test)","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.730673Z","iopub.execute_input":"2023-12-05T07:29:40.731479Z","iopub.status.idle":"2023-12-05T07:29:40.739846Z","shell.execute_reply.started":"2023-12-05T07:29:40.731447Z","shell.execute_reply":"2023-12-05T07:29:40.738259Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Predicting the test values for x\nx_test.head()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.741687Z","iopub.execute_input":"2023-12-05T07:29:40.7426Z","iopub.status.idle":"2023-12-05T07:29:40.758325Z","shell.execute_reply.started":"2023-12-05T07:29:40.742563Z","shell.execute_reply":"2023-12-05T07:29:40.756479Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_test.head()","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.760445Z","iopub.execute_input":"2023-12-05T07:29:40.76167Z","iopub.status.idle":"2023-12-05T07:29:40.776123Z","shell.execute_reply.started":"2023-12-05T07:29:40.761628Z","shell.execute_reply":"2023-12-05T07:29:40.773918Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Prediction of the algorithm for 100 observations\")\ny_pred[0:100]","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.778998Z","iopub.execute_input":"2023-12-05T07:29:40.780316Z","iopub.status.idle":"2023-12-05T07:29:40.793713Z","shell.execute_reply.started":"2023-12-05T07:29:40.780263Z","shell.execute_reply":"2023-12-05T07:29:40.791937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#importing mean_squarred_error\nfrom sklearn.metrics import mean_squared_error","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.795831Z","iopub.execute_input":"2023-12-05T07:29:40.796289Z","iopub.status.idle":"2023-12-05T07:29:40.802544Z","shell.execute_reply.started":"2023-12-05T07:29:40.796255Z","shell.execute_reply":"2023-12-05T07:29:40.801481Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Calculating the Error in the Model\nprint(\"The Error in the Model is \")\nmean_squared_error(y_test,y_pred)","metadata":{"execution":{"iopub.status.busy":"2023-12-05T07:29:40.803731Z","iopub.execute_input":"2023-12-05T07:29:40.804766Z","iopub.status.idle":"2023-12-05T07:29:40.821276Z","shell.execute_reply.started":"2023-12-05T07:29:40.804722Z","shell.execute_reply":"2023-12-05T07:29:40.820307Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Thanks for watching my hardwork!!","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}}]}