{"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":"<h1><center>NFL Big Data Bowl 2022 Insights of Special Teams Play</center></h1>","metadata":{}},{"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-01-03T15:55:16.784593Z","iopub.execute_input":"2022-01-03T15:55:16.784963Z","iopub.status.idle":"2022-01-03T15:55:16.816372Z","shell.execute_reply.started":"2022-01-03T15:55:16.784855Z","shell.execute_reply":"2022-01-03T15:55:16.815705Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import datetime\nimport matplotlib\nfrom matplotlib import pyplot as plt\n%matplotlib inline\nmatplotlib.rcParams['figure.figsize'] = (10,6)\nimport seaborn as sns\nfrom scipy.stats import norm\nfrom sklearn.model_selection import train_test_split\nfrom sklearn import tree\nfrom sklearn.tree import DecisionTreeRegressor\nimport tensorflow as tf\nfrom tensorflow import keras\nfrom tensorflow.keras import layers","metadata":{"execution":{"iopub.status.busy":"2022-01-03T15:55:22.883798Z","iopub.execute_input":"2022-01-03T15:55:22.884363Z","iopub.status.idle":"2022-01-03T15:55:29.176230Z","shell.execute_reply.started":"2022-01-03T15:55:22.884327Z","shell.execute_reply":"2022-01-03T15:55:29.175300Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### NFL Big Data Bowl 2022 data (.csv files) reading","metadata":{}},{"cell_type":"code","source":"Players_df = pd.read_csv('/kaggle/input/nfl-big-data-bowl-2022/players.csv')\ndisplay(Players_df.shape)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T15:56:08.287850Z","iopub.execute_input":"2022-01-03T15:56:08.288301Z","iopub.status.idle":"2022-01-03T15:56:08.320976Z","shell.execute_reply.started":"2022-01-03T15:56:08.288273Z","shell.execute_reply":"2022-01-03T15:56:08.320153Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"seasons = [\"2018\", \"2019\", \"2020\"]\ntracking_df = pd.DataFrame()\nfor S in seasons:\n    \n    trackingTemp_df = pd.read_csv(\"../input/nfl-big-data-bowl-2022/tracking\"+S+\".csv\")\n    tracking_df = tracking_df.append(trackingTemp_df)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T15:56:11.944586Z","iopub.execute_input":"2022-01-03T15:56:11.945278Z","iopub.status.idle":"2022-01-03T15:58:45.306053Z","shell.execute_reply.started":"2022-01-03T15:56:11.945237Z","shell.execute_reply":"2022-01-03T15:58:45.304975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### NFL Big Data Bowl 2022 data Feature Engineering","metadata":{}},{"cell_type":"code","source":"display(tracking_df.shape)\n# removing outliers from player tracking data (keep data of Player position along the long axis x (sidelines)of the field, 0 - 120 yards and Player position along the short axis y (endzones lines)of the field, 0 - 53.3 yards)\ntracking_df = tracking_df[(tracking_df.x>0) & (tracking_df.y>0)]\ndisplay(tracking_df.shape)\ntracking_df.describe()","metadata":{"execution":{"iopub.status.busy":"2022-01-03T15:58:55.160848Z","iopub.execute_input":"2022-01-03T15:58:55.161721Z","iopub.status.idle":"2022-01-03T15:59:22.858431Z","shell.execute_reply.started":"2022-01-03T15:58:55.161662Z","shell.execute_reply":"2022-01-03T15:59:22.857447Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(tracking_df.x,bins=20,rwidth=0.8)\nplt.xlabel('Player position on long axis(Yards)')\nplt.ylabel('Count')\nplt.show()\nplt.hist(tracking_df.y,bins=20,rwidth=0.8)\nplt.xlabel('Player position on short axis(Yards)')\nplt.ylabel('Count')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-03T15:59:31.715870Z","iopub.execute_input":"2022-01-03T15:59:31.716179Z","iopub.status.idle":"2022-01-03T15:59:33.400124Z","shell.execute_reply.started":"2022-01-03T15:59:31.716147Z","shell.execute_reply":"2022-01-03T15:59:33.399480Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(tracking_df.x,bins=20,rwidth=0.8,density=True)\nplt.xlabel('Player position on long axis(Yards)')\nplt.ylabel('Count')\n\nrng = np.arange(tracking_df.x.min(),tracking_df.x.max(),0.1)\nplt.plot(rng,norm.pdf(rng,tracking_df.x.mean(),tracking_df.x.std()))","metadata":{"execution":{"iopub.status.busy":"2022-01-03T15:59:38.016436Z","iopub.execute_input":"2022-01-03T15:59:38.017274Z","iopub.status.idle":"2022-01-03T15:59:39.186762Z","shell.execute_reply.started":"2022-01-03T15:59:38.017239Z","shell.execute_reply":"2022-01-03T15:59:39.185997Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(tracking_df.y,bins=20,rwidth=0.8,density=True)\nplt.xlabel('Player position on short axis(Yards)')\nplt.ylabel('Count')\n\nrng = np.arange(tracking_df.y.min(),tracking_df.y.max(),0.1)\nplt.plot(rng,norm.pdf(rng,tracking_df.y.mean(),tracking_df.y.std()))","metadata":{"execution":{"iopub.status.busy":"2022-01-03T15:59:43.362551Z","iopub.execute_input":"2022-01-03T15:59:43.362869Z","iopub.status.idle":"2022-01-03T15:59:44.461962Z","shell.execute_reply.started":"2022-01-03T15:59:43.362841Z","shell.execute_reply":"2022-01-03T15:59:44.461305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"\\033[1m tracking_df x mean:  {tracking_df.x.mean()}\")\nprint(f\"\\033[1m tracking_df y mean:  {tracking_df.y.mean()}\")\nprint(f\"\\033[1m tracking_df x std:  {tracking_df.x.std()}\")\nprint(f\"\\033[1m tracking_df y std:  {tracking_df.y.std()}\")\nx_upper_limit = tracking_df.x.mean() + 2*tracking_df.x.std()\nprint(f\"\\033[1m tracking_df x_upper_limit:  {x_upper_limit}\")\nx_lower_limit = tracking_df.x.mean() - 2*tracking_df.x.std()\nprint(f\"\\033[1m tracking_df x_lower_limit:  {x_lower_limit}\")\ny_upper_limit = tracking_df.y.mean() + 3*tracking_df.y.std()\nprint(f\"\\033[1m tracking_df y_upper_limit:  {y_upper_limit}\")\ny_lower_limit = tracking_df.y.mean() - 3*tracking_df.y.std()\nprint(f\"\\033[1m tracking_df y_lower_limit:  {y_lower_limit}\")\nprint(f\"\\n \\033[1m tracking_df shape before outliers remove:  {tracking_df.shape}\\n\")\n#print(f\"\\n\\033[1m tracking_df1 Outliers: \\n\\n\")\n#display(tracking_df1[(tracking_df1.x>x_lower_limit) | (tracking_df1.x<x_lower_limit) | (tracking_df1.y>y_upper_limit) | (tracking_df1.y<y_lower_limit)])\ntracking_df1 = tracking_df[(tracking_df.x<x_upper_limit) & (tracking_df.x>x_lower_limit) & (tracking_df.y<y_upper_limit) & (tracking_df.y>y_lower_limit)]\nprint(f\"\\n \\033[1m tracking_df1 shape after outliers remove:  {tracking_df1.shape}\\n\")\ndel tracking_df\ntracking_df1.describe()","metadata":{"execution":{"iopub.status.busy":"2022-01-03T15:59:48.748027Z","iopub.execute_input":"2022-01-03T15:59:48.748491Z","iopub.status.idle":"2022-01-03T16:00:06.944369Z","shell.execute_reply.started":"2022-01-03T15:59:48.748457Z","shell.execute_reply":"2022-01-03T16:00:06.943521Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking_df1_Speeds = tracking_df1.copy()\ntracking_df1_Speeds = tracking_df1_Speeds[['nflId','gameId','playId','frameId','event','s']]\n# Remove other events except 'kickoff','free_kick' from player tracking data\ntracking_df1_Speeds = tracking_df1_Speeds.loc[tracking_df1_Speeds.groupby(['gameId','playId']).event.transform(lambda k: np.cumsum(k.isin(['kickoff','free_kick'])) >= 1)]\n# Consider 45 frame ids of player speed from the moment of 'kickoff','free_kick' events \ntracking_df1_Speeds = tracking_df1_Speeds.groupby(['nflId','gameId','playId']).head(45).reset_index()\ntracking_df1_Speeds = tracking_df1_Speeds.groupby(['nflId','gameId','playId']).s.apply(lambda z: z.max()).reset_index()\ntracking_df1_Speeds = tracking_df1_Speeds.sort_values(by='s', ascending=False)\ntracking_df1_Speeds.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:00:19.667662Z","iopub.execute_input":"2022-01-03T16:00:19.667944Z","iopub.status.idle":"2022-01-03T16:00:56.219025Z","shell.execute_reply.started":"2022-01-03T16:00:19.667915Z","shell.execute_reply":"2022-01-03T16:00:56.218200Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Coverting Player's height from foot&inches to inches\n#Players_df[\"height\"] = Players_df[\"height\"].str.replace(\"Jun\", \"6\")\n#Players_df[\"height\"] = Players_df[\"height\"].str.replace(\"May\", \"5\")\nht = (Players_df.height.str.contains('-'), 'height')\nPlayers_df.loc[ht]=Players_df.loc[ht].str.split('-').str[0].astype(int)*12+Players_df.loc[ht].str.split('-').str[1].astype(int)\nPlayers_df['height'] = Players_df.height.astype(int)\n#Players_df = Players_df.replace({'height':{6:72}})\nPlayers_df[\"birthDate\"] = pd.to_datetime(Players_df[\"birthDate\"])\n# finding Player age from birth date\nPlayers_df[\"age\"] = Players_df[\"birthDate\"].apply(lambda l : (datetime.datetime.now().year - l.year))\ndisplay(Players_df.shape)\ndisplay(Players_df.describe())\nPlayers_df.head(3)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:03.800676Z","iopub.execute_input":"2022-01-03T16:01:03.801398Z","iopub.status.idle":"2022-01-03T16:01:03.886159Z","shell.execute_reply.started":"2022-01-03T16:01:03.801343Z","shell.execute_reply":"2022-01-03T16:01:03.885280Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(Players_df.height,bins=20,rwidth=0.8)\nplt.xlabel('Height(inches)')\nplt.ylabel('Count')\nplt.show()\nplt.hist(Players_df.age,bins=20,rwidth=0.8)\nplt.xlabel('Age(years)')\nplt.ylabel('Count')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:09.046892Z","iopub.execute_input":"2022-01-03T16:01:09.047291Z","iopub.status.idle":"2022-01-03T16:01:09.562782Z","shell.execute_reply.started":"2022-01-03T16:01:09.047247Z","shell.execute_reply":"2022-01-03T16:01:09.561949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(Players_df.height,bins=20,rwidth=0.8,density=True)\nplt.xlabel('Height(inches)')\nplt.ylabel('Count')\n\nrng = np.arange(Players_df.height.min(),Players_df.height.max(),0.1)\nplt.plot(rng,norm.pdf(rng,Players_df.height.mean(),Players_df.height.std()))","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:13.026361Z","iopub.execute_input":"2022-01-03T16:01:13.026650Z","iopub.status.idle":"2022-01-03T16:01:13.332226Z","shell.execute_reply.started":"2022-01-03T16:01:13.026622Z","shell.execute_reply":"2022-01-03T16:01:13.331195Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(Players_df.age,bins=20,rwidth=0.8,density=True)\nplt.xlabel('Age(Years)')\nplt.ylabel('Count')\n\nrng = np.arange(Players_df.age.min(),Players_df.age.max(),0.1)\nplt.plot(rng,norm.pdf(rng,Players_df.age.mean(),Players_df.age.std()))","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:17.263583Z","iopub.execute_input":"2022-01-03T16:01:17.263910Z","iopub.status.idle":"2022-01-03T16:01:17.550019Z","shell.execute_reply.started":"2022-01-03T16:01:17.263864Z","shell.execute_reply":"2022-01-03T16:01:17.549181Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"\\033[1m Players_df height mean:  {Players_df.height.mean()}\")\nprint(f\"\\033[1m Players_df age mean:  {Players_df.age.mean()}\")\nprint(f\"\\033[1m Players_df height std:  {Players_df.height.std()}\")\nprint(f\"\\033[1m Players_df age std:  {Players_df.age.std()}\")\nheight_upper_limit = Players_df.height.mean() + 2*Players_df.height.std()\nprint(f\"\\033[1m Players_df height_upper_limit:  {height_upper_limit}\")\nheight_lower_limit = Players_df.height.mean() - 2*Players_df.height.std()\nprint(f\"\\033[1m Players_df height_lower_limit:  {height_lower_limit}\")\nage_upper_limit = Players_df.age.mean() + 3*Players_df.age.std()\nprint(f\"\\033[1m Players_df age_upper_limit:  {age_upper_limit}\")\nage_lower_limit = Players_df.age.mean() - 3*Players_df.age.std()\nprint(f\"\\033[1m Players_df age_lower_limit:  {age_lower_limit}\")\nprint(f\"\\n \\033[1m Players_df shape before outliers remove:  {Players_df.shape}\\n\")\n#print(f\"\\n\\033[1m Players_df Outliers: \\n\\n\")\n#display(Players_df[(Players_df.height>height_lower_limit) | (Players_df.height<height_lower_limit) | (Players_df.age>age_upper_limit) | (Players_df.age<age_lower_limit)])\nPlayers_df1 = Players_df[(Players_df.height<height_upper_limit) & (Players_df.height>height_lower_limit) & (Players_df.age<age_upper_limit) & (Players_df.age>age_lower_limit)]\nprint(f\"\\n \\033[1m Players_df shape after outliers remove:  {Players_df1.shape}\\n\")\ndisplay(Players_df1.describe())\nPlayers_df1.head()","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:24.118362Z","iopub.execute_input":"2022-01-03T16:01:24.118637Z","iopub.status.idle":"2022-01-03T16:01:24.165486Z","shell.execute_reply.started":"2022-01-03T16:01:24.118609Z","shell.execute_reply":"2022-01-03T16:01:24.164920Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Merging Players & players tracking data after outliers removal\ntracking_df1_Player_Speeds = pd.merge(tracking_df1_Speeds, Players_df1, left_on = ['nflId'], right_on = ['nflId'] )\ntracking_df1_Player_Speeds = tracking_df1_Player_Speeds[['nflId','displayName','age','height','weight','s','gameId','playId']]\ntracking_df1_Player_Speeds.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:29.915873Z","iopub.execute_input":"2022-01-03T16:01:29.916168Z","iopub.status.idle":"2022-01-03T16:01:30.007760Z","shell.execute_reply.started":"2022-01-03T16:01:29.916140Z","shell.execute_reply":"2022-01-03T16:01:30.006947Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.xlabel('Player Age')\nplt.ylabel('Player Speed (Yards/Second)')\nplt.scatter(tracking_df1_Player_Speeds['age'],tracking_df1_Player_Speeds['s'],color='green',marker='*')","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:33.594403Z","iopub.execute_input":"2022-01-03T16:01:33.595132Z","iopub.status.idle":"2022-01-03T16:01:34.331702Z","shell.execute_reply.started":"2022-01-03T16:01:33.595097Z","shell.execute_reply":"2022-01-03T16:01:34.331102Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.xlabel('Player Height')\nplt.ylabel('Player Speed (Yards/Second)')\nplt.scatter(tracking_df1_Player_Speeds['height'],tracking_df1_Player_Speeds['s'],color='red',marker='*')","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:38.019322Z","iopub.execute_input":"2022-01-03T16:01:38.020192Z","iopub.status.idle":"2022-01-03T16:01:38.737111Z","shell.execute_reply.started":"2022-01-03T16:01:38.020135Z","shell.execute_reply":"2022-01-03T16:01:38.736331Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.xlabel('Player Weight')\nplt.ylabel('Player Speed (Yards/Second)')\nplt.scatter(tracking_df1_Player_Speeds['weight'],tracking_df1_Player_Speeds['s'],color='Blue',marker='*')","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:42.482941Z","iopub.execute_input":"2022-01-03T16:01:42.483564Z","iopub.status.idle":"2022-01-03T16:01:43.213193Z","shell.execute_reply.started":"2022-01-03T16:01:42.483515Z","shell.execute_reply":"2022-01-03T16:01:43.212314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Model development","metadata":{}},{"cell_type":"code","source":"tracking_df1_Player_Speeds_inputs = tracking_df1_Player_Speeds.drop(['nflId','displayName','gameId','playId','s'],axis='columns')\ntracking_df1_Player_Speeds_inputs['age'] = tracking_df1_Player_Speeds_inputs.age.astype(int)\ntracking_df1_Player_Speeds_inputs.head(3)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:52.236538Z","iopub.execute_input":"2022-01-03T16:01:52.237052Z","iopub.status.idle":"2022-01-03T16:01:52.252000Z","shell.execute_reply.started":"2022-01-03T16:01:52.237009Z","shell.execute_reply":"2022-01-03T16:01:52.251302Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking_df1_Player_Speeds_target = tracking_df1_Player_Speeds['s']\ntracking_df1_Player_Speeds_target.head(3)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:01:56.610023Z","iopub.execute_input":"2022-01-03T16:01:56.610450Z","iopub.status.idle":"2022-01-03T16:01:56.617455Z","shell.execute_reply.started":"2022-01-03T16:01:56.610410Z","shell.execute_reply":"2022-01-03T16:01:56.616755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Use train_test_split to split data to train & test the model","metadata":{}},{"cell_type":"code","source":"X_train,X_test,y_train,y_test = train_test_split(tracking_df1_Player_Speeds_inputs,tracking_df1_Player_Speeds_target,test_size=0.3)\ndisplay(X_train.shape)\ndisplay(y_train.shape)\ndisplay(X_test.shape)\ndisplay(y_test.shape)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:02:02.978675Z","iopub.execute_input":"2022-01-03T16:02:02.979438Z","iopub.status.idle":"2022-01-03T16:02:03.005440Z","shell.execute_reply.started":"2022-01-03T16:02:02.979389Z","shell.execute_reply":"2022-01-03T16:02:03.004926Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Use DecisionTreeRegressor algorithm to build the model","metadata":{}},{"cell_type":"code","source":"tr_pl_dtr = DecisionTreeRegressor(random_state=0)\ntr_pl_dtr.fit(X_train,y_train)\ntr_pl_dtr.score(X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:03:32.980293Z","iopub.execute_input":"2022-01-03T16:03:32.981272Z","iopub.status.idle":"2022-01-03T16:03:33.139084Z","shell.execute_reply.started":"2022-01-03T16:03:32.981217Z","shell.execute_reply":"2022-01-03T16:03:33.138217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Predict player speeds in yards/second with player age in years, height in inches & weight in lbs","metadata":{}},{"cell_type":"code","source":"print(f\"\\033[1m Player with age 23 years, 74 inches height & 225 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[23, 74, 225]])}\")\nprint(f\"\\033[1m Player with age 23 years, 75 inches height & 225 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[23, 75, 225]])}\")\nprint(f\"\\033[1m Player with age 23 years, 74 inches height & 240 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[23, 74, 240]])}\")\nprint(f\"\\033[1m Player with age 23 years, 75 inches height & 240 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[23, 75, 240]])}\")\nprint(f\"\\033[1m Player with age 24 years, 75 inches height & 240 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[24, 75, 240]])}\")\nprint(f\"\\033[1m Player with age 25 years, 75 inches height & 240 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[25, 75, 240]])}\")\nprint(f\"\\033[1m Player with age 26 years, 75 inches height & 240 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[26, 75, 240]])}\")\nprint(f\"\\033[1m Player with age 25.5 years, 75 inches height & 240 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[25.5, 75, 240]])}\")\nprint(f\"\\033[1m Player with age 26 years, 74 inches height & 235 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[26, 74, 235]])}\")\nprint(f\"\\033[1m Player with age 23.5 years, 72.5 inches height & 220 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[23.5, 72.5, 220]])}\")\nprint(f\"\\033[1m Player with age 25 years, 77 inches height & 245 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[25, 77, 245]])}\")\nprint(f\"\\033[1m Player with age 24 years, 74 inches height & 230 lbs weight predictable speed in yards per second after Kick Off or Free Kick:  {tr_pl_dtr.predict([[24, 73, 230]])}\")","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:05:33.803134Z","iopub.execute_input":"2022-01-03T16:05:33.803449Z","iopub.status.idle":"2022-01-03T16:05:33.820532Z","shell.execute_reply.started":"2022-01-03T16:05:33.803420Z","shell.execute_reply":"2022-01-03T16:05:33.819660Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Deep Learning Model with two hidden layers","metadata":{}},{"cell_type":"code","source":"tr_pl_kss = keras.Sequential([keras.layers.Dense(100,activation='softmax'),keras.layers.Dense(50,activation='relu'),keras.layers.Dense(25,activation='sigmoid')])\ntr_pl_kss.compile(optimizer='adam',loss='sparse_categorical_crossentropy',metrics=['accuracy'])\ntr_pl_kss.fit(X_train,y_train,epochs=100)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:05:42.046175Z","iopub.execute_input":"2022-01-03T16:05:42.046607Z","iopub.status.idle":"2022-01-03T16:13:42.837805Z","shell.execute_reply.started":"2022-01-03T16:05:42.046575Z","shell.execute_reply":"2022-01-03T16:13:42.836956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr_pl_kss.summary()","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:13:49.511383Z","iopub.execute_input":"2022-01-03T16:13:49.511839Z","iopub.status.idle":"2022-01-03T16:13:49.519952Z","shell.execute_reply.started":"2022-01-03T16:13:49.511809Z","shell.execute_reply":"2022-01-03T16:13:49.518878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr_pl_kss.evaluate(X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:13:56.454605Z","iopub.execute_input":"2022-01-03T16:13:56.455122Z","iopub.status.idle":"2022-01-03T16:13:58.043403Z","shell.execute_reply.started":"2022-01-03T16:13:56.455089Z","shell.execute_reply":"2022-01-03T16:13:58.042495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_predicted = tr_pl_kss.predict(X_test)\ny_predicted_labels = [np.argmax(i) for i in y_predicted]\ncm = tf.math.confusion_matrix(labels=y_test,predictions=y_predicted_labels)\n\nplt.figure(figsize = (10,7))\nsns.heatmap(cm, annot=True, fmt='d')\nplt.xlabel('Predicted')\nplt.ylabel('Truth')","metadata":{"execution":{"iopub.status.busy":"2022-01-03T16:14:03.378126Z","iopub.execute_input":"2022-01-03T16:14:03.378836Z","iopub.status.idle":"2022-01-03T16:14:06.138709Z","shell.execute_reply.started":"2022-01-03T16:14:03.378789Z","shell.execute_reply":"2022-01-03T16:14:06.137716Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}