{"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":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt #graphing\nimport plotly.express as px #graphing\nimport seaborn as sns #graphing\n\nfrom plotly.offline import plot, iplot, init_notebook_mode\nimport plotly.graph_objs as go\ninit_notebook_mode(connected=True)\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n        \npd.set_option('display.max_columns', None)        ","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-10-05T00:09:45.697649Z","iopub.execute_input":"2022-10-05T00:09:45.698252Z","iopub.status.idle":"2022-10-05T00:09:48.673531Z","shell.execute_reply.started":"2022-10-05T00:09:45.698128Z","shell.execute_reply":"2022-10-05T00:09:48.671786Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/tabular-playground-series-oct-2022/train_0.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-10-05T00:09:48.676286Z","iopub.execute_input":"2022-10-05T00:09:48.676748Z","iopub.status.idle":"2022-10-05T00:10:47.655101Z","shell.execute_reply.started":"2022-10-05T00:09:48.676695Z","shell.execute_reply":"2022-10-05T00:10:47.653617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-10-05T00:10:47.656702Z","iopub.execute_input":"2022-10-05T00:10:47.657114Z","iopub.status.idle":"2022-10-05T00:10:47.726058Z","shell.execute_reply.started":"2022-10-05T00:10:47.657079Z","shell.execute_reply":"2022-10-05T00:10:47.724873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:12:41.339795Z","iopub.execute_input":"2022-10-01T00:12:41.340167Z","iopub.status.idle":"2022-10-01T00:12:41.346928Z","shell.execute_reply.started":"2022-10-01T00:12:41.340132Z","shell.execute_reply":"2022-10-01T00:12:41.346024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:13:54.287602Z","iopub.execute_input":"2022-10-01T00:13:54.288307Z","iopub.status.idle":"2022-10-01T00:13:54.311243Z","shell.execute_reply.started":"2022-10-01T00:13:54.288269Z","shell.execute_reply":"2022-10-01T00:13:54.309648Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"corr = df.corr()\nsns.set(rc = {\"figure.figsize\": (15, 8)})\n\nsns.heatmap(corr, xticklabels = corr.columns, yticklabels = corr.columns, cmap = \"Spectral\")","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:13:54.313141Z","iopub.execute_input":"2022-10-01T00:13:54.313546Z","iopub.status.idle":"2022-10-01T00:14:19.236806Z","shell.execute_reply.started":"2022-10-01T00:13:54.313507Z","shell.execute_reply":"2022-10-01T00:14:19.235492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.ball_pos_x.max()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:18:37.395931Z","iopub.execute_input":"2022-10-01T00:18:37.396383Z","iopub.status.idle":"2022-10-01T00:18:37.411019Z","shell.execute_reply.started":"2022-10-01T00:18:37.396338Z","shell.execute_reply":"2022-10-01T00:18:37.409540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.ball_pos_x.min()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:19:00.649496Z","iopub.execute_input":"2022-10-01T00:19:00.650023Z","iopub.status.idle":"2022-10-01T00:19:00.664649Z","shell.execute_reply.started":"2022-10-01T00:19:00.649986Z","shell.execute_reply":"2022-10-01T00:19:00.663228Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## We can see a goal event around index 1530 since the ball position x axis resets to 0 ⚽","metadata":{}},{"cell_type":"code","source":"df_x = df.iloc[:1540]\ndf_x.ball_pos_x.plot()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:43:02.800464Z","iopub.execute_input":"2022-10-01T00:43:02.801746Z","iopub.status.idle":"2022-10-01T00:43:03.155951Z","shell.execute_reply.started":"2022-10-01T00:43:02.801687Z","shell.execute_reply":"2022-10-01T00:43:03.154689Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Also true for the y axis","metadata":{}},{"cell_type":"code","source":"df_x.ball_pos_y.plot()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T01:30:06.267127Z","iopub.execute_input":"2022-10-01T01:30:06.267768Z","iopub.status.idle":"2022-10-01T01:30:06.647713Z","shell.execute_reply.started":"2022-10-01T01:30:06.267721Z","shell.execute_reply":"2022-10-01T01:30:06.646270Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.ball_pos_y.max()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:19:11.318971Z","iopub.execute_input":"2022-10-01T00:19:11.319420Z","iopub.status.idle":"2022-10-01T00:19:11.331670Z","shell.execute_reply.started":"2022-10-01T00:19:11.319381Z","shell.execute_reply":"2022-10-01T00:19:11.330569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.ball_pos_y.min()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:19:21.176403Z","iopub.execute_input":"2022-10-01T00:19:21.176927Z","iopub.status.idle":"2022-10-01T00:19:21.191264Z","shell.execute_reply.started":"2022-10-01T00:19:21.176885Z","shell.execute_reply":"2022-10-01T00:19:21.189827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.ball_pos_z.max()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:19:34.161924Z","iopub.execute_input":"2022-10-01T00:19:34.162371Z","iopub.status.idle":"2022-10-01T00:19:34.174977Z","shell.execute_reply.started":"2022-10-01T00:19:34.162332Z","shell.execute_reply":"2022-10-01T00:19:34.173943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.ball_pos_z.min()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:19:51.507223Z","iopub.execute_input":"2022-10-01T00:19:51.507738Z","iopub.status.idle":"2022-10-01T00:19:51.525180Z","shell.execute_reply.started":"2022-10-01T00:19:51.507688Z","shell.execute_reply":"2022-10-01T00:19:51.523709Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## team_A_scoring_within_10sec: 1 indicates the team will score within 10 seconds (target variable) ⚽","metadata":{}},{"cell_type":"code","source":"df_team_A = df.iloc[:15000]\ndf_team_A.team_A_scoring_within_10sec.plot()","metadata":{"execution":{"iopub.status.busy":"2022-10-03T15:46:02.078689Z","iopub.execute_input":"2022-10-03T15:46:02.079168Z","iopub.status.idle":"2022-10-03T15:46:02.667541Z","shell.execute_reply.started":"2022-10-03T15:46:02.079109Z","shell.execute_reply":"2022-10-03T15:46:02.665665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## player_scoring_next: Ranges -1 to 5, 6 players in total. 🚘","metadata":{}},{"cell_type":"code","source":"df_team_A.player_scoring_next.plot()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T01:01:53.057408Z","iopub.execute_input":"2022-10-01T01:01:53.058286Z","iopub.status.idle":"2022-10-01T01:01:53.386808Z","shell.execute_reply.started":"2022-10-01T01:01:53.058237Z","shell.execute_reply":"2022-10-01T01:01:53.385921Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Normal distribution of player 0 x velocity 🚘","metadata":{}},{"cell_type":"code","source":"df.p0_vel_x.hist()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:53:11.409903Z","iopub.execute_input":"2022-10-01T00:53:11.410335Z","iopub.status.idle":"2022-10-01T00:53:11.801863Z","shell.execute_reply.started":"2022-10-01T00:53:11.410300Z","shell.execute_reply":"2022-10-01T00:53:11.800368Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Left skewed distribution of player 0 y velocity 🚘","metadata":{}},{"cell_type":"code","source":"df.p0_vel_y.hist()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:53:29.200379Z","iopub.execute_input":"2022-10-01T00:53:29.201193Z","iopub.status.idle":"2022-10-01T00:53:29.577567Z","shell.execute_reply.started":"2022-10-01T00:53:29.201144Z","shell.execute_reply":"2022-10-01T00:53:29.576686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Either you're boosting or you aren't  🚀","metadata":{}},{"cell_type":"code","source":"df.p0_boost.hist()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T00:53:59.736740Z","iopub.execute_input":"2022-10-01T00:53:59.737162Z","iopub.status.idle":"2022-10-01T00:54:00.128635Z","shell.execute_reply.started":"2022-10-01T00:53:59.737126Z","shell.execute_reply":"2022-10-01T00:54:00.127147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Ball y x Position Heatmap 🔥","metadata":{}},{"cell_type":"code","source":"df_pos = df.iloc[:30000]\nfig = px.density_heatmap(df_pos, x=\"ball_pos_y\", y=\"ball_pos_x\", nbinsx = 250, nbinsy = 175, color_continuous_scale = \"Portland\", range_color=(0, 3.6))\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 12, color = \"#FFFFFF\"))\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-05T00:13:41.688245Z","iopub.execute_input":"2022-10-05T00:13:41.688710Z","iopub.status.idle":"2022-10-05T00:13:41.849156Z","shell.execute_reply.started":"2022-10-05T00:13:41.688674Z","shell.execute_reply":"2022-10-05T00:13:41.847525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Ball y z Position Heatmap 🔥","metadata":{}},{"cell_type":"code","source":"fig = px.density_heatmap(df_pos, x=\"ball_pos_y\", y=\"ball_pos_z\", nbinsx = 250, nbinsy = 200, color_continuous_scale = \"Portland\", range_color=(0, 3.6))\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 12, color = \"#FFFFFF\"))\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-05T00:17:55.112726Z","iopub.execute_input":"2022-10-05T00:17:55.113249Z","iopub.status.idle":"2022-10-05T00:17:55.270361Z","shell.execute_reply.started":"2022-10-05T00:17:55.113210Z","shell.execute_reply":"2022-10-05T00:17:55.269391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Animation of ball during goal event: Ball resets to ball_pos_x = 0 and ball_pos_y = 0","metadata":{}},{"cell_type":"code","source":"df_iloc = df.iloc[1400:1540]\n\nfig = px.scatter_3d(df_iloc, x = \"ball_pos_x\", y = \"ball_pos_y\", z = \"ball_pos_z\",\n                    range_x = (80.8, -80.8),\n                    range_y = (106.392, -104.392),\n                    range_z = (1.296, 39.4372),\n                    animation_frame = \"event_time\",\n                    color_discrete_sequence = [\"#FFFFFF\"])\n\nfig.update_traces(marker = dict(size = 6))\nfig.layout.updatemenus[0].buttons[0].args[1]['frame']['duration'] = 0.0000001\nfig.layout.updatemenus[0].buttons[0].args[1]['transition']['duration'] = 0.0000001\nfig.update_coloraxes(showscale = False)\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 12, color = \"#FFFFFF\"))\nfig.update_layout(scene = dict(\n                    xaxis = dict(\n                         backgroundcolor=\"#950000\",\n                         gridcolor=\"white\",\n                         showbackground=True,\n                         zerolinecolor=\"white\",),\n                    yaxis = dict(\n                        backgroundcolor=\"#950000\",\n                        gridcolor=\"white\",\n                        showbackground=True,\n                        zerolinecolor=\"white\"),\n                    zaxis = dict(\n                        backgroundcolor=\"#950000\",\n                        gridcolor=\"white\",\n                        showbackground=True,\n                        zerolinecolor=\"white\",),),\n                    width=700,\n                    margin=dict(\n                    r=10, l=10,\n                    b=10, t=10)\n                  )\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T01:08:39.362668Z","iopub.execute_input":"2022-10-01T01:08:39.363172Z","iopub.status.idle":"2022-10-01T01:08:40.005444Z","shell.execute_reply.started":"2022-10-01T01:08:39.363133Z","shell.execute_reply":"2022-10-01T01:08:40.004325Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Animation of car during demolition event\n## Null values: A demolition occurs when the animation goes blank\n\n## What is Demolition in Rocket League?\nDemolition is referred to the bumps occur when a player runs into another player at supersonic speed. The victim of a demolition will explode and combust, but will respawn near their team's goal after a few seconds. If two players run into each other both at supersonic speed and their fenders collide, they will both be demolished. In higher-level gameplay, demolitions are sometimes used tactically to prevent an opponent from scoring, or to clear the way for a teammate to score.","metadata":{}},{"cell_type":"code","source":"df_iloc_car = df.iloc[600:800]\n\nfig = px.scatter_3d(df_iloc_car, x = \"p0_pos_x\", y = \"p0_pos_y\", z = \"p0_pos_z\",\n                    range_x = (80.8, -80.8),\n                    range_y = (104.392, -104.392),\n                    range_z = (0, 39.4372),\n                    animation_frame = \"event_time\",\n                    color_discrete_sequence = [\"#FFFFFF\"])\n\nfig.update_traces(marker = dict(size = 6))\nfig.layout.updatemenus[0].buttons[0].args[1]['frame']['duration'] = 0.0000001\nfig.layout.updatemenus[0].buttons[0].args[1]['transition']['duration'] = 0.0000001\nfig.update_coloraxes(showscale = False)\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 12, color = \"#FFFFFF\"))\nfig.update_layout(scene = dict(\n                    xaxis = dict(\n                         backgroundcolor=\"#950000\",\n                         gridcolor=\"white\",\n                         showbackground=True,\n                         zerolinecolor=\"white\",),\n                    yaxis = dict(\n                        backgroundcolor=\"#950000\",\n                        gridcolor=\"white\",\n                        showbackground=True,\n                        zerolinecolor=\"white\"),\n                    zaxis = dict(\n                        backgroundcolor=\"#950000\",\n                        gridcolor=\"white\",\n                        showbackground=True,\n                        zerolinecolor=\"white\",),),\n                    width=700,\n                    margin=dict(\n                    r=10, l=10,\n                    b=10, t=10)\n                  )\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T01:25:03.154182Z","iopub.execute_input":"2022-10-01T01:25:03.154662Z","iopub.status.idle":"2022-10-01T01:25:04.028709Z","shell.execute_reply.started":"2022-10-01T01:25:03.154599Z","shell.execute_reply":"2022-10-01T01:25:04.027530Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Driver Racepaths: 3 Orange (Red) Team, 3 Blue Team","metadata":{}},{"cell_type":"code","source":"df0 = df.iloc[:5000]\ncolors = [\"#9B000A\", \"#9B000A\", \"#9B000A\", \"#0A009B\", \"#0A009B\", \"#0A009B\"]\n\nfor i in range(6):\n    \n    fig = px.line_3d(df0, x=f\"p{i}_pos_x\", y=f\"p{i}_pos_y\", z=f\"p{i}_pos_z\")\n    fig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 12, color = \"#FFFFFF\"))\n    fig.update_layout(scene = dict(\n                    xaxis = dict(\n                         backgroundcolor=\"#00B60C\",\n                         gridcolor=\"white\",\n                         showbackground=True,\n                         zerolinecolor=\"white\",),\n                    yaxis = dict(\n                        backgroundcolor=\"#00B60C\",\n                        gridcolor=\"white\",\n                        showbackground=True,\n                        zerolinecolor=\"white\"),\n                    zaxis = dict(\n                        backgroundcolor=\"#00B60C\",\n                        gridcolor=\"white\",\n                        showbackground=True,\n                        zerolinecolor=\"white\",),),\n                    width=700,\n                    margin=dict(\n                    r=10, l=10,\n                    b=10, t=10)\n                  )\n    fig.update_traces(line_color = colors[i], textposition = \"top center\")\n    fig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-02T02:26:17.197135Z","iopub.execute_input":"2022-10-02T02:26:17.197596Z","iopub.status.idle":"2022-10-02T02:26:18.107895Z","shell.execute_reply.started":"2022-10-02T02:26:17.197562Z","shell.execute_reply":"2022-10-02T02:26:18.106700Z"},"trusted":true},"execution_count":null,"outputs":[]}]}