Football Stats Quiz

1 minute read

About a month ago I watched a very awesome and inspirational talk by Patrick Lucey from StatsPerform on an overview of AI in sport. In one of their slides they mention that “sports data reconstructs the story of the match/performance” and “the more granular the data, the better the story”. The analogy stuck with me and made me wonder: could I predict the score of a football match if I had only a snapshot of its statistics?

As the result of that I have made a very simple quiz game using Streamlit which is available online here -; with all the code located in this repo - Inside the game the user is asked to predict the score of some match given stats on shots and possession per each team.

Football Stats Quiz Gameplay
Football Stats Quiz Gameplay

The biggest challenge for me was to quickly find simple and open-source data with all the stats available. In the end, I relied on two StatsBomb’s repos - and, where the first one is a handy python package and the second is a storage for a subset of all of their data available for free.

I have been using Streamlit in my work for few years now, and so it was an obvious choice for me to prototype the game in Streamlit. However, I usually build interactive dashboards in Streamlit, certainly not games and quizzes, hence in this particular project I had to rely on Streamlit’s session_state much more than usual in order to keep track of the index of the current question and the overall game state. Additionally, I also barely dealt with styling in Streamlit up until now, and I found it still quite hacky in nature - in order to apply a unique style for some Streamlit-generated objects I had to dig numerous times through CSS attributes and various parent-child relationships.

Overall, I definitely had fun working on this project in my spare time. After playing around 10 games, my best score is 9 out of 15, which I personally think is not too bad, but let us see how it compares with others. Feel free to share your scores in the comments section below!

Football Stats Quiz personal best
My best score in the game so far