{"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)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport plotly.graph_objects as go\nimport plotly.express as px\n\nfrom plotnine import *\n\nimport warnings\nwarnings.simplefilter(action='ignore', category=Warning)\n\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 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","_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-10-01T22:19:38.107769Z","iopub.execute_input":"2022-10-01T22:19:38.108657Z","iopub.status.idle":"2022-10-01T22:19:41.402548Z","shell.execute_reply.started":"2022-10-01T22:19:38.108528Z","shell.execute_reply":"2022-10-01T22:19:41.401355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<iframe width=\"942\" height=\"530\" src=\"https://www.youtube.com/embed/krlaWEIx4XY\" title=\"New Rocket League Intro Music Got Me Like (MEME) #Shorts\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>","metadata":{}},{"cell_type":"markdown","source":"https://www.youtube.com/watch?v=krlaWEIx4XY\n\nNew Rocket League Intro Music Got Me Like (MEME) Shorts\n\n#Rocket League List of Actions\n\n* Win - Win a match\n* MVP - Earn the highest score in a match (you must be on the winning team)\n* Goal - Hit the ball into the opponent's goal\n* Aerial Goal - Score a goal from an aerial hit (a hit on the ball above goal height)\n* Backwards Goal - Score a goal by hitting the ball driving backwards\n* Bicycle Goal - Score a goal from a bicycle hit\n* Long Goal - Score a goal from a great distance (past half-field)\n* Turtle Goal - Score a goal by hitting the ball while upside-down\n* Pool Shot - Score a goal by hitting an opponent into the ball\n* Overtime Goal - Score a goal after the regulation time has ended\n* Hat Trick - Score 3 goals in a single game\n* Assist - Pass the ball to a teammate who scores\n* Playmaker - Have 3 assists in a single game\n* Save - Block a shot on your goal\n* Epic Save - Block a shot on goal that's on the verge of scoring\n* Savior - Block 3 shots on goal in a single game\n* Shot on Goal - Hit the ball towards the opponent team's goal\n* Center Ball - Hit the ball towards the center of the field near the opposing goal\n* Clear Ball - Hit the ball away from your own goal area\n* Demolition - Demolish another player\n* Extermination - Demolish 7 players in a single game\n* First Touch - Be the first to touch the ball on kickoff\n* Damage (Dropshot) - Hit a tile with the ball in its first or second phase\n* Ultra Damage (Dropshot) - Hit a tile with the ball in its third or final phase\n* Bicycle Hit - Hit the ball by flipping backwards into it. NOTE: This action used to grant 10 points, but it now grants 0.\n* Low Five - Give a congratulatory bump to your team's goal-scorer after the goal\n* High Five - Give a high-flying congratulatory bump to your team's goal-scorer after the goal\n* Swish Goal (Hoops) - In Hoops, score a goal without the ball hitting anything on the way in\n\nhttps://rocketleague.fandom.com/wiki/Points","metadata":{}},{"cell_type":"code","source":"dt = pd.read_csv(\"/kaggle/input/tabular-playground-series-oct-2022/train_dtypes.csv\")\ndt.head()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T22:20:11.556687Z","iopub.execute_input":"2022-10-01T22:20:11.557428Z","iopub.status.idle":"2022-10-01T22:20:11.580413Z","shell.execute_reply.started":"2022-10-01T22:20:11.557384Z","shell.execute_reply":"2022-10-01T22:20:11.579508Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#We have 10 train csv (61 columns each one)","metadata":{}},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/tabular-playground-series-oct-2022/train_4.csv\", delimiter=',', encoding='utf8')\npd.set_option('display.max_columns', None)\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T22:20:16.342647Z","iopub.execute_input":"2022-10-01T22:20:16.343289Z","iopub.status.idle":"2022-10-01T22:20:40.045133Z","shell.execute_reply.started":"2022-10-01T22:20:16.343254Z","shell.execute_reply":"2022-10-01T22:20:40.043785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-10-01T22:21:37.084542Z","iopub.execute_input":"2022-10-01T22:21:37.084963Z","iopub.status.idle":"2022-10-01T22:21:37.413187Z","shell.execute_reply.started":"2022-10-01T22:21:37.084930Z","shell.execute_reply":"2022-10-01T22:21:37.411963Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"team_scoring_next\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-10-01T22:21:45.750479Z","iopub.execute_input":"2022-10-01T22:21:45.750928Z","iopub.status.idle":"2022-10-01T22:21:45.839721Z","shell.execute_reply.started":"2022-10-01T22:21:45.750890Z","shell.execute_reply":"2022-10-01T22:21:45.838543Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"player_scoring_next\"].value_counts()","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-10-01T22:21:50.758546Z","iopub.execute_input":"2022-10-01T22:21:50.759305Z","iopub.status.idle":"2022-10-01T22:21:50.786383Z","shell.execute_reply.started":"2022-10-01T22:21:50.759262Z","shell.execute_reply":"2022-10-01T22:21:50.784991Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Columns of (My) Interest (names require the below explanations)\n\nball_pos_xyz: Ball's position as a 3d vector.\n\nball_vel_xyz: Ball's velocity as a 3d vector.\n\np{i}_pos_xyz: Player i's position as a 3d vector.\n\np{i}_vel_xyz: Player i's velocity as a 3d vector.\n\np{i}_boost: Player i's boost remaining, in 0, 100. A player can consume boost to substantially increase their speed, and is required to fly up into the z dimension (besides driving up a wall, or the small air gained by a jump).\n\nboost{i}_timer: Time in seconds until big boost orb i respawns, or 0 if it's available. Big boost orbs grant a full 100 boost to a player driving over it.\n\nplayer_scoring_next (train only): Which player scores at the end of the current event, in 0, 6), or -1 if the event does not end in a goal.\n\nteam_scoring_next (train only): Which team scores at the end of the current event (A or B), or NaN if the event does not end in a goal.\n\nteam_A|B_scoring_within_10sec (train only): Target columns Value of 1 if team_scoring_next == A|B and time_before_event is in -10, 0, otherwise 0.\n\nhttps://www.kaggle.com/competitions/tabular-playground-series-oct-2022/data","metadata":{}},{"cell_type":"markdown","source":"#Team A Scoring within 10 seconds","metadata":{}},{"cell_type":"code","source":"#Code by Rohannanaware (Yoda) https://www.kaggle.com/code/rohannanaware/decision-tree-basics-us-income-dataset/notebook\n\n(ggplot(df, aes(x = \"team_scoring_next\", fill = \"team_A_scoring_within_10sec\"))\n + geom_bar(position=\"fill\")\n + theme(axis_text_x = element_text(angle = 60, hjust = 1))\n)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-01T22:22:13.366657Z","iopub.execute_input":"2022-10-01T22:22:13.367098Z","iopub.status.idle":"2022-10-01T22:22:20.215895Z","shell.execute_reply.started":"2022-10-01T22:22:13.367062Z","shell.execute_reply":"2022-10-01T22:22:20.214695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Turtle Goal\n\nScore a goal by hitting the ball while upside-down","metadata":{}},{"cell_type":"markdown","source":"![](https://i.makeagif.com/media/8-08-2015/VX1CjE.gif)https://makeagif.com/gif/ninja-turtle-goal-rocket-league-VX1CjE","metadata":{}},{"cell_type":"markdown","source":"##Team B Scoring within 10 seconds","metadata":{}},{"cell_type":"code","source":"#Code by Rohannanaware (Yoda) https://www.kaggle.com/code/rohannanaware/decision-tree-basics-us-income-dataset/notebook\n\n(ggplot(df, aes(x = \"team_scoring_next\", fill = \"team_B_scoring_within_10sec\"))\n + geom_bar(position=\"fill\")\n + theme(axis_text_x = element_text(angle = 60, hjust = 1))\n)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-01T22:22:26.308684Z","iopub.execute_input":"2022-10-01T22:22:26.310003Z","iopub.status.idle":"2022-10-01T22:22:33.120828Z","shell.execute_reply.started":"2022-10-01T22:22:26.309953Z","shell.execute_reply":"2022-10-01T22:22:33.120048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#https://www.kaggle.com/ilyabiro/visual-analysis-or-how-to-find-out-who-escaped-1st/notebook\nfig, axarr = plt.subplots(1, 2, figsize=(14,8))\naxarr[0].set_title('Player 5 Boost Distribution')\nf = sns.distplot(df['p5_boost'], color='g', bins=15, ax=axarr[0])\naxarr[1].set_title('Player 5 Boost Distribution for the two Subpopulations')\ng = sns.kdeplot(df['p5_boost'].loc[df['p5_vel_z'] == 1], \n                shade= True, ax=axarr[1], label='p5_vel_z').set_xlabel('p5_boost')\ng = sns.kdeplot(df['p5_boost'].loc[df['p5_vel_z'] == 0], \n                shade=True, ax=axarr[1], label='p5_vel_z')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-01T22:22:38.997485Z","iopub.execute_input":"2022-10-01T22:22:38.997888Z","iopub.status.idle":"2022-10-01T22:22:47.765705Z","shell.execute_reply.started":"2022-10-01T22:22:38.997856Z","shell.execute_reply":"2022-10-01T22:22:47.764581Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##https://www.kaggle.com/ilyabiro/visual-analysis-or-how-to-find-out-who-escaped-1st/notebook\nfig, ax = plt.subplots(figsize=(10, 8))\nax.set_title('Ball s & Player s velocity Distribution')\ng = sns.kdeplot(df['ball_vel_z'].loc[df['p1_vel_z'] == 1], \n                shade= True, ax=ax, label='p1_vel_z').set_xlabel('ball_vel_z')\ng = sns.kdeplot(df['ball_vel_z'].loc[df['p1_vel_z'] == 0], \n                shade=True, ax=ax, label='p1_vel_z')\nax.grid()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-01T22:22:56.058006Z","iopub.execute_input":"2022-10-01T22:22:56.058460Z","iopub.status.idle":"2022-10-01T22:22:56.561977Z","shell.execute_reply.started":"2022-10-01T22:22:56.058423Z","shell.execute_reply":"2022-10-01T22:22:56.560775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#High Five Team's Goal-Scorer\n\nIt's artistical though I couldn' t interpret that parallel chart below","metadata":{}},{"cell_type":"code","source":"fig = px.parallel_categories(df, color=\"player_scoring_next\", color_continuous_scale=px.colors.sequential.OrRd)\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-01T22:20:50.085662Z","iopub.execute_input":"2022-10-01T22:20:50.086102Z","iopub.status.idle":"2022-10-01T22:21:07.395181Z","shell.execute_reply.started":"2022-10-01T22:20:50.086067Z","shell.execute_reply":"2022-10-01T22:21:07.394034Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.datasets import make_blobs\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.calibration import CalibratedClassifierCV\nfrom sklearn.metrics import log_loss","metadata":{"execution":{"iopub.status.busy":"2022-10-01T22:23:07.651995Z","iopub.execute_input":"2022-10-01T22:23:07.652977Z","iopub.status.idle":"2022-10-01T22:23:07.763797Z","shell.execute_reply.started":"2022-10-01T22:23:07.652936Z","shell.execute_reply":"2022-10-01T22:23:07.762794Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.random.seed(0)","metadata":{"execution":{"iopub.status.busy":"2022-10-01T22:23:11.900081Z","iopub.execute_input":"2022-10-01T22:23:11.902902Z","iopub.status.idle":"2022-10-01T22:23:11.907793Z","shell.execute_reply.started":"2022-10-01T22:23:11.902853Z","shell.execute_reply":"2022-10-01T22:23:11.906928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Robin East https://www.kaggle.com/code/robineast/log-loss-example\n\n# Generate data\nX, y = make_blobs(n_samples=1000, n_features=2, random_state=42,\n                  cluster_std=5.0)\nX_train, y_train = X[:600], y[:600]\nX_valid, y_valid = X[600:800], y[600:800]\nX_train_valid, y_train_valid = X[:800], y[:800]\nX_test, y_test = X[800:], y[800:]","metadata":{"execution":{"iopub.status.busy":"2022-10-01T22:23:15.738798Z","iopub.execute_input":"2022-10-01T22:23:15.739755Z","iopub.status.idle":"2022-10-01T22:23:15.749156Z","shell.execute_reply.started":"2022-10-01T22:23:15.739704Z","shell.execute_reply":"2022-10-01T22:23:15.747974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Robin East https://www.kaggle.com/code/robineast/log-loss-example\n\n# Train uncalibrated random forest classifier on whole train and validation\n# data and evaluate on test data\nclf = RandomForestClassifier(n_estimators=25)\nclf.fit(X_train_valid, y_train_valid)\nclf_probs = clf.predict_proba(X_test)\nscore = log_loss(y_test, clf_probs)\nprint(score)","metadata":{"execution":{"iopub.status.busy":"2022-10-01T22:23:20.119064Z","iopub.execute_input":"2022-10-01T22:23:20.119736Z","iopub.status.idle":"2022-10-01T22:23:20.198446Z","shell.execute_reply.started":"2022-10-01T22:23:20.119691Z","shell.execute_reply":"2022-10-01T22:23:20.196619Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Acknowledgements:\n\nRobin East https://www.kaggle.com/code/robineast/log-loss-example\n\nRohannanaware (Yoda)\nhttps://www.kaggle.com/code/rohannanaware/decision-tree-basics-us-income-dataset/notebook\n\nIlyabiro https://www.kaggle.com/ilyabiro/visual-analysis-or-how-to-find-out-who-escaped-1st/notebook","metadata":{"execution":{"iopub.status.busy":"2022-10-01T20:47:12.527595Z","iopub.execute_input":"2022-10-01T20:47:12.528012Z","iopub.status.idle":"2022-10-01T20:47:12.537622Z","shell.execute_reply.started":"2022-10-01T20:47:12.527975Z","shell.execute_reply":"2022-10-01T20:47:12.536415Z"}}},{"cell_type":"markdown","source":"#That's my Cosplay Submission \n\n![](https://c.tenor.com/UKHJAy-BQX8AAAAd/rocket-league-cosplay.gif)https://tenor.com/view/rocket-league-cosplay-gif-14435823","metadata":{}}]}