{"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)\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":{"execution":{"iopub.status.busy":"2022-08-02T00:08:50.578164Z","iopub.execute_input":"2022-08-02T00:08:50.579237Z","iopub.status.idle":"2022-08-02T00:08:50.648082Z","shell.execute_reply.started":"2022-08-02T00:08:50.579142Z","shell.execute_reply":"2022-08-02T00:08:50.646847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"! pip install moviepy","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:08:50.650534Z","iopub.execute_input":"2022-08-02T00:08:50.651291Z","iopub.status.idle":"2022-08-02T00:09:31.190495Z","shell.execute_reply.started":"2022-08-02T00:08:50.651243Z","shell.execute_reply":"2022-08-02T00:09:31.189132Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sn\nfrom moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip\nfrom IPython.display import Video\n\n","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:31.192170Z","iopub.execute_input":"2022-08-02T00:09:31.192516Z","iopub.status.idle":"2022-08-02T00:09:32.142272Z","shell.execute_reply.started":"2022-08-02T00:09:31.192482Z","shell.execute_reply":"2022-08-02T00:09:32.140845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nname = \"vid_test.mp4\"\nffmpeg_extract_subclip(\nf\"/kaggle/input/dfl-bundesliga-data-shootout/train/1606b0e6_1.mp4\", \n510.59 - 12.5, \n510.59 + 12.5, \ntargetname=name,\n)\nVideo(name, width=800)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.145246Z","iopub.execute_input":"2022-08-02T00:09:32.145615Z","iopub.status.idle":"2022-08-02T00:09:32.625660Z","shell.execute_reply.started":"2022-08-02T00:09:32.145575Z","shell.execute_reply":"2022-08-02T00:09:32.624248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sb","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.629059Z","iopub.execute_input":"2022-08-02T00:09:32.629769Z","iopub.status.idle":"2022-08-02T00:09:32.636107Z","shell.execute_reply.started":"2022-08-02T00:09:32.629718Z","shell.execute_reply":"2022-08-02T00:09:32.635021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv(r'/kaggle/input/dfl-bundesliga-data-shootout/train.csv') ","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.637184Z","iopub.execute_input":"2022-08-02T00:09:32.638013Z","iopub.status.idle":"2022-08-02T00:09:32.669496Z","shell.execute_reply.started":"2022-08-02T00:09:32.637980Z","shell.execute_reply":"2022-08-02T00:09:32.668612Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.671120Z","iopub.execute_input":"2022-08-02T00:09:32.671752Z","iopub.status.idle":"2022-08-02T00:09:32.691056Z","shell.execute_reply.started":"2022-08-02T00:09:32.671716Z","shell.execute_reply":"2022-08-02T00:09:32.690296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.692317Z","iopub.execute_input":"2022-08-02T00:09:32.692776Z","iopub.status.idle":"2022-08-02T00:09:32.698761Z","shell.execute_reply.started":"2022-08-02T00:09:32.692742Z","shell.execute_reply":"2022-08-02T00:09:32.697932Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.700084Z","iopub.execute_input":"2022-08-02T00:09:32.700636Z","iopub.status.idle":"2022-08-02T00:09:32.734114Z","shell.execute_reply.started":"2022-08-02T00:09:32.700605Z","shell.execute_reply":"2022-08-02T00:09:32.732908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.739059Z","iopub.execute_input":"2022-08-02T00:09:32.739626Z","iopub.status.idle":"2022-08-02T00:09:32.745739Z","shell.execute_reply.started":"2022-08-02T00:09:32.739592Z","shell.execute_reply":"2022-08-02T00:09:32.744625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.748559Z","iopub.execute_input":"2022-08-02T00:09:32.749797Z","iopub.status.idle":"2022-08-02T00:09:32.760473Z","shell.execute_reply.started":"2022-08-02T00:09:32.749753Z","shell.execute_reply":"2022-08-02T00:09:32.759476Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.762261Z","iopub.execute_input":"2022-08-02T00:09:32.763039Z","iopub.status.idle":"2022-08-02T00:09:32.775702Z","shell.execute_reply.started":"2022-08-02T00:09:32.763006Z","shell.execute_reply":"2022-08-02T00:09:32.774866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'{data.event_attributes.isna().sum() * 100 / data.index.size} % null values of the dataste')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.779158Z","iopub.execute_input":"2022-08-02T00:09:32.779801Z","iopub.status.idle":"2022-08-02T00:09:32.787477Z","shell.execute_reply.started":"2022-08-02T00:09:32.779756Z","shell.execute_reply":"2022-08-02T00:09:32.786419Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### here we can't eliminate from nan data as it posses 60 % of data and because it's categorical data we can use strategies such as fill the nan values by the most frequent words in event_attributes","metadata":{}},{"cell_type":"code","source":"data.describe().round(2)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.790540Z","iopub.execute_input":"2022-08-02T00:09:32.791270Z","iopub.status.idle":"2022-08-02T00:09:32.812448Z","shell.execute_reply.started":"2022-08-02T00:09:32.791228Z","shell.execute_reply":"2022-08-02T00:09:32.811647Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event_attributes.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.814125Z","iopub.execute_input":"2022-08-02T00:09:32.814459Z","iopub.status.idle":"2022-08-02T00:09:32.822725Z","shell.execute_reply.started":"2022-08-02T00:09:32.814430Z","shell.execute_reply":"2022-08-02T00:09:32.821497Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event_attributes.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.824773Z","iopub.execute_input":"2022-08-02T00:09:32.825514Z","iopub.status.idle":"2022-08-02T00:09:32.838975Z","shell.execute_reply.started":"2022-08-02T00:09:32.825469Z","shell.execute_reply":"2022-08-02T00:09:32.837643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h3> sep[arating event_attributes elements from it's [] and single quots</h3>","metadata":{}},{"cell_type":"code","source":"data.event_attributes = data.event_attributes.fillna(\"['pass', 'openplay']\")","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.840302Z","iopub.execute_input":"2022-08-02T00:09:32.841020Z","iopub.status.idle":"2022-08-02T00:09:32.848946Z","shell.execute_reply.started":"2022-08-02T00:09:32.840974Z","shell.execute_reply":"2022-08-02T00:09:32.848003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event_attributes = data.event_attributes.str.split(\"[\").str.get(1)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.850594Z","iopub.execute_input":"2022-08-02T00:09:32.851283Z","iopub.status.idle":"2022-08-02T00:09:32.881666Z","shell.execute_reply.started":"2022-08-02T00:09:32.851241Z","shell.execute_reply":"2022-08-02T00:09:32.880690Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head(1)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.883193Z","iopub.execute_input":"2022-08-02T00:09:32.883641Z","iopub.status.idle":"2022-08-02T00:09:32.895044Z","shell.execute_reply.started":"2022-08-02T00:09:32.883600Z","shell.execute_reply":"2022-08-02T00:09:32.894068Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event_attributes = data.event_attributes.str.split(\"]\").str.get(0)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.896332Z","iopub.execute_input":"2022-08-02T00:09:32.896865Z","iopub.status.idle":"2022-08-02T00:09:32.927086Z","shell.execute_reply.started":"2022-08-02T00:09:32.896834Z","shell.execute_reply":"2022-08-02T00:09:32.925915Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head(1)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.928498Z","iopub.execute_input":"2022-08-02T00:09:32.929333Z","iopub.status.idle":"2022-08-02T00:09:32.946414Z","shell.execute_reply.started":"2022-08-02T00:09:32.929301Z","shell.execute_reply":"2022-08-02T00:09:32.945636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event_attributes = data.event_attributes.replace(\"'pass', 'openplay'\",\"pass, openplay\")","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.947754Z","iopub.execute_input":"2022-08-02T00:09:32.948221Z","iopub.status.idle":"2022-08-02T00:09:32.954982Z","shell.execute_reply.started":"2022-08-02T00:09:32.948193Z","shell.execute_reply":"2022-08-02T00:09:32.953940Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head(1) ","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.956190Z","iopub.execute_input":"2022-08-02T00:09:32.957082Z","iopub.status.idle":"2022-08-02T00:09:32.971200Z","shell.execute_reply.started":"2022-08-02T00:09:32.957039Z","shell.execute_reply":"2022-08-02T00:09:32.970372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event_attributes = data.event_attributes.replace(\"pass, openplay\", \"pass in openplay\")","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.972488Z","iopub.execute_input":"2022-08-02T00:09:32.973620Z","iopub.status.idle":"2022-08-02T00:09:32.981387Z","shell.execute_reply.started":"2022-08-02T00:09:32.973574Z","shell.execute_reply":"2022-08-02T00:09:32.980609Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head(1) ","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.985127Z","iopub.execute_input":"2022-08-02T00:09:32.985506Z","iopub.status.idle":"2022-08-02T00:09:32.996963Z","shell.execute_reply.started":"2022-08-02T00:09:32.985475Z","shell.execute_reply":"2022-08-02T00:09:32.995818Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event_attributes","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:32.998219Z","iopub.execute_input":"2022-08-02T00:09:32.998826Z","iopub.status.idle":"2022-08-02T00:09:33.012280Z","shell.execute_reply.started":"2022-08-02T00:09:32.998793Z","shell.execute_reply":"2022-08-02T00:09:33.011101Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.duplicated()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:33.014038Z","iopub.execute_input":"2022-08-02T00:09:33.014496Z","iopub.status.idle":"2022-08-02T00:09:33.031667Z","shell.execute_reply.started":"2022-08-02T00:09:33.014454Z","shell.execute_reply":"2022-08-02T00:09:33.030581Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:33.041515Z","iopub.execute_input":"2022-08-02T00:09:33.042076Z","iopub.status.idle":"2022-08-02T00:09:33.049760Z","shell.execute_reply.started":"2022-08-02T00:09:33.042044Z","shell.execute_reply":"2022-08-02T00:09:33.048471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h3> the <u style = 'color : blueviolet'>event</u> data </h3>","metadata":{}},{"cell_type":"code","source":"data.event.unique()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:33.051401Z","iopub.execute_input":"2022-08-02T00:09:33.052283Z","iopub.status.idle":"2022-08-02T00:09:33.062287Z","shell.execute_reply.started":"2022-08-02T00:09:33.052238Z","shell.execute_reply":"2022-08-02T00:09:33.061402Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [12,8])\nsb.countplot(x='event', data=data, palette=\"husl\");","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:33.063642Z","iopub.execute_input":"2022-08-02T00:09:33.064013Z","iopub.status.idle":"2022-08-02T00:09:33.303435Z","shell.execute_reply.started":"2022-08-02T00:09:33.063984Z","shell.execute_reply":"2022-08-02T00:09:33.302265Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:33.304952Z","iopub.execute_input":"2022-08-02T00:09:33.306003Z","iopub.status.idle":"2022-08-02T00:09:33.314451Z","shell.execute_reply.started":"2022-08-02T00:09:33.305969Z","shell.execute_reply":"2022-08-02T00:09:33.313689Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h3> We Notice that the word <span style = 'color : red'> play</span> is the most frequent </h3>","metadata":{}},{"cell_type":"code","source":"# data.time = pd.to_datetime(data.time)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:33.315908Z","iopub.execute_input":"2022-08-02T00:09:33.316636Z","iopub.status.idle":"2022-08-02T00:09:33.324121Z","shell.execute_reply.started":"2022-08-02T00:09:33.316605Z","shell.execute_reply":"2022-08-02T00:09:33.323238Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(data.time);","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:33.325116Z","iopub.execute_input":"2022-08-02T00:09:33.325680Z","iopub.status.idle":"2022-08-02T00:09:33.509950Z","shell.execute_reply.started":"2022-08-02T00:09:33.325649Z","shell.execute_reply":"2022-08-02T00:09:33.509003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"let's see the each event over the time","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize = [8,9])\nsb.barplot(x=\"time\", y=\"event\", data=data);","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:33.511081Z","iopub.execute_input":"2022-08-02T00:09:33.511362Z","iopub.status.idle":"2022-08-02T00:09:33.977063Z","shell.execute_reply.started":"2022-08-02T00:09:33.511335Z","shell.execute_reply":"2022-08-02T00:09:33.975957Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"the challenge posses more time","metadata":{}},{"cell_type":"markdown","source":"<h3> ok let's first focus on the event <a style = 'color = green;'>play</a> and it's types with train videos   </h3>","metadata":{}},{"cell_type":"code","source":"data.event_attributes[data['event'] == 'play'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:33.978295Z","iopub.execute_input":"2022-08-02T00:09:33.978598Z","iopub.status.idle":"2022-08-02T00:09:33.990786Z","shell.execute_reply.started":"2022-08-02T00:09:33.978570Z","shell.execute_reply":"2022-08-02T00:09:33.989755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [12,8])\nsb.countplot(x='event_attributes', data=data, palette=\"dark\")\nplt.xticks(rotation = 45) \nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:33.992785Z","iopub.execute_input":"2022-08-02T00:09:33.993178Z","iopub.status.idle":"2022-08-02T00:09:34.278997Z","shell.execute_reply.started":"2022-08-02T00:09:33.993147Z","shell.execute_reply":"2022-08-02T00:09:34.277850Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [10,10])\ndata['event_attributes'].value_counts().plot(kind='barh')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.280212Z","iopub.execute_input":"2022-08-02T00:09:34.280494Z","iopub.status.idle":"2022-08-02T00:09:34.548629Z","shell.execute_reply.started":"2022-08-02T00:09:34.280467Z","shell.execute_reply":"2022-08-02T00:09:34.547541Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"pass from open play this what we will focus according to the video id","metadata":{}},{"cell_type":"code","source":"df_throwin = data[data[\"event\"] == \"throwin\"].reset_index()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.550298Z","iopub.execute_input":"2022-08-02T00:09:34.551142Z","iopub.status.idle":"2022-08-02T00:09:34.561310Z","shell.execute_reply.started":"2022-08-02T00:09:34.551091Z","shell.execute_reply":"2022-08-02T00:09:34.560205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_throwin.iloc[0]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.562840Z","iopub.execute_input":"2022-08-02T00:09:34.563702Z","iopub.status.idle":"2022-08-02T00:09:34.575653Z","shell.execute_reply.started":"2022-08-02T00:09:34.563660Z","shell.execute_reply":"2022-08-02T00:09:34.574898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event_attributes","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.576774Z","iopub.execute_input":"2022-08-02T00:09:34.577245Z","iopub.status.idle":"2022-08-02T00:09:34.588607Z","shell.execute_reply.started":"2022-08-02T00:09:34.577216Z","shell.execute_reply":"2022-08-02T00:09:34.587866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.video_id[data['event_attributes'] == \"pass in openplay\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.589603Z","iopub.execute_input":"2022-08-02T00:09:34.590329Z","iopub.status.idle":"2022-08-02T00:09:34.606980Z","shell.execute_reply.started":"2022-08-02T00:09:34.590283Z","shell.execute_reply":"2022-08-02T00:09:34.605889Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":" they are located into 12 video ","metadata":{}},{"cell_type":"markdown","source":"let's check the number of shortcuts from each video","metadata":{}},{"cell_type":"code","source":"data.event[(data['event_attributes'] == \"pass in openplay\") & (data['video_id'] == '1606b0e6_1')].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.608644Z","iopub.execute_input":"2022-08-02T00:09:34.608972Z","iopub.status.idle":"2022-08-02T00:09:34.623200Z","shell.execute_reply.started":"2022-08-02T00:09:34.608939Z","shell.execute_reply":"2022-08-02T00:09:34.622102Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pass_openplay1 = data.time[(data['event_attributes'] == \"pass in openplay\") & (data['video_id'] == '1606b0e6_1') & (data.event == 'play')]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.624815Z","iopub.execute_input":"2022-08-02T00:09:34.625495Z","iopub.status.idle":"2022-08-02T00:09:34.638282Z","shell.execute_reply.started":"2022-08-02T00:09:34.625451Z","shell.execute_reply":"2022-08-02T00:09:34.637241Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pass_openplay1","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.639349Z","iopub.execute_input":"2022-08-02T00:09:34.639703Z","iopub.status.idle":"2022-08-02T00:09:34.651486Z","shell.execute_reply.started":"2022-08-02T00:09:34.639673Z","shell.execute_reply":"2022-08-02T00:09:34.650779Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [10,6])\nplt.plot((pass_openplay1.values).round(2), '--g');","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.652516Z","iopub.execute_input":"2022-08-02T00:09:34.653339Z","iopub.status.idle":"2022-08-02T00:09:34.846295Z","shell.execute_reply.started":"2022-08-02T00:09:34.653305Z","shell.execute_reply":"2022-08-02T00:09:34.845061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(pass_openplay1.values).round(2)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.847900Z","iopub.execute_input":"2022-08-02T00:09:34.848427Z","iopub.status.idle":"2022-08-02T00:09:34.862488Z","shell.execute_reply.started":"2022-08-02T00:09:34.848397Z","shell.execute_reply":"2022-08-02T00:09:34.860956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass1 = (pass_openplay1.values).round(2)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.863945Z","iopub.execute_input":"2022-08-02T00:09:34.865424Z","iopub.status.idle":"2022-08-02T00:09:34.871351Z","shell.execute_reply.started":"2022-08-02T00:09:34.865382Z","shell.execute_reply":"2022-08-02T00:09:34.870193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass1 = pd.DataFrame(chinging_over_pass1)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.872590Z","iopub.execute_input":"2022-08-02T00:09:34.873084Z","iopub.status.idle":"2022-08-02T00:09:34.883441Z","shell.execute_reply.started":"2022-08-02T00:09:34.873054Z","shell.execute_reply":"2022-08-02T00:09:34.882628Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass1 = chinging_over_pass1.pct_change(fill_method ='ffill')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.884745Z","iopub.execute_input":"2022-08-02T00:09:34.885236Z","iopub.status.idle":"2022-08-02T00:09:34.897133Z","shell.execute_reply.started":"2022-08-02T00:09:34.885201Z","shell.execute_reply":"2022-08-02T00:09:34.896264Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass1","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.898828Z","iopub.execute_input":"2022-08-02T00:09:34.899254Z","iopub.status.idle":"2022-08-02T00:09:34.917670Z","shell.execute_reply.started":"2022-08-02T00:09:34.899212Z","shell.execute_reply":"2022-08-02T00:09:34.916708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass1.describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.919021Z","iopub.execute_input":"2022-08-02T00:09:34.919590Z","iopub.status.idle":"2022-08-02T00:09:34.933053Z","shell.execute_reply.started":"2022-08-02T00:09:34.919536Z","shell.execute_reply":"2022-08-02T00:09:34.932294Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = chinging_over_pass1\nplt.figure(figsize = [15,7])\nfig, ax = plt.subplots()\n# Annotation\nfig.set_size_inches(15, 7)\nax.annotate('global Maximum (0.087799)', xy =(53.5,0.087 ),\n                xytext =(105, .08), \n                arrowprops = dict(facecolor ='gold'),)\nplt.plot(y);\nplt.title('the changing rate of the time (pass on the Open-play)')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:34.934174Z","iopub.execute_input":"2022-08-02T00:09:34.934645Z","iopub.status.idle":"2022-08-02T00:09:35.210569Z","shell.execute_reply.started":"2022-08-02T00:09:34.934614Z","shell.execute_reply":"2022-08-02T00:09:35.209316Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.mean()[0],y.median()[0]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:35.211922Z","iopub.execute_input":"2022-08-02T00:09:35.212431Z","iopub.status.idle":"2022-08-02T00:09:35.225691Z","shell.execute_reply.started":"2022-08-02T00:09:35.212390Z","shell.execute_reply":"2022-08-02T00:09:35.224625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style = 'color : blueviolet '> we see the average of changing very small and that's mean that 99 % of 43 minute of the selected video the players from two teams play pass on open-play ⚽⚽</p>","metadata":{}},{"cell_type":"markdown","source":"<h2>watch how Alphonso davis and lewandawski pass at the openplay 😂 </h2>","metadata":{}},{"cell_type":"code","source":"data.event.unique()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:35.227045Z","iopub.execute_input":"2022-08-02T00:09:35.227751Z","iopub.status.idle":"2022-08-02T00:09:35.244017Z","shell.execute_reply.started":"2022-08-02T00:09:35.227709Z","shell.execute_reply":"2022-08-02T00:09:35.242673Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:35.245531Z","iopub.execute_input":"2022-08-02T00:09:35.246587Z","iopub.status.idle":"2022-08-02T00:09:35.260667Z","shell.execute_reply.started":"2022-08-02T00:09:35.246526Z","shell.execute_reply":"2022-08-02T00:09:35.258999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head(1)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:35.262603Z","iopub.execute_input":"2022-08-02T00:09:35.263736Z","iopub.status.idle":"2022-08-02T00:09:35.277899Z","shell.execute_reply.started":"2022-08-02T00:09:35.263693Z","shell.execute_reply":"2022-08-02T00:09:35.276140Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in (data.event.unique()):\n    print('*' * 10 , ' ', i, ' ', '*' * 10)\n    print(' ')\n    print(data.event_attributes[data.event == i].value_counts())\n    print(' ')\n\n","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:35.279105Z","iopub.execute_input":"2022-08-02T00:09:35.280831Z","iopub.status.idle":"2022-08-02T00:09:35.315662Z","shell.execute_reply.started":"2022-08-02T00:09:35.280787Z","shell.execute_reply":"2022-08-02T00:09:35.314621Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [10,10])\ndata['event'].value_counts().plot(kind='barh')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:35.318685Z","iopub.execute_input":"2022-08-02T00:09:35.319109Z","iopub.status.idle":"2022-08-02T00:09:35.526523Z","shell.execute_reply.started":"2022-08-02T00:09:35.319066Z","shell.execute_reply":"2022-08-02T00:09:35.523644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = data.query(' event != \"start\" & event != \"end\"')\nx = pd.DataFrame(x)\nx","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:35.527956Z","iopub.execute_input":"2022-08-02T00:09:35.528306Z","iopub.status.idle":"2022-08-02T00:09:35.554814Z","shell.execute_reply.started":"2022-08-02T00:09:35.528270Z","shell.execute_reply":"2022-08-02T00:09:35.554005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize = (10, 5))\n\n# creating the bar plot\nplt.bar(data.event, data.event_attributes, color ='maroon',\n        width = 0.4)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:35.556172Z","iopub.execute_input":"2022-08-02T00:09:35.556621Z","iopub.status.idle":"2022-08-02T00:09:55.888221Z","shell.execute_reply.started":"2022-08-02T00:09:35.556589Z","shell.execute_reply":"2022-08-02T00:09:55.887108Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event[(data.event == 'challenge') & (data.event == 'throwin') & (data.event == 'play')]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:55.889916Z","iopub.execute_input":"2022-08-02T00:09:55.890596Z","iopub.status.idle":"2022-08-02T00:09:55.906032Z","shell.execute_reply.started":"2022-08-02T00:09:55.890536Z","shell.execute_reply":"2022-08-02T00:09:55.904891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event[data.event == 'start']","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:55.907103Z","iopub.execute_input":"2022-08-02T00:09:55.907971Z","iopub.status.idle":"2022-08-02T00:09:55.919744Z","shell.execute_reply.started":"2022-08-02T00:09:55.907926Z","shell.execute_reply":"2022-08-02T00:09:55.918770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event_attributes.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:55.921140Z","iopub.execute_input":"2022-08-02T00:09:55.921528Z","iopub.status.idle":"2022-08-02T00:09:55.935858Z","shell.execute_reply.started":"2022-08-02T00:09:55.921500Z","shell.execute_reply":"2022-08-02T00:09:55.934908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[data['event_attributes'] == \"pass in openplay\"]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:55.937744Z","iopub.execute_input":"2022-08-02T00:09:55.938394Z","iopub.status.idle":"2022-08-02T00:09:55.960374Z","shell.execute_reply.started":"2022-08-02T00:09:55.938352Z","shell.execute_reply":"2022-08-02T00:09:55.958479Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[data.event_attributes.duplicated()]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:55.961941Z","iopub.execute_input":"2022-08-02T00:09:55.962451Z","iopub.status.idle":"2022-08-02T00:09:55.982244Z","shell.execute_reply.started":"2022-08-02T00:09:55.962408Z","shell.execute_reply":"2022-08-02T00:09:55.981044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h3> what I observed here</h3>\n<ol>\n    <li> each event can have multiple event attributes</li>\n    <li> each event_attribute can have only one event type at the same time</li>\n    <li> <span style = 'color : green'>start</span>  and <span style = 'color : green'>end</span> has the even_attributes ['pass', 'openplay'] <br> \n    but <span style = 'color : blueviolet;'>challenge</span> , <span style = 'color : blueviolet'>play</span> and <span style = 'color : blueviolet'>throwin</span> has multiple event attributes\n    </li>\n\n</ol>","metadata":{}},{"cell_type":"markdown","source":"let's begin with start","metadata":{}},{"cell_type":"code","source":"data.head(1)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:55.983541Z","iopub.execute_input":"2022-08-02T00:09:55.983858Z","iopub.status.idle":"2022-08-02T00:09:55.995238Z","shell.execute_reply.started":"2022-08-02T00:09:55.983831Z","shell.execute_reply":"2022-08-02T00:09:55.994401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.event[data.event == 'start'].count()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:55.996668Z","iopub.execute_input":"2022-08-02T00:09:55.997319Z","iopub.status.idle":"2022-08-02T00:09:56.011299Z","shell.execute_reply.started":"2022-08-02T00:09:55.997272Z","shell.execute_reply":"2022-08-02T00:09:56.010094Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"the start event 3418 = the event attributes pass-openplay 3418 \nbecause start event has only pass-openplay","metadata":{}},{"cell_type":"code","source":"data.video_id[data.event == 'start'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.012871Z","iopub.execute_input":"2022-08-02T00:09:56.013169Z","iopub.status.idle":"2022-08-02T00:09:56.024264Z","shell.execute_reply.started":"2022-08-02T00:09:56.013142Z","shell.execute_reply":"2022-08-02T00:09:56.023208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"until now I don't know if start and openplay that's mean pass at open play at the start of  the match ","metadata":{}},{"cell_type":"code","source":"data.time[(data.event == 'start') & (data.video_id == '1606b0e6_1')].values","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.025611Z","iopub.execute_input":"2022-08-02T00:09:56.025941Z","iopub.status.idle":"2022-08-02T00:09:56.048391Z","shell.execute_reply.started":"2022-08-02T00:09:56.025911Z","shell.execute_reply":"2022-08-02T00:09:56.047340Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pass_openplay2 = data.time[(data.event == 'start') & (data.video_id == '1606b0e6_1')]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.049822Z","iopub.execute_input":"2022-08-02T00:09:56.050236Z","iopub.status.idle":"2022-08-02T00:09:56.061230Z","shell.execute_reply.started":"2022-08-02T00:09:56.050196Z","shell.execute_reply":"2022-08-02T00:09:56.060117Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [10,6])\nplt.plot((pass_openplay2.values).round(2), '--g');\nplt.title('the time range of event start and video (1606b0e6_1)')\nplt.xlabel('the range')\nplt.ylabel('time')\nplt.show()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-08-02T00:09:56.062724Z","iopub.execute_input":"2022-08-02T00:09:56.063696Z","iopub.status.idle":"2022-08-02T00:09:56.220161Z","shell.execute_reply.started":"2022-08-02T00:09:56.063655Z","shell.execute_reply":"2022-08-02T00:09:56.218873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass2 = (pass_openplay2.values).round(2)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.223687Z","iopub.execute_input":"2022-08-02T00:09:56.224010Z","iopub.status.idle":"2022-08-02T00:09:56.229425Z","shell.execute_reply.started":"2022-08-02T00:09:56.223982Z","shell.execute_reply":"2022-08-02T00:09:56.228380Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass2 = pd.DataFrame(chinging_over_pass2)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.231167Z","iopub.execute_input":"2022-08-02T00:09:56.231935Z","iopub.status.idle":"2022-08-02T00:09:56.240334Z","shell.execute_reply.started":"2022-08-02T00:09:56.231891Z","shell.execute_reply":"2022-08-02T00:09:56.239613Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass2 = chinging_over_pass2.pct_change(fill_method ='ffill')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.241601Z","iopub.execute_input":"2022-08-02T00:09:56.242104Z","iopub.status.idle":"2022-08-02T00:09:56.251170Z","shell.execute_reply.started":"2022-08-02T00:09:56.242074Z","shell.execute_reply":"2022-08-02T00:09:56.250390Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass2","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.252738Z","iopub.execute_input":"2022-08-02T00:09:56.253375Z","iopub.status.idle":"2022-08-02T00:09:56.267680Z","shell.execute_reply.started":"2022-08-02T00:09:56.253333Z","shell.execute_reply":"2022-08-02T00:09:56.266724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass2.describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.269174Z","iopub.execute_input":"2022-08-02T00:09:56.269718Z","iopub.status.idle":"2022-08-02T00:09:56.284192Z","shell.execute_reply.started":"2022-08-02T00:09:56.269687Z","shell.execute_reply":"2022-08-02T00:09:56.282933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = chinging_over_pass2\nplt.figure(figsize = [15,7])\nfig, ax = plt.subplots()\n# Annotation\nfig.set_size_inches(15, 7)\nax.annotate('global Maximum (0.090936)', xy =(53.5,0.089\n                                             ),\n                xytext =(105, .07), \n                arrowprops = dict(facecolor ='gold'),)\nplt.plot(y);\nplt.title('the changing rate of the time (pass on the Open-play)');\nplt.show();","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.285791Z","iopub.execute_input":"2022-08-02T00:09:56.286601Z","iopub.status.idle":"2022-08-02T00:09:56.494648Z","shell.execute_reply.started":"2022-08-02T00:09:56.286542Z","shell.execute_reply":"2022-08-02T00:09:56.493525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pass_openplay2.values[-1]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.495868Z","iopub.execute_input":"2022-08-02T00:09:56.496189Z","iopub.status.idle":"2022-08-02T00:09:56.503631Z","shell.execute_reply.started":"2022-08-02T00:09:56.496160Z","shell.execute_reply":"2022-08-02T00:09:56.502374Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### let's get the full video \nthe full video is about all times in event start and attribute open in play for first id in the training","metadata":{}},{"cell_type":"code","source":"name = \"video1.mp4\"\nffmpeg_extract_subclip(\nf\"/kaggle/input/dfl-bundesliga-data-shootout/train/1606b0e6_1.mp4\", \npass_openplay2.values[0], \npass_openplay2.values[-1], \ntargetname=name,\n)\nVideo(name, width=765)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:09:56.505219Z","iopub.execute_input":"2022-08-02T00:09:56.506273Z","iopub.status.idle":"2022-08-02T00:10:31.381173Z","shell.execute_reply.started":"2022-08-02T00:09:56.506219Z","shell.execute_reply":"2022-08-02T00:10:31.379566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### let's take shortcut where we will work","metadata":{}},{"cell_type":"code","source":"x = list(pass_openplay2)\nname = \"video1-shortcut.mp4\"\nffmpeg_extract_subclip(\nf\"/kaggle/input/dfl-bundesliga-data-shootout/train/1606b0e6_1.mp4\", \nx[-1] - 5, \nx[-1] + 5, \ntargetname=name,\n)\nVideo(name, width=765)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:10:31.383744Z","iopub.execute_input":"2022-08-02T00:10:31.385119Z","iopub.status.idle":"2022-08-02T00:10:31.551260Z","shell.execute_reply.started":"2022-08-02T00:10:31.385077Z","shell.execute_reply":"2022-08-02T00:10:31.549886Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"let's begin with video 2","metadata":{}},{"cell_type":"code","source":"pass_openplay3 = data.time[(data.event == 'start') & (data.video_id == '35bd9041_0')]\n\nplt.figure(figsize = [10,6])\nplt.plot((pass_openplay2.values).round(2), '--g');\nplt.title('the time range of event start and video (35bd9041_0)')\nplt.xlabel('the range')\nplt.ylabel('time')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:10:31.553390Z","iopub.execute_input":"2022-08-02T00:10:31.554140Z","iopub.status.idle":"2022-08-02T00:10:31.791637Z","shell.execute_reply.started":"2022-08-02T00:10:31.554089Z","shell.execute_reply":"2022-08-02T00:10:31.790322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass3 = (pass_openplay3.values).round(2)\n\nchinging_over_pass3 = pd.DataFrame(chinging_over_pass3)\n\nchinging_over_pass3 = chinging_over_pass3.pct_change(fill_method ='ffill')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:10:31.809246Z","iopub.execute_input":"2022-08-02T00:10:31.809659Z","iopub.status.idle":"2022-08-02T00:10:31.819375Z","shell.execute_reply.started":"2022-08-02T00:10:31.809626Z","shell.execute_reply":"2022-08-02T00:10:31.818167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chinging_over_pass3.describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:10:31.821269Z","iopub.execute_input":"2022-08-02T00:10:31.821600Z","iopub.status.idle":"2022-08-02T00:10:31.843046Z","shell.execute_reply.started":"2022-08-02T00:10:31.821572Z","shell.execute_reply":"2022-08-02T00:10:31.841905Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = chinging_over_pass3\nplt.figure(figsize = [15,7])\nfig, ax = plt.subplots()\n# Annotation\nfig.set_size_inches(15, 7)\nax.annotate('global Maximum (0.217457)', xy =(53.5,0.21),\n                xytext =(105, .17), \n                arrowprops = dict(facecolor ='gold'),)\nplt.plot(y);\nplt.title('the changing rate of the time (pass on the Open-play)');\nplt.show();","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:10:31.844606Z","iopub.execute_input":"2022-08-02T00:10:31.845302Z","iopub.status.idle":"2022-08-02T00:10:32.094119Z","shell.execute_reply.started":"2022-08-02T00:10:31.845259Z","shell.execute_reply":"2022-08-02T00:10:32.092969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(chinging_over_pass3.max() - chinging_over_pass2.max()).round(2)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:10:32.095759Z","iopub.execute_input":"2022-08-02T00:10:32.096194Z","iopub.status.idle":"2022-08-02T00:10:32.108398Z","shell.execute_reply.started":"2022-08-02T00:10:32.096151Z","shell.execute_reply":"2022-08-02T00:10:32.107303Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### the full video of start event and pass in open-play","metadata":{}},{"cell_type":"code","source":"name = \"video2.mp4\"\nffmpeg_extract_subclip(\nf\"/kaggle/input/dfl-bundesliga-data-shootout/train/35bd9041_0.mp4\", \npass_openplay3.values[0], \npass_openplay3.values[-1], \ntargetname=name,\n)\nVideo(name, width=765)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:10:32.110033Z","iopub.execute_input":"2022-08-02T00:10:32.110330Z","iopub.status.idle":"2022-08-02T00:11:05.419370Z","shell.execute_reply.started":"2022-08-02T00:10:32.110298Z","shell.execute_reply":"2022-08-02T00:11:05.418205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### let's take shortcut","metadata":{}},{"cell_type":"code","source":"x = list(pass_openplay3)\nname = \"video1-shortcut.mp4\"\nffmpeg_extract_subclip(\nf\"/kaggle/input/dfl-bundesliga-data-shootout/train/35bd9041_0.mp4\", \nx[1], \nx[1] + 20, \ntargetname=name,\n)\nVideo(name, width=765)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:05.421010Z","iopub.execute_input":"2022-08-02T00:11:05.421359Z","iopub.status.idle":"2022-08-02T00:11:05.522975Z","shell.execute_reply.started":"2022-08-02T00:11:05.421324Z","shell.execute_reply":"2022-08-02T00:11:05.521984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(chinging_over_pass3.max() - chinging_over_pass2.max()).round(2)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:05.525265Z","iopub.execute_input":"2022-08-02T00:11:05.525643Z","iopub.status.idle":"2022-08-02T00:11:06.239970Z","shell.execute_reply.started":"2022-08-02T00:11:05.525606Z","shell.execute_reply":"2022-08-02T00:11:06.239103Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p> the change in the rate<span style = 'color : red'> very small nearly it was 0.13 </span>hence I am not going to calculate the changing rate for the rest of times in  pass-onplay for event start for the rest of videos however in the first video the change in the rate of pass was smaller than the second match this means the players in the first video doing less mess pass and that's good let's see the other information </p>","metadata":{}},{"cell_type":"code","source":"unique_video = list(data.video_id[data.event == 'start'].unique())\nunique_video","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.241392Z","iopub.execute_input":"2022-08-02T00:11:06.242000Z","iopub.status.idle":"2022-08-02T00:11:06.272212Z","shell.execute_reply.started":"2022-08-02T00:11:06.241970Z","shell.execute_reply":"2022-08-02T00:11:06.271128Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<span style = 'color : red'> Note </span> **we here try to get the rest of the videos into a list rather than take each video only and thats will be fast**","metadata":{}},{"cell_type":"code","source":"unique_video = list(data.video_id[data.event == 'start'].unique())\nunique_video[:] = (value for value in unique_video if (value != \"1606b0e6_1\") and (value != \"35bd9041_0\"))\ntime_list = []\nfor i in range(len(unique_video)):\n    venom = data.time[(data.event == 'start') & (data.video_id == unique_video[i])]\n    time_list.append((venom))\n        ","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.273661Z","iopub.execute_input":"2022-08-02T00:11:06.274216Z","iopub.status.idle":"2022-08-02T00:11:06.510218Z","shell.execute_reply.started":"2022-08-02T00:11:06.274185Z","shell.execute_reply":"2022-08-02T00:11:06.508772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [10,6])\nplt.plot((time_list[0].values).round(2), '--g');\nplt.title(f'the time range of event start and video (unique_video[0])')\nplt.xlabel('the range')\nplt.ylabel('time')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.511932Z","iopub.execute_input":"2022-08-02T00:11:06.512633Z","iopub.status.idle":"2022-08-02T00:11:06.719649Z","shell.execute_reply.started":"2022-08-02T00:11:06.512587Z","shell.execute_reply":"2022-08-02T00:11:06.718477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"max_change = []\ncounter = 0\nfor i in time_list:\n    x = pd.DataFrame(i)\n    x = x.pct_change(fill_method ='ffill')\n    max_change.append(x.max())\n    ","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.720877Z","iopub.execute_input":"2022-08-02T00:11:06.721168Z","iopub.status.idle":"2022-08-02T00:11:06.743162Z","shell.execute_reply.started":"2022-08-02T00:11:06.721142Z","shell.execute_reply":"2022-08-02T00:11:06.742234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = []\nfor i in range(len(max_change)):\n    y.append(max_change[i][0])\ny","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.744872Z","iopub.execute_input":"2022-08-02T00:11:06.745820Z","iopub.status.idle":"2022-08-02T00:11:06.757774Z","shell.execute_reply.started":"2022-08-02T00:11:06.745783Z","shell.execute_reply":"2022-08-02T00:11:06.756712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"min(y), ","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.759452Z","iopub.execute_input":"2022-08-02T00:11:06.760415Z","iopub.status.idle":"2022-08-02T00:11:06.768094Z","shell.execute_reply.started":"2022-08-02T00:11:06.760368Z","shell.execute_reply":"2022-08-02T00:11:06.767395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"index = y.index(min(y))\nprint('The index of minimum max value:', index)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.769034Z","iopub.execute_input":"2022-08-02T00:11:06.769474Z","iopub.status.idle":"2022-08-02T00:11:06.779873Z","shell.execute_reply.started":"2022-08-02T00:11:06.769442Z","shell.execute_reply":"2022-08-02T00:11:06.778937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(f'the least maximum of the video 1606b0e6_1 is :{chinging_over_pass2.max()[0]} however in the video {unique_video[y.index(min(y))]} we find out that it has the least maximum of the changing rate')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.781248Z","iopub.execute_input":"2022-08-02T00:11:06.781843Z","iopub.status.idle":"2022-08-02T00:11:06.791961Z","shell.execute_reply.started":"2022-08-02T00:11:06.781812Z","shell.execute_reply":"2022-08-02T00:11:06.790854Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h3> note </h3>\n<p> before continue why I have choose the <span style = 'color : red'> least maximum changing rate </span> rather than <span style = 'color : red'>least minimum changing rate</span>least minimum changing rate ? </p>\n<br>\n<cite> that's because some videos that may have minimum changing rate which in the match there's no pass at open play at fraction of seconds but if it very small we can accept the all minimum rate but in maximum changing rate here is the problem because the match turned to air plays or have a lot of fauls and less pass at open play thus I focus on the matches taht has the least maximum</cite>","metadata":{}},{"cell_type":"markdown","source":"### let's see the <span style = 'color : red'>best match</span> in the pass at openplay until now","metadata":{}},{"cell_type":"code","source":"best_pass_openplay = data.time[(data.event == 'start') & (data.video_id == '3c993bd2_0')]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.793594Z","iopub.execute_input":"2022-08-02T00:11:06.794082Z","iopub.status.idle":"2022-08-02T00:11:06.804408Z","shell.execute_reply.started":"2022-08-02T00:11:06.794053Z","shell.execute_reply":"2022-08-02T00:11:06.803604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [9,6])\nplt.plot((pass_openplay2.values).round(2), 'b');\nplt.title('the time range of event start and video (3c993bd2_0)')\nplt.xlabel('the range')\nplt.ylabel('time')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.805571Z","iopub.execute_input":"2022-08-02T00:11:06.806063Z","iopub.status.idle":"2022-08-02T00:11:06.968102Z","shell.execute_reply.started":"2022-08-02T00:11:06.806034Z","shell.execute_reply":"2022-08-02T00:11:06.967202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"best_chinging_over_pass = (best_pass_openplay.values).round(2)\n\nbest_chinging_over_pass = pd.DataFrame(best_chinging_over_pass)\n\nbest_chinging_over_pass = best_chinging_over_pass.pct_change(fill_method ='ffill')\n\nbest_chinging_over_pass","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.969342Z","iopub.execute_input":"2022-08-02T00:11:06.969860Z","iopub.status.idle":"2022-08-02T00:11:06.982797Z","shell.execute_reply.started":"2022-08-02T00:11:06.969821Z","shell.execute_reply":"2022-08-02T00:11:06.981786Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"now let's see the changing rate graph","metadata":{}},{"cell_type":"code","source":"y = best_chinging_over_pass\nplt.figure(figsize = [15,7])\nfig, ax = plt.subplots()\n# Annotation\nfig.set_size_inches(15, 7)\nax.annotate('global Maximum (0.090936)', xy =(53.5,0.086\n                                             ),\n                xytext =(105, .07), \n                arrowprops = dict(facecolor ='black'),)\nplt.plot(y);\nplt.title('the changing rate of the time (pass on the Open-play)');\nplt.show();","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:06.985700Z","iopub.execute_input":"2022-08-02T00:11:06.986574Z","iopub.status.idle":"2022-08-02T00:11:07.192431Z","shell.execute_reply.started":"2022-08-02T00:11:06.986523Z","shell.execute_reply":"2022-08-02T00:11:07.191351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### the full video ","metadata":{}},{"cell_type":"code","source":"x = list(pass_openplay3)\nname = \"best_pass_over_open-play1.mp4\"\nffmpeg_extract_subclip(\nf\"/kaggle/input/dfl-bundesliga-data-shootout/train/3c993bd2_0.mp4\", \nbest_pass_openplay.values[0], \nbest_pass_openplay.values[-1], \ntargetname=name,\n)\nVideo(name, width=765)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:07.194212Z","iopub.execute_input":"2022-08-02T00:11:07.195307Z","iopub.status.idle":"2022-08-02T00:11:40.052533Z","shell.execute_reply.started":"2022-08-02T00:11:07.195267Z","shell.execute_reply":"2022-08-02T00:11:40.051215Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### the clip of the video","metadata":{}},{"cell_type":"code","source":"x = list(best_pass_openplay)\nname = \"best_pass_over_open-play2.mp4\"\nffmpeg_extract_subclip(\nf\"/kaggle/input/dfl-bundesliga-data-shootout/train/3c993bd2_0.mp4\", \nx[1], \nx[1] + 17, \ntargetname=name,\n)\nVideo(name, width=765)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.054872Z","iopub.execute_input":"2022-08-02T00:11:40.055366Z","iopub.status.idle":"2022-08-02T00:11:40.147805Z","shell.execute_reply.started":"2022-08-02T00:11:40.055312Z","shell.execute_reply":"2022-08-02T00:11:40.146601Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"raw","source":"","metadata":{}},{"cell_type":"markdown","source":"Summary of  Start Event Analysis: \n1. the even start has only pass in playopen only\n2. the even start contains 3418 pass in openplay    \n3. it the start events exist on 12 video of training \n4. we notice in the video which has the least maximum changing rate that each player try to play from **First Touch** \n    that's mean each player at the game try to do correct pass to his friends at the same team  fast and without a lot of miss pass \n5. the lot of miss pass in the match may cause higher maximum changing rate so it will be important point to focus \n","metadata":{}},{"cell_type":"markdown","source":"# <div style=\"padding:20px;color:white;margin:0;font-size:100%;text-align:left;display:fill;border-radius:5px;background-color:#6A79BA;overflow:hidden; text-align : center\"> challenge Event </div>\n","metadata":{}},{"cell_type":"code","source":"data.head(1)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.149297Z","iopub.execute_input":"2022-08-02T00:11:40.149735Z","iopub.status.idle":"2022-08-02T00:11:40.165203Z","shell.execute_reply.started":"2022-08-02T00:11:40.149699Z","shell.execute_reply":"2022-08-02T00:11:40.163600Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[data.event == 'challenge'].shape","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.167273Z","iopub.execute_input":"2022-08-02T00:11:40.168172Z","iopub.status.idle":"2022-08-02T00:11:40.181929Z","shell.execute_reply.started":"2022-08-02T00:11:40.168123Z","shell.execute_reply":"2022-08-02T00:11:40.180306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"we have 624 row that's challenge event now let's see what is the event attributes","metadata":{}},{"cell_type":"code","source":"data.event_attributes[data.event == 'challenge'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.183575Z","iopub.execute_input":"2022-08-02T00:11:40.184214Z","iopub.status.idle":"2022-08-02T00:11:40.195394Z","shell.execute_reply.started":"2022-08-02T00:11:40.184183Z","shell.execute_reply":"2022-08-02T00:11:40.194579Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Until now I don't know what are some attributes of this but let's see some shortcut","metadata":{}},{"cell_type":"code","source":"data.video_id[data.event_attributes == \"'ball_action_forced'\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.197021Z","iopub.execute_input":"2022-08-02T00:11:40.197653Z","iopub.status.idle":"2022-08-02T00:11:40.208347Z","shell.execute_reply.started":"2022-08-02T00:11:40.197619Z","shell.execute_reply":"2022-08-02T00:11:40.207379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"great.. \nlet's see the time of most frequent video id and event_attributes = 'ball_action_forced'","metadata":{}},{"cell_type":"code","source":"ball_action_forced = data.time[(data.video_id == '3c993bd2_1') & (data.event_attributes == \"'ball_action_forced'\")].values","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.210352Z","iopub.execute_input":"2022-08-02T00:11:40.210790Z","iopub.status.idle":"2022-08-02T00:11:40.222311Z","shell.execute_reply.started":"2022-08-02T00:11:40.210747Z","shell.execute_reply":"2022-08-02T00:11:40.221387Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"name = \"ball_action_forced.mp4\"\nffmpeg_extract_subclip(\nf\"/kaggle/input/dfl-bundesliga-data-shootout/train/3c993bd2_1.mp4\", \nball_action_forced[1], \nball_action_forced[1] + 30, \ntargetname=name,\n)\nVideo(name, width=765)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.223670Z","iopub.execute_input":"2022-08-02T00:11:40.224308Z","iopub.status.idle":"2022-08-02T00:11:40.881493Z","shell.execute_reply.started":"2022-08-02T00:11:40.224265Z","shell.execute_reply":"2022-08-02T00:11:40.880231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"the ball_action_forced means deflect the ball to prevent a counterattack and so on..\nI will modify it","metadata":{}},{"cell_type":"code","source":"data.event_attributes = data.event_attributes.replace(\"'ball_action_forced'\", 'ball deflect')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.883704Z","iopub.execute_input":"2022-08-02T00:11:40.884941Z","iopub.status.idle":"2022-08-02T00:11:40.895992Z","shell.execute_reply.started":"2022-08-02T00:11:40.884878Z","shell.execute_reply":"2022-08-02T00:11:40.895062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ball_deflect1 = data.time[(data.video_id == '3c993bd2_1') & (data.event_attributes == \"ball deflect\")].values","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.897777Z","iopub.execute_input":"2022-08-02T00:11:40.898245Z","iopub.status.idle":"2022-08-02T00:11:40.941652Z","shell.execute_reply.started":"2022-08-02T00:11:40.898203Z","shell.execute_reply":"2022-08-02T00:11:40.940704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ball_deflect1","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.943445Z","iopub.execute_input":"2022-08-02T00:11:40.944328Z","iopub.status.idle":"2022-08-02T00:11:40.975970Z","shell.execute_reply.started":"2022-08-02T00:11:40.944282Z","shell.execute_reply":"2022-08-02T00:11:40.972421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [10,6])\nplt.plot((ball_deflect1).round(2), 'c');\nplt.title('the ball_deflect time range 3c993bd2_1')\nplt.xlabel('the range')\nplt.ylabel('time')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:40.980851Z","iopub.execute_input":"2022-08-02T00:11:40.983798Z","iopub.status.idle":"2022-08-02T00:11:41.242750Z","shell.execute_reply.started":"2022-08-02T00:11:40.983747Z","shell.execute_reply":"2022-08-02T00:11:41.241626Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### it's rely different from the start event attributes","metadata":{}},{"cell_type":"markdown","source":"now I will look at the changing rate for the first one in order and then to the all videos ","metadata":{}},{"cell_type":"code","source":"changing_ball_deflect1 = (ball_deflect1).round(2)\nchanging_ball_deflect1= pd.DataFrame(changing_ball_deflect1)\nchanging_ball_deflect1 = changing_ball_deflect1.pct_change(fill_method ='ffill')\nchanging_ball_deflect1.tail(7)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.244217Z","iopub.execute_input":"2022-08-02T00:11:41.245023Z","iopub.status.idle":"2022-08-02T00:11:41.258363Z","shell.execute_reply.started":"2022-08-02T00:11:41.244978Z","shell.execute_reply":"2022-08-02T00:11:41.257539Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [15,7])\nplt.plot(changing_ball_deflect1, 'r');\nplt.title('the changing rate of (3c993bd2_1)');\nplt.show();","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.259863Z","iopub.execute_input":"2022-08-02T00:11:41.261038Z","iopub.status.idle":"2022-08-02T00:11:41.458162Z","shell.execute_reply.started":"2022-08-02T00:11:41.260995Z","shell.execute_reply":"2022-08-02T00:11:41.457418Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'the maximum changing rate is : {changing_ball_deflect1.max()}')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.459368Z","iopub.execute_input":"2022-08-02T00:11:41.459896Z","iopub.status.idle":"2022-08-02T00:11:41.467259Z","shell.execute_reply.started":"2022-08-02T00:11:41.459863Z","shell.execute_reply":"2022-08-02T00:11:41.466134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### let's do this for the rest videos and visualize the video with least maximum changing rate","metadata":{}},{"cell_type":"code","source":"unique_video = list(data.video_id[(data.event == 'challenge') & (data.event_attributes == 'ball deflect')].unique())\nunique_video[:] = (value for value in unique_video if (value != \"3c993bd2_1\"))\ntime_list_ball_deflect = []\nfor i in range(len(unique_video)):\n    venom2 = data.time[(data.event_attributes == 'ball deflect') & (data.video_id == unique_video[i])]\n    time_list_ball_deflect.append((venom2))","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.468831Z","iopub.execute_input":"2022-08-02T00:11:41.469137Z","iopub.status.idle":"2022-08-02T00:11:41.525909Z","shell.execute_reply.started":"2022-08-02T00:11:41.469107Z","shell.execute_reply":"2022-08-02T00:11:41.524757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# max change\nmax_change = []\ncounter = 0\nfor i in time_list:\n    x = pd.DataFrame(i)\n    x = x.pct_change(fill_method ='bfill')\n    max_change.append(x.max())\ny = []\nfor i in range(len(max_change)):\n    y.append(max_change[i][0])\ny","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.527570Z","iopub.execute_input":"2022-08-02T00:11:41.527909Z","iopub.status.idle":"2022-08-02T00:11:41.559388Z","shell.execute_reply.started":"2022-08-02T00:11:41.527879Z","shell.execute_reply":"2022-08-02T00:11:41.558574Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"index = y.index(min(y))\nprint('The index of minimum max value:', index)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.560702Z","iopub.execute_input":"2022-08-02T00:11:41.561301Z","iopub.status.idle":"2022-08-02T00:11:41.567050Z","shell.execute_reply.started":"2022-08-02T00:11:41.561253Z","shell.execute_reply":"2022-08-02T00:11:41.565966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(f' the least of maximum changing rate will be in the video : {unique_video[y.index(min(y))]} with value = {min(y)}')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.568436Z","iopub.execute_input":"2022-08-02T00:11:41.568751Z","iopub.status.idle":"2022-08-02T00:11:41.578208Z","shell.execute_reply.started":"2022-08-02T00:11:41.568722Z","shell.execute_reply":"2022-08-02T00:11:41.577389Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### let's visualize the plot of time frequency and changing rate","metadata":{}},{"cell_type":"code","source":"# time freq\nbest_deflect_ball = data.time[(data.event_attributes == 'ball deflect') & (data.video_id == 'cfbe2e94_1')]\nplt.figure(figsize = [9,6])\nplt.plot((best_deflect_ball.values).round(2), 'b');\nplt.title('the time range of  (cfbe2e94_1)')\nplt.xlabel('the range')\nplt.ylabel('time')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.579629Z","iopub.execute_input":"2022-08-02T00:11:41.580704Z","iopub.status.idle":"2022-08-02T00:11:41.727446Z","shell.execute_reply.started":"2022-08-02T00:11:41.580662Z","shell.execute_reply":"2022-08-02T00:11:41.726201Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# rate\nbest_changing_deflect_ball = (best_deflect_ball.values).round(2)\nbest_changing_deflect_ball = pd.DataFrame(best_changing_deflect_ball)\nbest_changing_deflect_ball = best_changing_deflect_ball.pct_change(fill_method ='bfill')\nbest_changing_deflect_ball.tail(6)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.729172Z","iopub.execute_input":"2022-08-02T00:11:41.730217Z","iopub.status.idle":"2022-08-02T00:11:41.742228Z","shell.execute_reply.started":"2022-08-02T00:11:41.730164Z","shell.execute_reply":"2022-08-02T00:11:41.741190Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [15,7])\nplt.plot(changing_ball_deflect1, 'r');\nplt.title('the changing rate of (cfbe2e94_1)');\nplt.show();","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.743834Z","iopub.execute_input":"2022-08-02T00:11:41.744315Z","iopub.status.idle":"2022-08-02T00:11:41.960862Z","shell.execute_reply.started":"2022-08-02T00:11:41.744274Z","shell.execute_reply":"2022-08-02T00:11:41.959917Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### let's now visualize the video","metadata":{}},{"cell_type":"code","source":"name = \"best ball deflect.mp4\"\nffmpeg_extract_subclip(\nf\"/kaggle/input/dfl-bundesliga-data-shootout/train/3c993bd2_1.mp4\", \nball_action_forced[20], \nball_action_forced[21] + 9, # 25 minute\ntargetname=name,\n)\nVideo(name, width=765)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:41.962274Z","iopub.execute_input":"2022-08-02T00:11:41.962837Z","iopub.status.idle":"2022-08-02T00:11:42.357526Z","shell.execute_reply.started":"2022-08-02T00:11:41.962803Z","shell.execute_reply":"2022-08-02T00:11:42.356594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## opponent_dispossessed\n#### Dispossessed :  <span style= 'color : red'>means</span> being tackled by an opponent without attempting to dribble past them.","metadata":{}},{"cell_type":"markdown","source":"let's see the videos that has the opponent_dispossessed ","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# for clip and best\nx = list(best_deflect_ball)\nname = \"best_pass_over_open-play2.mp4\"\nffmpeg_extract_subclip(\nf\"/kaggle/input/dfl-bundesliga-data-shootout/train/cfbe2e94_1.mp4\", \nx[1], \nx[1] + 17, \ntargetname=name,\n)\nVideo(name, width=765)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:42.358925Z","iopub.execute_input":"2022-08-02T00:11:42.359736Z","iopub.status.idle":"2022-08-02T00:11:43.299920Z","shell.execute_reply.started":"2022-08-02T00:11:42.359699Z","shell.execute_reply":"2022-08-02T00:11:43.298514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.video_id[data.event_attributes  == \"'opponent_dispossessed'\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:11:43.301610Z","iopub.execute_input":"2022-08-02T00:11:43.302595Z","iopub.status.idle":"2022-08-02T00:11:44.780604Z","shell.execute_reply.started":"2022-08-02T00:11:43.302557Z","shell.execute_reply":"2022-08-02T00:11:44.779412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T00:13:51.752170Z","iopub.execute_input":"2022-08-02T00:13:51.752845Z","iopub.status.idle":"2022-08-02T00:13:51.765658Z","shell.execute_reply.started":"2022-08-02T00:13:51.752807Z","shell.execute_reply":"2022-08-02T00:13:51.764606Z"},"trusted":true},"execution_count":null,"outputs":[]}]}