{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"markdown","source":"![](https://1ycbx02rgnsa1i87hd1i7v1r-wpengine.netdna-ssl.com/wp-content/uploads/2019/01/nfl.png)"},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pylab as plt\nimport seaborn as sns\nimport matplotlib.patches as patches\nsns.set_style(\"whitegrid\")\n\n# set additional display options for report\npd.set_option(\"display.max_columns\", 100)\nth_props = [('font-size', '13px'), ('background-color', 'white'), \n            ('color', '#666666')]\ntd_props = [('font-size', '15px'), ('background-color', 'white')]\nstyles = [dict(selector=\"td\", props=td_props), dict(selector=\"th\", \n            props=th_props)]","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"In this notebook, I have tried to utilize the data provided which includes Injury Record, Players Play (267,005 Plays) data and Players Movement Data to generate some significant observations and recommendation which can be beneficial to check the growing trend Injury with the increase in matches on Synthetic Turf. My recommendation are as below which is concluded based on my in-depth analysis as observed below in the notebook.\n\n  - ***The Athletic Shoe In Football :*** It is needed to define optimal shoe sizing, the effect that design has on mechanical load, and how cleat properties, including pattern and structure, interact with the variety of playing surfaces. Important structural considerations of shoe design, including biomechanical compliance, cleat and turf interaction, and shoe sizing/fit, that affect the way an athlete engages with the playing surface should be considered, in case of synthetic turf.\n\n  - ***Friction On Artificial Turf:*** The soil fields of Natural surfaces become slippery after rainfall, they are a cause of sprains, muscle strains, and related types of trauma. Artificial turf fields increase the friction between the ground and the players’ spikes, which allows improved braking and acceleration. As a result, players experience more powerful impacts when they collide due to the increased speed at which they can run, which leads to a higher potential for trauma. Along with this insertion of additional rubber chips into the artificial turf can also help in solving this problem   and this should be replaced every 2 years at least.\n\n\n<p style=\"margin-top:40px\"> \nMy analysis is thoroughly documented in the following sections:  </p>\n\n  - <a href='#bg'>Background and Conclusion</a>\n  - <a href='#mt'>Methodology</a>\n  - <a href='#an'>Analysis</a>\n  - <a href='#tm'>Qualifications</a>\n\n<p style=\"margin-top:40px\">"},{"metadata":{},"cell_type":"markdown","source":"<a id='bg'></a>\n<div class=\"h2\">  Background and Conclusion</div>\n\n<p style=\"margin-top: 20px\">The National Football League (NFL) is a professional American football league consisting of 32 teams, divided equally between the National Football Conference (NFC) and the American Football Conference (AFC). The NFL is one of the four major professional sports leagues in North America and the highest professional level of American football in the world.\n\nRecent investigations of lower limb injuries among football athletes have indicated significantly higher injury rates on synthetic turf compared with natural turf (Mack et al., 2018; Loughran et al., 2019). In conjunction with the epidemiologic investigations, biomechanical studies of football cleat-surface interactions have shown that synthetic turf surfaces do not release cleats as readily as natural turf and may contribute to the incidence of non-contact lower limb injuries (Kent et al., 2015).\n\nFew of the key observations noted from Turfgrass Producers International based on games played in between 2012-16 are :\n\n* 1,280 NFL games (213,935 distinct plays) were played during the 2012-16 seasons.\n* 4,801 lower body injuries occurred during the study sample, affecting 2,032 NFL players.\n* Synthetic turf resulted in a 27% increase in non-contact lower body injuries.\n* 56% higher rate (knee/ankle/foot) of sustaining an injury on synthetic turf that resulted in time lost, and a 67% higher injury rate resulting in more than 8 days time lost from injury.\n* 68% higher rate of sustaining an ankle injury rate on synthetic turf that resulted in any time lost from injury and a 103% increase in injury rates on synthetic turf resulting in more than 8 days time lost from injury."},{"metadata":{},"cell_type":"markdown","source":"<a id='mt'></a>\n<div class=\"h2\">  Methodology </div>\n<p style=\"margin-top: 20px\">I followed an in-depth approach using statistical methodolgies to arrive at conclusion and tested multiple types using sampling of the given data to ensure that there is no biasness in the observations noted. I have also tried to utilize classification models - SVM and Random Forest, however the data provided didn't bring any acceptable model significance and dropped the model and went ahead with Exploratory Data Analysis. I have tried to keep my analysis simple, yet detailed so that it can be easily understood by anyone reading them </p>\n\nThe entire analysis was built on sample comparison to check the biasness due to the presence of less injury cases compared to non injury cases. Every conclusion drawn has been repeatedly validated by multiple samples.\n\n<div class=\"h3\"> External Inputs Considered </div>\nTo understand the problem better, I went through multiple external resources and tried to build relationships while generating my results. Few of such external information considered were as below:\n\n  - NFL Official Rules and history\n  - Videos and game highlights\n  - NFL press releases, articles and general statistics\n  - NFL Health and Safety website \n  - Articles and research papers on sports-related concussions "},{"metadata":{},"cell_type":"markdown","source":"<a id='an'></a>\n<div class=\"h2\">  Analysis</div>"},{"metadata":{"trusted":true},"cell_type":"code","source":"#Memory Reducer Code\n\ndef reduce_mem_usage(df):\n    \"\"\" iterate through all the columns of a dataframe and modify the data type\n        to reduce memory usage.        \n    \"\"\"\n    start_mem = df.memory_usage().sum() / 1024**2\n    print('Memory usage of dataframe is {:.2f} MB'.format(start_mem))\n    \n    for col in df.columns:\n        col_type = df[col].dtype\n        \n        if col_type != object:\n            c_min = df[col].min()\n            c_max = df[col].max()\n            if str(col_type)[:3] == 'int':\n                if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:\n                    df[col] = df[col].astype(np.int8)\n                elif c_min > np.iinfo(np.int16).min and c_max < np.iinfo(np.int16).max:\n                    df[col] = df[col].astype(np.int16)\n                elif c_min > np.iinfo(np.int32).min and c_max < np.iinfo(np.int32).max:\n                    df[col] = df[col].astype(np.int32)\n                elif c_min > np.iinfo(np.int64).min and c_max < np.iinfo(np.int64).max:\n                    df[col] = df[col].astype(np.int64)  \n            else:\n                if c_min > np.finfo(np.float16).min and c_max < np.finfo(np.float16).max:\n                    df[col] = df[col].astype(np.float16)\n                elif c_min > np.finfo(np.float32).min and c_max < np.finfo(np.float32).max:\n                    df[col] = df[col].astype(np.float32)\n                else:\n                    df[col] = df[col].astype(np.float64)\n        else:\n            df[col] = df[col].astype('category')\n\n    end_mem = df.memory_usage().sum() / 1024**2\n    print('Memory usage after optimization is: {:.2f} MB'.format(end_mem))\n    print('Decreased by {:.1f}%'.format(100 * (start_mem - end_mem) / start_mem))\n    \n    return df\n\n\n#def import_data(file):\n #   \"\"\"create a dataframe and optimize its memory usage\"\"\"\n  #  playtrk = pd.read_csv(''../input/nfl-playing-surface-analytics/PlayerTrackData.csv', parse_dates=True, keep_date_col=True)\n   # playtrk = reduce_mem_usage(playtrk)\n    #return playtrk\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#Import available data\n\ninjrec = pd.read_csv('../input/nfl-playing-surface-analytics/InjuryRecord.csv')\nplaylist = pd.read_csv('../input/nfl-playing-surface-analytics/PlayList.csv')\nplaytrk = pd.read_csv('../input/nfl-playing-surface-analytics/PlayerTrackData.csv')\nplaytrk = reduce_mem_usage(playtrk)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Data Preparation - Removing Duplicates\n\ndef clean_weather(row):\n    cloudy = ['Cloudy 50% change of rain', 'Hazy', 'Cloudy.', 'Overcast', 'Mostly Cloudy','Cloudy, fog started developing in 2nd quarter', 'Partly Cloudy','Mostly cloudy', 'Rain Chance 40%',' Partly cloudy', 'Party Cloudy','Rain likely, temps in low 40s', 'Partly Clouidy', 'Cloudy, 50% change of rain','Mostly Coudy', '10% Chance of Rain','Cloudy, chance of rain', '30% Chance of Rain', 'Cloudy, light snow accumulating 1-3\"','cloudy', 'Coudy', 'Cloudy with periods of rain, thunder possible. Winds shifting to WNW, 10-20 mph.','Cloudy fog started developing in 2nd quarter', 'Cloudy light snow accumulating 1-3\"','Cloudywith periods of rain, thunder possible. Winds shifting to WNW, 10-20 mph.','Cloudy 50% change of rain', 'Cloudy and cold','Cloudy and Cool', 'Partly cloudy','Cloudy.','Cold']\n    clear = ['Clear, Windy',' Clear to Cloudy', 'Clear, highs to upper 80s','Clear and clear','Partly sunny',\n             'Clear, Windy', 'Clear skies', 'Sunny', 'Partly Sunny', 'Mostly Sunny', 'Clear Skies',\n             'Sunny Skies', 'Partly clear', 'Fair', 'Sunny, highs to upper 80s', 'Sun & clouds', 'Mostly sunny','Sunny, Windy',\n             'Mostly Sunny Skies', 'Clear and Sunny', 'Clear and sunny','Clear to Partly Cloudy', 'Clear Skies',\n            'Clear and cold', 'Clear and warm', 'Clear and Cool', 'Sunny and cold', 'Sunny and warm', 'Sunny and clear','Heat Index 95']\n    \n    rainy = ['Rainy', 'Scattered Showers', 'Showers', 'Cloudy Rain', 'Light Rain', 'Rain shower', 'Rain likely, temps in low 40s.', 'Cloudy, Rain']\n    \n    snow = ['Heavy lake effect snow']\n    \n    indoor = ['Controlled Climate', 'Indoors', 'N/A Indoor', 'N/A (Indoors)']\n        \n    if row.Weather in cloudy:\n        return 'Cloudy'\n    \n    if row.Weather in indoor:\n        return 'Indoor'\n    \n    if row.Weather in clear:\n        return 'Clear'\n    \n    if row.Weather in rainy:\n        return 'Rain'\n    \n    if row.Weather in snow:\n        return 'Snow'\n    \n    return row.Weather\n\ndef clean_stadiumtype(row):\n    if row.StadiumType in ['Bowl', 'Heinz Field', 'Cloudy']:\n        return np.nan\n    else:\n        return row.StadiumType\n\ndef clean_play_df(playlist):\n    playlist_cleaned = playlist.copy()\n    \n    # clean StadiumType\n    playlist_cleaned['StadiumType'] = playlist_cleaned['StadiumType'].str.replace(r'Oudoor|Outdoors|Ourdoor|Outddors|Outdor|Outside', 'Outdoor')\n    playlist_cleaned['StadiumType'] = playlist_cleaned['StadiumType'].str.replace(r'Indoors|Indoor, Roof Closed|Indoor, Open Roof', 'Indoor')\n    playlist_cleaned['StadiumType'] = playlist_cleaned['StadiumType'].str.replace(r'Closed Dome|Domed, closed|Domed, Open|Domed, open|Dome, closed|Domed', 'Dome')\n    playlist_cleaned['StadiumType'] = playlist_cleaned['StadiumType'].str.replace(r'Retr. Roof-Closed|Outdoor Retr Roof-Open|Retr. Roof - Closed|Retr. Roof-Open|Retr. Roof - Open|Retr. Roof Closed', 'Retractable Roof')\n    playlist_cleaned['StadiumType'] = playlist_cleaned.apply(lambda row: clean_stadiumtype(row), axis=1)\n    \n    # clean Weather\n    playlist_cleaned['Weather'] = playlist_cleaned.apply(lambda row: clean_weather(row), axis=1)\n    \n    return playlist_cleaned\n\nplaylist_cleaned = clean_play_df(playlist)\n\n#Deleting unnecessary files\ndel [[playlist]]\nimport gc\ngc.collect()\nplaylist=pd.DataFrame()\n\n# New column to track no of days missed due to injury\n\ndef label(row):\n   if row['DM_M42']+ row['DM_M28'] + row['DM_M7'] + row['DM_M1']  == 4 :\n     return 42\n   if row['DM_M42']+ row['DM_M28'] + row['DM_M7'] + row['DM_M1']  == 3 :\n      return 28\n   if row['DM_M42']+ row['DM_M28'] + row['DM_M7'] + row['DM_M1']  == 2 :\n      return 7\n   if row['DM_M42']+ row['DM_M28'] + row['DM_M7'] + row['DM_M1']  == 1 :\n      return 1\n      return 0\n     \ninjrec.apply (lambda row: label(row), axis=1)\ninjrec['Minm_Days_Game_Missed'] = injrec.apply (lambda row: label(row), axis=1)\n\ninjrec['BodyPart_Surface']= injrec['Surface'] + '-' + injrec['BodyPart']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Which body part is the most effected?\n\ninjrec.groupby('BodyPart').count()['PlayerKey'] \\\n    .sort_values() \\\n    .plot(kind='bar', figsize=(10, 3), title='Count of injuries by Body Part')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"It can be clearly seen from the plot that Knee and Ankle injuries are the most occuring injuries which together constitues ~ 85% of the injured cases."},{"metadata":{"trusted":true},"cell_type":"code","source":"# Look at the distribution of injuries by Body Part across Turfs - Natural & Synthetic. Is Surface having any impact?\ninjrec.groupby(['BodyPart','Surface']) \\\n    .count() \\\n    .unstack('BodyPart')['PlayerKey'] \\\n    .T.sort_values('Natural').T \\\n    .sort_values('Ankle') \\\n    .plot(kind='bar', figsize=(15, 5), title='Injury Body Part by Turf Type')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Though there isn't much difference in the count of injuries by Turfs (in the given set of injuries data). but it is important to note that Anke and Knee injuries are quite higher on Synthetic Turf compared to Natural whereas Knee injuries are quite common"},{"metadata":{"trusted":true},"cell_type":"code","source":"# To study the impact of other factors driving injuries, merged the injury data with the PlayList data which has the rest of the data.\n\nplaylist_eval = playlist_cleaned.loc[:, ['PlayerKey','GameID','FieldType']]\nplaylist_eval=playlist_eval.drop_duplicates()\nplaylist_eval_1=playlist_eval.merge(injrec[['PlayerKey','BodyPart']],how='left').fillna(\"NoInjury\")\n\ndel [[playlist_eval]]\ngc.collect()\nplaylist_eval=pd.DataFrame()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#This plot only helps in getting a better understanding of Injury Vs Non Injury data points. No significant inference from the plot.\n\nplaylist_eval_1.groupby(['BodyPart','FieldType']) \\\n    .count() \\\n    .unstack('FieldType')['GameID'] \\\n    .sort_values('Natural') \\\n    .T.sort_values('Ankle').T \\\n    .plot(kind='bar', figsize=(15, 5), title='Overall Injury Snapshot')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Addnl : Evaluate the number of injured cases by Surface Types on an overall base of games played.\nComment : It can be clearly seen that the Percentage of Injury cases is higher in Synthetic surface at an overall base as well which indicates that there are some key drivers affecting the playing surface and hence the injuries as well."},{"metadata":{"trusted":true},"cell_type":"code","source":"injrec.groupby(['BodyPart_Surface','Minm_Days_Game_Missed']) \\\n    .count() \\\n    .unstack('BodyPart_Surface')['PlayerKey'] \\\n.sort_values('Minm_Days_Game_Missed') \\\n    .plot(kind='bar', figsize=(15, 5), title='How Surface and Body Part Injury Occured')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"It can be well understood from the above exploratory data analysis, that Knee injuries has the Longest Impact as maximum games are missed when a player has Knee Injuries.\nNow coming to surface, if the Knee or Ankle injuries occured on Synthetic Surface then the injury is more critical compared to the same occured on Natural surface.\nNow what we need to understand whether there is any change in the player movement or playing pattern is driven by  multiple other factors along with Surface (Synthetic) or not."},{"metadata":{"trusted":true,"collapsed":true},"cell_type":"code","source":"#Merging Injury data with Play List Data\nplaylist_cleaned=playlist_cleaned.merge(injrec[['PlayKey','BodyPart','Minm_Days_Game_Missed']],how='left')\nplaylist_cleaned.BodyPart.fillna('', inplace=True)\nplaylist_cleaned.Minm_Days_Game_Missed.fillna('', inplace=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#Created a separate dataset to ensure that results are not biased due to less no of injured events\nmodel_data=playlist_cleaned\n\nmodel_data['BodyPart'] = model_data['BodyPart'].map({'Knee': 1, 'Ankle': 1, 'Foot': 1, '': 0})\nmodel_data_inj=model_data.loc[model_data['BodyPart'] == 1]\nrest_data=model_data.loc[model_data['BodyPart'] == 0]\nmodel_data_noninj=rest_data.sample(frac=0.001)\n\n\nframes = [model_data_inj, model_data_noninj]\nmodel_data_final = pd.concat(frames)\n\nmodel_data_final['BodyPart'].value_counts()\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Compute the correlation matrix\ncorr = model_data_final.corr()\n\n# Generate a mask for the upper triangle\nmask = np.zeros_like(corr, dtype=np.bool)\nmask[np.triu_indices_from(mask)] = True\n\n# Set up the matplotlib figure\nf, ax = plt.subplots(figsize=(11, 9))\n\n# Generate a custom diverging colormap\ncmap = sns.diverging_palette(220, 10, as_cmap=True)\n\n# Draw the heatmap with the mask and correct aspect ratio\nsns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,\n            square=True, linewidths=.5, cbar_kws={\"shrink\": .5})","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#Checking the relationship of each Categorical Variable with the Target Variable (Injury/Non Injury) to find out any significant patter\ncategorical = [\n  'StadiumType', 'Weather', 'PlayType', 'Position', 'PositionGroup']\nfig, ax = plt.subplots(3, 2, figsize=(35, 20))\nfor var, subplot in zip(categorical, ax.flatten()):\n    sns.boxplot(x=var, y='BodyPart', data=model_data_final, ax=subplot)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#Using Player Track Data to find out whether injury has any correlation with player's movement\nplaytrk.head()\nplaytrk=playtrk.merge(model_data[['PlayKey','BodyPart']],how='left')\nplaytrk['BodyPart'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Create Football Field\n\ndef create_football_field(linenumbers=True,\n                          endzones=True,\n                          highlight_line=False,\n                          highlight_line_number=50,\n                          highlighted_name='Line of Scrimmage',\n                          fifty_is_los=False,\n                          figsize=(12, 6.33)):\n    \"\"\"\n    Function that plots the football field for viewing plays.\n    Allows for showing or hiding endzones.\n    \"\"\"\n    rect = patches.Rectangle((0, 0), 120, 53.3, linewidth=0.1,\n                             edgecolor='r', facecolor='darkgreen', zorder=0)\n\n    fig, ax = plt.subplots(1, figsize=figsize)\n    ax.add_patch(rect)\n\n    plt.plot([10, 10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80,\n              80, 90, 90, 100, 100, 110, 110, 120, 0, 0, 120, 120],\n             [0, 0, 53.3, 53.3, 0, 0, 53.3, 53.3, 0, 0, 53.3, 53.3, 0, 0, 53.3,\n              53.3, 0, 0, 53.3, 53.3, 0, 0, 53.3, 53.3, 53.3, 0, 0, 53.3],\n             color='white')\n    if fifty_is_los:\n        plt.plot([60, 60], [0, 53.3], color='gold')\n        plt.text(62, 50, '<- Player Yardline at Snap', color='gold')\n    # Endzones\n    if endzones:\n        ez1 = patches.Rectangle((0, 0), 10, 53.3,\n                                linewidth=0.1,\n                                edgecolor='r',\n                                facecolor='blue',\n                                alpha=0.2,\n                                zorder=0)\n        ez2 = patches.Rectangle((110, 0), 120, 53.3,\n                                linewidth=0.1,\n                                edgecolor='r',\n                                facecolor='blue',\n                                alpha=0.2,\n                                zorder=0)\n        ax.add_patch(ez1)\n        ax.add_patch(ez2)\n    plt.xlim(0, 120)\n    plt.ylim(-5, 58.3)\n    plt.axis('off')\n    if linenumbers:\n        for x in range(20, 110, 10):\n            numb = x\n            if x > 50:\n                numb = 120 - x\n            plt.text(x, 5, str(numb - 10),\n                     horizontalalignment='center',\n                     fontsize=20,  # fontname='Arial',\n                     color='white')\n            plt.text(x - 0.95, 53.3 - 5, str(numb - 10),\n                     horizontalalignment='center',\n                     fontsize=20,  # fontname='Arial',\n                     color='white', rotation=180)\n    if endzones:\n        hash_range = range(11, 110)\n    else:\n        hash_range = range(1, 120)\n\n    for x in hash_range:\n        ax.plot([x, x], [0.4, 0.7], color='white')\n        ax.plot([x, x], [53.0, 52.5], color='white')\n        ax.plot([x, x], [22.91, 23.57], color='white')\n        ax.plot([x, x], [29.73, 30.39], color='white')\n\n    if highlight_line:\n        hl = highlight_line_number + 10\n        plt.plot([hl, hl], [0, 53.3], color='yellow')\n        plt.text(hl + 2, 50, '<- {}'.format(highlighted_name),\n                 color='yellow')\n    return fig, ax\n\ncreate_football_field()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#inj_cases=model_data_inj.sample(frac=0.10)\n#non_inj_cases=rest_data.sample(frac=0.05)\n# image utils\n#from PIL import Image\n#ax = Image.open('../input/nfl-utils/nfl_coordinates.png')\n#ax = ax.resize((1200,533))\n  # show background\n #   fig = plt.figure(figsize=figsize)\n  #  plt.imshow(np.array(background).transpose(0,1,2), origin='lower')\n    \n#Movement of Injured Players\nexample_play_id1 = model_data_inj['PlayKey'].values[0]\nexample_play_id2 = model_data_inj['PlayKey'].values[1]\nexample_play_id3 = model_data_inj['PlayKey'].values[2]\nexample_play_id4 = model_data_inj['PlayKey'].values[3]\nexample_play_id5 = model_data_inj['PlayKey'].values[4]\nfig, ax = create_football_field()\nplaytrk.query('PlayKey == @example_play_id1')\\\n.plot(kind='scatter', x='x', y='y', title='Players Movement - Injured Plays',color='orange',ax=ax)\nplaytrk.query('PlayKey == @example_play_id2')\\\n.plot(kind='scatter', x='x', y='y',title='Players Movement - Injured Plays',color='red', ax=ax)\nplaytrk.query('PlayKey == @example_play_id3')\\\n.plot(kind='scatter', x='x', y='y',title='Players Movement - Injured Plays',color='yellow', ax=ax)\nplaytrk.query('PlayKey == @example_play_id4')\\\n.plot(kind='scatter', x='x', y='y',title='Players Movement - Injured Plays',color='blue', ax=ax)\nplaytrk.query('PlayKey == @example_play_id5')\\\n.plot(kind='scatter', x='x', y='y',title='Players Movement - Injured Plays',color='black', ax=ax)\nplt.show()\n\n\n#Movement of Non Injured Players\nexample_play_id1 = rest_data['PlayKey'].values[0]\nexample_play_id2 = rest_data['PlayKey'].values[1]\nexample_play_id3 = rest_data['PlayKey'].values[2]\nexample_play_id4 = rest_data['PlayKey'].values[3]\nexample_play_id5 = rest_data['PlayKey'].values[4]\nfig, ax = create_football_field()\nplaytrk.query('PlayKey == @example_play_id1')\\\n.plot(kind='scatter', x='x', y='y', title='Players Movement - Non Injured Plays',color='orange',ax=ax)\nplaytrk.query('PlayKey == @example_play_id2')\\\n.plot(kind='scatter', x='x', y='y',title='Players Movement - Non Injured Plays',color='red', ax=ax)\nplaytrk.query('PlayKey == @example_play_id3')\\\n.plot(kind='scatter', x='x', y='y',title='Players Movement - Non Injured Plays',color='yellow', ax=ax)\nplaytrk.query('PlayKey == @example_play_id4')\\\n.plot(kind='scatter', x='x', y='y',title='Players Movement - Non Injured Plays',color='blue', ax=ax)\nplaytrk.query('PlayKey == @example_play_id5')\\\n.plot(kind='scatter', x='x', y='y',title='Players Movement - Non Injured Plays',color='black', ax=ax)\nplt.show()\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"playtrk.head()\n\n# How speed of different players are observed in Injured Vs Non Injured Cases\n\n#Injured Cases\ninj_list = model_data_inj['PlayKey'].tolist()\nplaytrk.query('PlayKey == @inj_list')\\\n.plot(kind='scatter', x='x', y='dis', title='Speed Across Distance Travelled - Injured Plays',color='orange')\nplt.show()\n\n\n#Non Injured Cases\nnoninj_list = rest_data['PlayKey'].tolist()\nplaytrk.query('PlayKey == @noninj_list').sample(22195)\\\n.plot(kind='scatter', x='x', y='dis', title='Speed Across Distance Travelled - Non Injured Plays',color='red')\nplt.show()\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# At which Orientation the injuries occur\n\n#Injured Cases\ninj_list = model_data_inj['PlayKey'].tolist()\nplaytrk.query('PlayKey == @inj_list')\\\n.plot(kind='scatter', x='o', y='dir', title='Speed Across Distance Travelled - Injured Plays',color='orange')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id='tm'></a>\n<div class=\"h2\">  Qualification</div>\n\n<p style=\"margin-top: 20px\"> I am currently as a Principal Data Scientist with ITC Infotech Ltd with strong math background and 9+ years of experience using predictive modeling, data processing, and data mining algorithms to solve challenging business problems in Retail/CPG/BFSI domain. Involved in R/Python open source community and passionate about deep reinforcement learning and other advance ML algorithms."}],"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":4,"nbformat_minor":1}