Sport Informatics and Analytics/Pattern Recognition/Python
Introduction
This topic develops issues raised in Pattern Recognition, Theme 2 of this course. It starts a conversation about the use of Python, a dynamic, general purpose programming language[1], in sport analytics.
Guido van Rossum compiled a history of Python in blog posts written between 2009 and 2013[2].
In this blog, I will shine the spotlight on Python's history. In particular, how Python was developed, major influences in its design, mistakes made, lessons learned, and future directions for the language.[3]
There is a detailed description of Python on this Wikipedia page.
A growing number of sport analytics practitioners combine Python and R in their work.[4] We introduce you to both platforms in this course. Your choice or combination of either language can be guided by these questions posed by Kevin Markham[5]:
- Do you have experience of programming in other languages?
- Are you working in academia or industry?
- Machine learning or statistical learning?
- Gentle introduction?
- Data exploration focus?
- Data cleaning focus?
- Data visualisation priorities?
Ana Crisan observes of these questions:
If you are capable of thinking about your problem in abstract terms (and thinking statistically is, to me, generalized and abstract terms), then the choice of language has little baring. While there is always some fussing about to get accustomed to a language's nuances, and there are some benefits of one languages over another, the truth is if you know how to analyze data you know how to find what you need within a language.[6]
In this course we encourage you to keep an open mind about the tools you use to analyse performance but are keen to support your use of Python and R.
Florencia D'Andrea (2019)[7] helped with some of these choices with the publication of Python tutorial resources that includes an R bootcamp. Oleksil Kharkovyna (2019)[8] has shared a beginner's guide to Python to extend the choices you have when you use Python. Costas Andreou (2020)[9] describes how to use the xlwings python library to connect with Excel VBA to enable the passing of data between both platforms.
Learning Python
If you are new to programming, there are lots of open resources to help you on your learning journey.
Python.org has an introduction to Python that presents the reader informally to the basic concepts and features of the Python language and system. The authors suggest that after the introduction "you will be able to read and write Python modules and programs, and you will be ready to learn more about the various Python library modules"[10]
Ola Sendecka[11] has created a series of video tutorials that you might find to be a gentle introduction.
See, for example, a guide to the Command Line
Her second video introduces Python.
Other tutorials in the series (Coding is for Girls) include:
- Python basics
- Dictionaries
- Comparisons
- Saving files and 'if' statements
- Functions
- User input and dealing with errors
- Documentation
- Reading and writing files
- Reading data from csv file
There is a Django Girls tutorial that you might find of interest that provides a step by step introduction that leads to the production of your own website.
Ben Hamner[12] and Elena Kirzhner[13], among others, have provided an introduction to visualisation with Python.
Al Sweigart[14] has made available an online introduction to Python for beginners.
FC Python provides an example of using association football to introduce Python basics.
Using Python in sport contexts
Researchers in sport have used Python in a variety of contexts. Some of them are presented here as case studies.
Case study 1: team pursuit cycling
Case study 2: basketball
Case study 3: NFL
Case study 4: Web scraping
Case study 5: bicycle journeys
Case study 6: association football
Case study 7: sleep patterns
References
- ↑ van Rossum, Guido (13 January, 2009). "Introduction and Overview". https://python-history.blogspot.com.au/2009/01/introduction-and-overview.html. Retrieved 13 October 2017.
- ↑ van Rossum, Guido (13 January, 2009). "The History of Python". https://python-history.blogspot.com.au/. Retrieved 13 October 2017.
- ↑ van Rossum, Guido (13 January, 2009). "Introduction and Overview". https://python-history.blogspot.com.au/2009/01/introduction-and-overview.html. Retrieved 13 October 2017.
- ↑ Koerhsen, Will (28 December 2017). "Random Forest in Python". https://towardsdatascience.com/random-forest-in-python-24d0893d51c0. Retrieved 117 December 2019.
- ↑ Markham, Kevin (2 February, 2005). "Should you teach Python or R for data science?". http://www.dataschool.io/python-or-r-for-data-science/. Retrieved 13 October 2017.
- ↑ Crisan, Ana (2 February, 2005). "Comment: Should you teach Python or R for data science?". http://www.dataschool.io/python-or-r-for-data-science/. Retrieved 13 October 2017.
- ↑ D'Andrea, Florencia (2019). "Tutorials". https://github.com/flor14/tutorials/blob/master/README.md. Retrieved 25 October 2019.
- ↑ Kharkovyna, Oleksil (17 July 2019). "A Beginner’s Guide to Python for Data Science". https://towardsdatascience.com/a-beginners-guide-to-python-for-data-science-60ef022b7b67. Retrieved 15 Decemer.
- ↑ Andreou, Costas (20 January 2020). "How to Supercharge Excel With Python". https://towardsdatascience.com/how-to-supercharge-excel-with-python-726b0f8e22c2. Retrieved 29 January 2020.
- ↑ Python Software Foundation (12 September 2014). "The Python Tutorial". https://docs.python.org/3/tutorial/. Retrieved 13 October 2017.
- ↑ Ossowski, Annabell (8 October 2017). "Your Django Story: Meet Ola Sendecka". http://blog.djangogirls.org/post/97295303273/your-django-story-meet-ola-sendecka. Retrieved 13 October 2017.
- ↑ Hamner, Ben (2017). "Python Data Visualizations". https://www.kaggle.com/benhamner/python-data-visualizations. Retrieved 13 December 2017.
- ↑ Kirzhner, Elena (6 December 2017). "Python Data Visualization — Comparing 5 Tools". https://codeburst.io/overview-of-python-data-visualization-tools-e32e1f716d10. Retrieved 13 December 2017.
- ↑ Sweigart, Al. "Automate the boring stuff with Python". https://automatetheboringstuff.com/. Retrieved 6 February 2018.
- ↑ Burden et al, Jun (2010). "Tracking a single cyclist during a team changeover on a velodrome track with Python and OpenCV". Procedia Engineering 2(2): 2931-2935.
- ↑ Fox, Joe; Menzies, Ryan; Emamdjomeh, Armand (14 April 2016). "Every shot Kobe Bryant ever took. All 30,699 of them". http://graphics.latimes.com/kobe-every-shot-ever/. Retrieved 13 October 2017.
- ↑ Fox, Joe (19 April 2016). "How we mapped Kobe's 30,699 shots". http://www.latimes.com/visuals/graphics/la-g-kobe-how-we-did-it-20160419-snap-htmlstory.html. Retrieved 13 October 2017.
- ↑ Davis, Ryan (6 August 2019). "NBA Data Processing Tutorials". https://github.com/rd11490/NBA_Tutorials. Retrieved 7 August 2019.
- ↑ Fordham, Stephen (6 October). "8 Useful P". https://towardsdatascience.com/8-useful-pandas-features-for-data-set-handling-753e9d8ba8ff. Retrieved 11 October 2019.
- ↑ Jürisoo, Mart (20 April 2018). "International football results from 1872 to 2019". https://www.kaggle.com/martj42/international-football-results-from-1872-to-2017. Retrieved 20 April 2018.
- ↑ Fordham, Stephen (6 October). "8 Useful P". https://towardsdatascience.com/8-useful-pandas-features-for-data-set-handling-753e9d8ba8ff. Retrieved 11 October 2019.
- ↑ Jürisoo, Mart (20 April 2018). "International football results from 1872 to 2019". https://www.kaggle.com/martj42/international-football-results-from-1872-to-2017. Retrieved 20 April 2018.