{"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":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-01-05T16:25:03.028385Z","iopub.execute_input":"2022-01-05T16:25:03.0287Z","iopub.status.idle":"2022-01-05T16:25:03.058404Z","shell.execute_reply.started":"2022-01-05T16:25:03.028619Z","shell.execute_reply":"2022-01-05T16:25:03.057503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"(Disclaimer: I work for Pro Football Focus, one of the data provider for this competition and hence not eligible for the prize)\n\nPunting is a huge part of special team game in NFL with about four per team games, however strategy behind them espically what are the best decision for punter and returner are not well understand. The following would be a discussion of the following problems:\n\n1. What's the best location for a punt to land?\n2. How much of execution error will affect the result?\n3. How can data evaluate returner performance?","metadata":{}},{"cell_type":"markdown","source":"Generally speaking as the punt land there are two decision a returner a make: \n1. Field the ball for a fair catch or return for yardage\n2. Let the ball bounce\n\nAs American football is an oval shape, the path of it bounce would be much more unpredictable than sports with spherical shape e.g. soccer or tennis, and therefore a model should need to capture the uncertainty of the ball. Therefore, a multi-layer perception model is used for capturing the uncertainty of the bounce. \n\nBy creating a bivariate Normal Distribution model with x-y location of punter, returner and where the ball is landed, we can train a model and sample the output distribution of ball location and build upon it for more detailed analysis. \n\n$$PuntBounceYard \\sim Normal(xy_{punter},xy_{returner},xy_{punt})$$\n\nAnd yard that the ball has bounced is by difference of yard when the ball has velocity and accelaration smaller than 1 $ms^{-1}$ and  $ms^{-2}$\n\n![](https://imgur.com/EJyakEr.png)","metadata":{}},{"cell_type":"markdown","source":"Then we can calculate average starting yard of opponent drive if opponent let the ball boounce. For every 1x1 yard grid on the field, 10,000 samples of the yardline where ball eventually stop at are used and hence calculate the probability of getting touchback which put the ball on 20 yard line, or the ball bounce out of bounce which put the ball to the yard that intersect the boundary. Since for most long distance kick punters are aimed for power not much for accuracy, all models below assume the punt happen on 50 yard line for maximize accuracy. The result is as below:\n\n![](https://imgur.com/Qw0qi12.png)","metadata":{}},{"cell_type":"markdown","source":"For the darkest color which indicate lowest starting yard line (beneficial to punting team), given the returner let the ball to bounce the optimal location of the punt would be about 10 yards, or extend to the sideline where the ball would most likely to bounce out of bound.","metadata":{}},{"cell_type":"markdown","source":"After establishing how the ball bounce, the next thing to do is finding how often the returner let the ball bounce in punter perspective. While it is possible to use a gradient boosting model with similar features as before with location of punter, returner... etc, a tree base model often do not generate an output that is easy to interpret compare to a neural network given similar performance. Therefore a simple multi-layer perception model is used here to predict return probability and others.\n\n![](https://imgur.com/VQUrx6V.png)\n\n![](https://imgur.com/nGToQRO.png)","metadata":{}},{"cell_type":"markdown","source":"For a complete picture, fair catch probability and return yard average (including penalty yards from both side) are also considered.\n\n$$NetReturnYard = ReturnYard-NetPenaltyYardByReceiving$$\n\n![](https://imgur.com/NCyHCK1.png)\n\n$$fairCatchProbability = P(fairCatch|FairCatch,Return,Muffed)$$\n\n![](https://imgur.com/AxmJRrI.png)\n\nWith all the information above, the value of an average return equal to\n\n$$ CatchProbability \\cdot (fairCatchProbability + (1-fairCatchProbability) \\cdot NetReturnYard)) + catchYardline $$\n\nAnd difference between catch and returning can be found\n\n![](https://imgur.com/4It67kx.png)","metadata":{}},{"cell_type":"markdown","source":"As seen above, the cutoff point is about on 5 yard line and if punt land further than that it is better to let the ball bounce instead of catching it. Assuming returner making the optimal decision, here is the average starting yardline corresponding to where the punt land\n\n![](https://imgur.com/LaxpkLS.png)","metadata":{}},{"cell_type":"markdown","source":"It shows that the optimal location of punt is about the sideline, which coincide of traditional knowledge of \"coffin corner\" punt. However, it assume punter has perfect execution of punt while in real life there are some room for error. To address the issue, Gaussian random noise is added to punt location to obvserve the how punt yard change when returner let the ball bounce","metadata":{}},{"cell_type":"markdown","source":"![](https://imgur.com/Qw0qi12.png)\n\n![](https://imgur.com/d0Qkl7J.png)\n\n![](https://imgur.com/VqPWPBg.png)\n\nLarger the error, the advantage of corner punt tends to disappear since there would be a higher chance to give up a touchback. After consider return we can similarly calculate average starting yardline assume returner make the optimal decision\n\n![](https://imgur.com/faHqvCR.png)\n\nComparing to optimal punt location withour error before, it is unfavaourable to punt to corner, and it is pretty much the same aiming for sideline or middle of the field where aming about 9 yard line is the most optimal","metadata":{}},{"cell_type":"markdown","source":"Finally we can use the above information to evaluate how returner perform. But first of all a really big factor about returner is how often he muff the ball, espically for returners who do not set his feet it become much easier. \n\n![](https://imgur.com/UPnlwRU.png)\n\nWith tracking data, it shows that returner speed is correlated to muff risk and higher the speed he is more likely to lose the ball. Given a lost possession close to own end zone can give up ~80 yards of value, it is not worth it for few yards given up by let the ball bounce. We can see how often returners have dangerous by define it as returner speed greater than 5 yards per second. Here is top 10 returners with highest dangerous catch rate (min 20 returns)","metadata":{}},{"cell_type":"code","source":"pd.DataFrame({'player':['Tim White','Donovan Peoples-Jones','Mecole Hardman','Tyreek Hill','D.J. Moore','CeeDee Lamb','Cooper Kupp','Micah Hyde','David Moore','Gunner Olszewski'],'dangerous catch rate':[0.266667, 0.200000,0.183333,0.166667,0.157895,0.153846,0.142857,0.142857,0.142857,0.138462]}).set_index('player')\n","metadata":{"execution":{"iopub.status.busy":"2022-01-05T16:28:59.184936Z","iopub.execute_input":"2022-01-05T16:28:59.1859Z","iopub.status.idle":"2022-01-05T16:28:59.199569Z","shell.execute_reply.started":"2022-01-05T16:28:59.185852Z","shell.execute_reply":"2022-01-05T16:28:59.198316Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Secondly as shown on above punt that land inside 5 yard are likely to become a touchback and hence returners should not try to catch the ball. Here is returners who catch the ball in the 5 yard for more than 1 time","metadata":{}},{"cell_type":"code","source":"pd.DataFrame({'player':['Nyheim Hines','Tarik Cohen','Tyreek Hill','JoJo Natson','Christian Kirk','DaeSean Hamilton',\"De'Anthony Thomas\",'Diontae Johnson','Adam Humphries','Pharoh Cooper','Micah Hyde'],'Catch Inside 5 yards':[3,3,2,2,2,2,2,2,2,2,2]}).set_index('player')\n","metadata":{"execution":{"iopub.status.busy":"2022-01-05T16:28:56.830912Z","iopub.execute_input":"2022-01-05T16:28:56.831246Z","iopub.status.idle":"2022-01-05T16:28:56.843236Z","shell.execute_reply.started":"2022-01-05T16:28:56.83121Z","shell.execute_reply":"2022-01-05T16:28:56.842599Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"As discussed above most returners are able to judge optimally and generally it is not an issue.","metadata":{}},{"cell_type":"markdown","source":"Finally with the expected catch rate model established before, one can find how often a returners can catch the ball over expected. Since for most situations even fair catch the ball can gain few more yards than let it bounce, returners who have more catches are generally better, but of course it is not build on cost that returners catch when the feet are not set. Here is top and bottom five returners with catch rate over expected","metadata":{}},{"cell_type":"code","source":"pd.DataFrame({'player':['Troymaine Pope', 'Ted Ginn', \"Da'Mari Scott\",'Brandon Zylstra' ,'K.J. Osborn', 'D.J. Reed' ,'Chad Beebe' ,'CeeDee Lamb', 'Danny Amendola', 'DaeSean Hamilton'],'Catch rate over expected':[-0.346902,-0.321041,-0.319027,-0.279114,-0.264701,0.008246,0.011463,0.051884,0.060763,0.061008]}).set_index('player')","metadata":{"execution":{"iopub.status.busy":"2022-01-05T16:28:41.563583Z","iopub.execute_input":"2022-01-05T16:28:41.563899Z","iopub.status.idle":"2022-01-05T16:28:41.585156Z","shell.execute_reply.started":"2022-01-05T16:28:41.563866Z","shell.execute_reply":"2022-01-05T16:28:41.584267Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Hope that the above discussion can answer some of the questions you may have regarding to punt. Notebook of code is avaliable here: https://www.kaggle.com/s903124/punt-submission-notebook","metadata":{}}]}