{"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=\"margin:0;font-size:35px;font-family:verdana;text-align:center;display:fill;border-radius:5px;overflow:hidden;\"> ⚡️Touchdown! American Football EDA and Domain Overview</div>\n\n<h5 style=\"text-align: right; font-family: optima; font-size: 12px; font-style: normal; font-weight: bold; text-decoration: None; text-transform: none; letter-spacing: 1px; color: #254E58; background-color: #ffffff;\">If winning isn't everything, why do they keep score?</h5>\n\n<br>    \n<p style=\"text-align: center;\">\n<img src=\"https://drive.google.com/uc?export=view&id=15mebeYwHmCoj0Z8ye4Q6jBcBgjjV0l_L\" style='width: 500px; height: 500px;'>\n</p>\n<p style=\"text-align: right\">Generated by Open Journey, love this one</p>","metadata":{}},{"cell_type":"markdown","source":"<a id=\"top\"></a>\n# <div style=\"padding:20px;color:white;margin:0;font-size:35px;font-family:verdana;text-align:center;display:fill;border-radius:40px;background-color:#5236A8;overflow:hidden\"><b>Table of Contents</b></div>\n\n<div style=\"background-color:aliceblue; padding:30px; font-size:15px;color:#034914\">\n    \n* [1. Introduction](#1)\n    - [Problem Statement](#1.1)\n    - [Background and Context](#1.2)\n    - [Dataset Overview](#1.3)\n    - [Objective and Goals](#1.4)\n\n* [2. Data Exploration](#2)\n    - [Load libraries](#2.1)\n    - [Data loading](#2.2)\n    - [Take a look at the data](#2.3)\n    - [Watching football! (for 12 seconds, hide your snacks)](#2.4)\n    - [Conclusions](#2.5)\n\n* [3. EDA](#3)\n    - [Hunt for NaN values](#3.1)\n    - [How many games in datasets?](#3.2)\n    - [How many plays in datasets?](#3.3)\n    - [Distribution of x position of players](#3.4)\n    - [Distribution of y position of players](#3.5)\n    - [Distribution of players' orientation](#3.6)\n    - [Distribution of players' acceleration](#3.7)\n    - [Distribution of players' direction](#3.8)","metadata":{}},{"cell_type":"markdown","source":"<a id=\"1\"></a>\n# <div style=\"padding:20px;color:white;margin:0;font-size:35px;font-family:verdana;text-align:center;display:fill;border-radius:40px;background-color:#5236A8;overflow:hidden\"><b>Problem Statement </b><a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></div>","metadata":{}},{"cell_type":"markdown","source":"<a id=\"1.1\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Problem</b> statement <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"markdown","source":"The goal of this competition is to use game footage and player tracking data to detect moments of contact between player pairs and when players make non-foot contact with the ground. The aim is to improve player safety by accurately identifying moments of contact during a football game.\n\nThis is a code competition where you will be required to submit your model, which will then be rerun on a set of unseen plays. The competition requires a strong understanding of machine learning and computer vision techniques, as well as the ability to work with video and tracking data.\n\nBy accurately detecting contact moments during a football game, the NFL hopes to identify correlations between certain types of contact and injury, which can contribute to future prevention. Your efforts could help mitigate unsafe situations and reduce injury to all players. Submissions will be evaluated on the Matthews Correlation Coefficient between the predicted and actual contact events.\n\nThis competition provides a unique opportunity to demonstrate your skills in computer vision and machine learning and make a positive impact on player health and safety in the NFL. Get ready to put your knowledge and skills to the test!","metadata":{}},{"cell_type":"markdown","source":"<a id=\"1.2\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Background</b> and context <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"markdown","source":"The National Football League (NFL) has teamed up with Amazon Web Services (AWS) to improve player safety and predict player injuries. In prior years, the NFL challenged the Kaggle community to create helmet impact detection and identification algorithms. This year, the NFL is taking it a step further by asking the Kaggle community to automatically identify all moments when players experience contact during a football game.","metadata":{}},{"cell_type":"markdown","source":"<a id=\"1.3\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Data</b> <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"markdown","source":"For this competition, you will be provided with game footage and player tracking data. Each play has four associated videos - two time-synced and aligned sideline and endzone views, and an All29 view which is not guaranteed to be time-synced. The training set videos are located in the \"train/\" folder, with corresponding labels in the \"train_labels.csv\" file. The videos for which you must make predictions are located in the \"test/\" folder.\n\nAdditionally, you will also be provided with baseline helmet detection and assignment boxes for the training and test sets, as well as 10 Hz player tracking data and video metadata.","metadata":{}},{"cell_type":"markdown","source":"<a id=\"1.4\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Goal</b> <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"markdown","source":"The ultimate goal of this competition is to accurately detect all moments of contact between player pairs and when players make non-foot contact with the ground. With accurate contact detection, the NFL can identify correlations between certain types of contact and injury, which can contribute to future prevention and improved player health and safety.","metadata":{}},{"cell_type":"markdown","source":"<a id=\"2\"></a>\n# <div style=\"padding:20px;color:white;margin:0;font-size:35px;font-family:verdana;text-align:center;display:fill;border-radius:40px;background-color:#5236A8;overflow:hidden\"><b>Data Exploration</b> <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></div>","metadata":{}},{"cell_type":"markdown","source":"<a id=\"2.1\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Load</b> libraries <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"code","source":"!pip install plotly==5.11.0","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:26:41.281094Z","iopub.execute_input":"2023-02-11T19:26:41.282977Z","iopub.status.idle":"2023-02-11T19:27:28.484446Z","shell.execute_reply.started":"2023-02-11T19:26:41.282565Z","shell.execute_reply":"2023-02-11T19:27:28.483341Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from pathlib import Path\nfrom IPython.display import HTML\nfrom IPython.display import Video\n\nimport pandas as pd\nimport numpy as np\nimport plotly.express as px","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:28.486629Z","iopub.execute_input":"2023-02-11T19:27:28.486919Z","iopub.status.idle":"2023-02-11T19:27:29.774661Z","shell.execute_reply.started":"2023-02-11T19:27:28.486893Z","shell.execute_reply":"2023-02-11T19:27:29.772978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"2.2\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Data</b> loading <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"code","source":"data_path = Path(\"/kaggle/input/nfl-player-contact-detection\")","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:29.776302Z","iopub.execute_input":"2023-02-11T19:27:29.776734Z","iopub.status.idle":"2023-02-11T19:27:29.782219Z","shell.execute_reply.started":"2023-02-11T19:27:29.776693Z","shell.execute_reply":"2023-02-11T19:27:29.780731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_labels = pd.read_csv(data_path / \"train_labels.csv\")\ntrain_player_tracking = pd.read_csv(data_path / \"train_player_tracking.csv\")\ntrain_baseline_helmets = pd.read_csv(data_path / \"train_baseline_helmets.csv\")\ntrain_video_metadata = pd.read_csv(data_path / \"train_video_metadata.csv\")\n\ntest_player_tracking = pd.read_csv(data_path / \"test_player_tracking.csv\")\ntest_baseline_helmets = pd.read_csv(data_path / \"test_baseline_helmets.csv\")\ntest_video_metadata = pd.read_csv(data_path / \"test_video_metadata.csv\")\n\nsample_submission = pd.read_csv(data_path / \"sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:29.783281Z","iopub.execute_input":"2023-02-11T19:27:29.783543Z","iopub.status.idle":"2023-02-11T19:27:50.046043Z","shell.execute_reply.started":"2023-02-11T19:27:29.783520Z","shell.execute_reply":"2023-02-11T19:27:50.044703Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"2.3\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Take</b> a look at the data <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"code","source":"train_player_tracking","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.049044Z","iopub.execute_input":"2023-02-11T19:27:50.049536Z","iopub.status.idle":"2023-02-11T19:27:50.089784Z","shell.execute_reply.started":"2023-02-11T19:27:50.049499Z","shell.execute_reply":"2023-02-11T19:27:50.088869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"So, there are data from sensors of plalyers. There are next columns:\n\n  - game_play: Unique game key and play id combination for the play.\n  - game_key: the ID code for the game.\n  - play_id: the ID code for the play.\n  - nfl_player_id: the player's ID code.\n  - datetime: timestamp at 10 Hz.\n  - step: timestep within play relative to the play start.\n  - position: the football position of the player.\n  - team: team of the player, either home or away.\n  - jersey_number: Player jersey number\n  - x_position: player position along the long axis of the field. See figure below.\n  - y_position: player position along the short axis of the field. See figure below.\n  - speed: speed in yards/second.\n  - distance: distance traveled from prior time point, in yards.\n  - orientation: orientation of player (deg).\n  - direction: angle of player motion (deg).\n  - acceleration: magnitiude of the total acceleration in yards/second^2.\n  - sa: Signed acceleration yards/second^2 in the direction the player is moving.\n","metadata":{}},{"cell_type":"markdown","source":"At the first look, all this information looks useful\n\nNow let's look at test_player_tracking","metadata":{}},{"cell_type":"code","source":"test_player_tracking","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.090977Z","iopub.execute_input":"2023-02-11T19:27:50.091641Z","iopub.status.idle":"2023-02-11T19:27:50.120310Z","shell.execute_reply.started":"2023-02-11T19:27:50.091606Z","shell.execute_reply":"2023-02-11T19:27:50.119079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Looks identical to train data, but has less data\n\nNow take a look at train_labels","metadata":{}},{"cell_type":"code","source":"train_labels","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.122053Z","iopub.execute_input":"2023-02-11T19:27:50.122445Z","iopub.status.idle":"2023-02-11T19:27:50.142901Z","shell.execute_reply.started":"2023-02-11T19:27:50.122384Z","shell.execute_reply":"2023-02-11T19:27:50.141587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"There we observe next columns:\n\n  - contact_id: A combination of the game_play, player_ids and step columns.\n  - game_play: the unique ID for the game and play.\n  - nfl_player_id_1 The lower numbered player id in the contact pair. If contact with ground then this is just the player id.\n  - nfl_player_id_2: The larger number player id in the contact pair. If for contact with the ground, this will contain an uppercase \"G\"\n  - step: A number representing each each timestep for each play, starting at 0 at the moment of the play starting, and incrementing by 1 every 0.1 seconds.\n  - datetime: The timetamp of the contact, at 10Hz\n  - contact: Whether contact occurred\n","metadata":{}},{"cell_type":"markdown","source":"In this table we see, whether pairs of players had a contact or not at some point of time.","metadata":{}},{"cell_type":"code","source":"sample_submission","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.144786Z","iopub.execute_input":"2023-02-11T19:27:50.145067Z","iopub.status.idle":"2023-02-11T19:27:50.161132Z","shell.execute_reply.started":"2023-02-11T19:27:50.145044Z","shell.execute_reply":"2023-02-11T19:27:50.159315Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"At submission we have to predict contact for pairs of players at particular game and play","metadata":{}},{"cell_type":"markdown","source":"Also we have there baseline_helmets tables for train and test sets. It's basically a predictions of helmet boxes, produced by winning solution of [previous competition](https://www.kaggle.com/c/nfl-health-and-safety-helmet-assignment) from NFL.","metadata":{}},{"cell_type":"code","source":"train_baseline_helmets","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.162874Z","iopub.execute_input":"2023-02-11T19:27:50.163351Z","iopub.status.idle":"2023-02-11T19:27:50.185333Z","shell.execute_reply.started":"2023-02-11T19:27:50.163310Z","shell.execute_reply":"2023-02-11T19:27:50.184039Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"There are next columns:\n\n  - game_play: Unique game key and play id combination for the play.\n  - game_key: the ID code for the game.\n  - play_id: the ID code for the play.\n  - view: The video view, either Sideline or Endzone\n  - video: The filename of the associated video.\n  - frame: The associated frame within the video.\n  - nfl_player_id: The imperfect predicted player id.\n  - player_label: The player label. A combination of V/H (home or visiting team) and the player jersey number.\n  - [left/width/top/height]: the specification of the bounding box of the prediction.\n","metadata":{}},{"cell_type":"markdown","source":"Basically, there is bounding box of helmet of each player. It may be useful, because contact with helmets is also may be considered as a contact of players\n\nThere is also a table of helmets for the test data:","metadata":{}},{"cell_type":"code","source":"test_baseline_helmets","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.187129Z","iopub.execute_input":"2023-02-11T19:27:50.187587Z","iopub.status.idle":"2023-02-11T19:27:50.209162Z","shell.execute_reply.started":"2023-02-11T19:27:50.187551Z","shell.execute_reply":"2023-02-11T19:27:50.207862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Looks identically","metadata":{}},{"cell_type":"markdown","source":"Finally, we have video metadata for train and test. Check out those ones","metadata":{}},{"cell_type":"code","source":"train_video_metadata","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.211523Z","iopub.execute_input":"2023-02-11T19:27:50.212633Z","iopub.status.idle":"2023-02-11T19:27:50.228008Z","shell.execute_reply.started":"2023-02-11T19:27:50.212574Z","shell.execute_reply":"2023-02-11T19:27:50.227296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_video_metadata","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.229268Z","iopub.execute_input":"2023-02-11T19:27:50.229731Z","iopub.status.idle":"2023-02-11T19:27:50.241830Z","shell.execute_reply.started":"2023-02-11T19:27:50.229704Z","shell.execute_reply":"2023-02-11T19:27:50.240621Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"So, what we see?\n\nFirstly, there are only 4 videos in a test set related to 2 games\n\nSecondly, we se there next columns:\n\n  - game_play: Unique game key and play id combination for the play.\n  - game_key: the ID code for the game.\n  - play_id: the ID code for the play.\n  - view: The video view, either Sideline or Endzone\n  - start_time: The timestamp of the video start.\n  - end_time: The timestamp when the video ends.\n  - snap_time: The timestamp when the play starts within the video. This is 5 seconds (300 frames) into the video.\n\nHave no thoughts about that for now","metadata":{}},{"cell_type":"markdown","source":"<a id=\"2.4\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Watching football!</b> (for 12 seconds, hide your snacks) <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"markdown","source":"Let's look at few video samples from training set","metadata":{}},{"cell_type":"code","source":"video_file = data_path / \"train\" / \"58168_003392_All29.mp4\"\nVideo(f\"{video_file}\", width=512, height=512, embed=True) ","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.244446Z","iopub.execute_input":"2023-02-11T19:27:50.244816Z","iopub.status.idle":"2023-02-11T19:27:50.352172Z","shell.execute_reply.started":"2023-02-11T19:27:50.244790Z","shell.execute_reply":"2023-02-11T19:27:50.351055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"video_file = data_path / \"train\" / \"58168_003392_Endzone.mp4\"\nVideo(f\"{video_file}\", width=512, height=512, embed=True) ","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.355661Z","iopub.execute_input":"2023-02-11T19:27:50.355991Z","iopub.status.idle":"2023-02-11T19:27:50.509687Z","shell.execute_reply.started":"2023-02-11T19:27:50.355965Z","shell.execute_reply":"2023-02-11T19:27:50.508802Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"video_file = data_path / \"train\" / \"58168_003392_Sideline.mp4\"\nVideo(f\"{video_file}\", width=512, height=512, embed=True) ","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.510603Z","iopub.execute_input":"2023-02-11T19:27:50.511568Z","iopub.status.idle":"2023-02-11T19:27:50.613349Z","shell.execute_reply.started":"2023-02-11T19:27:50.511526Z","shell.execute_reply":"2023-02-11T19:27:50.611758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"So, for each game we have 3 synchronized short videos.\n\nFun fuct: in test set we have videos from the train set. Disappointing🥲","metadata":{}},{"cell_type":"markdown","source":"<a id=\"2.5\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Conclusions</b><a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3\"></a>\n# <div style=\"padding:20px;color:white;margin:0;font-size:35px;font-family:verdana;text-align:center;display:fill;border-radius:40px;background-color:#5236A8;overflow:hidden\"><b>EDA</b> <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></div>","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3.1\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Hunt</b> for NaN values <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"code","source":"train_player_tracking.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.614772Z","iopub.execute_input":"2023-02-11T19:27:50.615052Z","iopub.status.idle":"2023-02-11T19:27:50.837090Z","shell.execute_reply.started":"2023-02-11T19:27:50.615027Z","shell.execute_reply":"2023-02-11T19:27:50.835599Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_labels.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:50.838737Z","iopub.execute_input":"2023-02-11T19:27:50.839369Z","iopub.status.idle":"2023-02-11T19:27:51.606659Z","shell.execute_reply.started":"2023-02-11T19:27:50.839327Z","shell.execute_reply":"2023-02-11T19:27:51.605010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_baseline_helmets.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:51.610125Z","iopub.execute_input":"2023-02-11T19:27:51.610533Z","iopub.status.idle":"2023-02-11T19:27:52.148848Z","shell.execute_reply.started":"2023-02-11T19:27:51.610502Z","shell.execute_reply":"2023-02-11T19:27:52.147751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_video_metadata.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:52.150077Z","iopub.execute_input":"2023-02-11T19:27:52.150425Z","iopub.status.idle":"2023-02-11T19:27:52.160581Z","shell.execute_reply.started":"2023-02-11T19:27:52.150366Z","shell.execute_reply":"2023-02-11T19:27:52.158852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Well, we return from the hunt empty-handed🐺","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3.2\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>How</b> many games in datasets? <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"code","source":"print(f\"There are: {train_player_tracking['game_key'].nunique()} games in train set\")\nprint(f\"There are: {test_player_tracking['game_key'].nunique()} games in test set\")","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:52.162171Z","iopub.execute_input":"2023-02-11T19:27:52.163116Z","iopub.status.idle":"2023-02-11T19:27:52.183835Z","shell.execute_reply.started":"2023-02-11T19:27:52.163049Z","shell.execute_reply":"2023-02-11T19:27:52.182726Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Remember, that games in test set are in the train set too","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3.3\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>How</b> many plays in datasets? <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"code","source":"print(f\"There are: {train_player_tracking['play_id'].nunique()} plays in train set\")\nprint(f\"There are: {test_player_tracking['play_id'].nunique()} plays in test set\")","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:52.184968Z","iopub.execute_input":"2023-02-11T19:27:52.186002Z","iopub.status.idle":"2023-02-11T19:27:52.197273Z","shell.execute_reply.started":"2023-02-11T19:27:52.185972Z","shell.execute_reply":"2023-02-11T19:27:52.196203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"3.4\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Distribution</b> of x position of players <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"code","source":"fig = px.histogram(train_player_tracking[\"x_position\"], title='Distribution of x position of players')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:52.198599Z","iopub.execute_input":"2023-02-11T19:27:52.198958Z","iopub.status.idle":"2023-02-11T19:27:52.832763Z","shell.execute_reply.started":"2023-02-11T19:27:52.198925Z","shell.execute_reply":"2023-02-11T19:27:52.831604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Mostly players are located at the starting line, where they all stay before game start. After that we see some increase at the center of the field","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3.5\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Distribution</b> of y position of players <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"code","source":"fig = px.histogram(train_player_tracking[\"y_position\"], title='Distribution of y position of players')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:52.834185Z","iopub.execute_input":"2023-02-11T19:27:52.834692Z","iopub.status.idle":"2023-02-11T19:27:53.252675Z","shell.execute_reply.started":"2023-02-11T19:27:52.834659Z","shell.execute_reply":"2023-02-11T19:27:53.251757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Mostly players are located near to the center of the y axis with some increases on sides. Maybe because players with ball try to go through another team on some side, not at the center (my opinion)","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3.6\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Distribution</b> of players' orientation <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{"execution":{"iopub.status.busy":"2023-02-09T23:28:01.208571Z","iopub.execute_input":"2023-02-09T23:28:01.208988Z","iopub.status.idle":"2023-02-09T23:28:01.217465Z","shell.execute_reply.started":"2023-02-09T23:28:01.208952Z","shell.execute_reply":"2023-02-09T23:28:01.215796Z"}}},{"cell_type":"code","source":"fig = px.histogram(train_player_tracking[\"orientation\"], title=\"Distribution of players\\' orientation\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:27:53.253973Z","iopub.execute_input":"2023-02-11T19:27:53.254300Z","iopub.status.idle":"2023-02-11T19:27:53.683510Z","shell.execute_reply.started":"2023-02-11T19:27:53.254275Z","shell.execute_reply":"2023-02-11T19:27:53.681289Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Mostly players are oriented at someones home zone, and we see a clear pattern of that","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3.7\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Distribution</b> of players' acceleration <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"code","source":"fig = px.histogram(train_player_tracking[\"acceleration\"], title=\"Distribution of players\\' acceleration\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-13T15:45:27.477234Z","iopub.execute_input":"2023-02-13T15:45:27.477838Z","iopub.status.idle":"2023-02-13T15:45:27.589332Z","shell.execute_reply.started":"2023-02-13T15:45:27.477708Z","shell.execute_reply":"2023-02-13T15:45:27.587176Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Mostly it's not high","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3.8\"></a>\n# <div><h2 style=\"font-family: Verdana; font-size: 25px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #155D07; background-color: #ffffff;\"><b>Distribution</b> of players' direction <a href=\"#top\" role=\"button\" aria-pressed=\"true\" >⬆️</a></h2></div>","metadata":{}},{"cell_type":"code","source":"fig = px.histogram(train_player_tracking[\"direction\"], title=\"Distribution of players\\' direction\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-11T19:29:42.698007Z","iopub.execute_input":"2023-02-11T19:29:42.698328Z","iopub.status.idle":"2023-02-11T19:29:43.127384Z","shell.execute_reply.started":"2023-02-11T19:29:42.698303Z","shell.execute_reply":"2023-02-11T19:29:43.126343Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"So, it seems like players go in different directions usually. Interestingly, this plot is not corresponding so much with the players' orientation plot.","metadata":{}},{"cell_type":"markdown","source":"## Notebook is still under construction. If you want to support me, upvote and reach me out in comments secton","metadata":{}}]}