Blog of Random Thoughts and Pictures

Advanced football visualisations duels on the pitch Italy compared to England

March 27th, 2021

As mentioned in Part I of this multipart post, Luca Pappalardo prepared a video, for the Friends of Tracking channel in 2020, to talk about some elements of a paper related to an open Wyscout data set, and advanced statistics related to passing networks, flow centrality and player ranking.

For this post (Part II) I’m going to cover my take on the match evolution and spatial stats.

I’ve forked the “mapping-match-events-in-Python” repo into my mmoffoot area and created a new branch called ‘englanddata’ to cover the data set of English Premier League information for the 2017-18 season.

Spatial distribution of events

There are tons of events collated in the WyScout API Events from duels to fouls to interruptions, as explained in the WyScout API document. For passes there are 6 types:

  • Pass = Hand pass,
  • Pass = Head pass,
  • Pass = High pass,
  • Pass = Launch,
  • Pass = Simple pass,
  • Pass = Smart pass,

In this Notebook there’s an interesting set of images created which show the distribution of positions per event type. These kernel density plots show the distribution of the events’ positions during the match with the darker the green representing the higher number of events in a specific zone of the field.

Figure 1: Move the slider to compare Italian Serie A Duels and English Premier League Duels 2017-18

The first image is of duels, and in the WyScout world “Duel” has a specific meaning,

A challenge between two players to gain control of the ball, progress with the ball or change its direction.

With a number of subtypes to consider too: Defensive duel, Offensive duel, Aerial duel, Loose ball duel, and Sliding tackle

For the moment I’m not going into the whys and wherefores of these subtypes, but it’s really interesting to review and compare the images and to see the difference of where the Italian league and the English league host their duels. Dare I say right-backs, left-backs and right wingers, left wingers should look closer if they are moving between the leagues.

A big summer move from England to Italy was Emre Can from Liverpool to Juventus, with Stephan Lichtsteiner coming in from Juventus to Arsenal maybe a view of these plots before the new 2018-19 season got underway might have been handy.

Of note there’s a 10,000 event sample size in here by default, so for the Italian & English league this represents about 6 matches worth of events, and so a larger sample size would be nice to see and compare against. Would also be nice to identify specific players (RB,LB and RW, LW) that were strong in those main duel locations, however that will have to be for another day.

Here are where the fouls happen.

Figure 2: Move slider to compare Italian Serie A Fouls and English Premier League Fouls 2017-18

And the shots.

Figure 3: Move the slide to compare Italian Serie A shots and English Premier League shots 2017-18

Intra-match evolution of the events

Goals are the main stay of football and so when looking at the English and Italian leagues (season 2017-18), its pleasing to see the difference between the leagues, especially the 1st half goals.

Yellow cards and red cards are covered in the data set too, and displayed in the Jupyter Notebook but I’ll be honest and say I didn’t take too much time to analyse the results here, because I was fascinated by the Duel plots.

LOI Matchday 2 Predictions

March 25th, 2021

Here’s another go at the match day predictions, using past match results

For match day 2 in the League of Ireland Premier division

Dundalk (76%) vs Finn Harps (6%)
Draw (13%)

Calling a Dundalk win here

Waterford (43%) vs Sligo Rovers (30%)
Draw (27%)

Calling a drawn match

Bohemians (62%) vs Longford Town (15%)
Draw (22%)

Calling a Bohemians win

St. Patricks (62%) vs Drogheda (15%)
Draw (21%)

Calling a St. Patricks win

Derry City (29%) vs Shamrock Rovers (43%)
Draw (28%)

Calling a drawn match here once it eventually gets played.

Advanced football visualisations and data analysis of match events

March 22nd, 2021

Luca Pappalardo an author of the paper (PCR2019) Pappalardo, L., Cintia, P., Rossi, A. et al. A public data set of spatio-temporal match events in soccer competitions. Nature Scientific Data 6, 236 (2019) prepared a video, for the Friends of Tracking channel in 2020, to talk about some elements of this paper and the related Wyscout data set, which was used for the paper.

In this video Luca covers:

  • The Wyscout data set, how it is collected, from players to events.
  • Basic statistics on events and distributions.
  • Plotting events on the field, match evolution and spatial stats.
  • Advanced statistics: passing networks, flow centrality and playerRank

For this blog post I’m going to cover my take on the player events in the Wyscout data set and the display of some basic statistics on events and distributions.

The origin of the code is available on Github under the project “mapping-match-events-in-Python” and worked through in this video.

Set up

Then I created a new branch called ‘englanddata’ in this area to cover the changes I made.

The example code base uses the Italian league data, but the branch name might be a give away, seeing as the data set has English Premier League information for the 2017-18 season I wanted to run the code base against that data set, and so I took a copy of the original Jupyter Notebook and ran it against the English data as data_england_exploration.ipynb.

The full list of data available includes:

  • Italian first division 2017-18
  • English first division 2017-18
  • Spanish first division 2017-18
  • French first division 2017-18
  • German first division 2017-18
  • European Championship 2017-18
  • World Cup 2018

All the matches, events, players, and competition data sets are hosted in a figshare repository with all the data stored in a JSON format.

The way the data is collected is explained in the paper, with a nice visual representation in the Notebook so I won’t ruin that insight and will let you read it in there.

I should say a quick word on Jupyter Notebooks, its an interactive way of developing and presenting data science projects, and I can really see that it’s an easy way to follow the code base for this project. It’s easy enough to install Jupyter Notebook on a machine too and well worth the install.

Plotting events on the field

There are a number of nice overviews of the structure of data given in the early part of the Notebook, but it’s more interesting when it comes to the static plots.

Figure 1: All Events Tottenham Hotspur 5 – 4 Leicester City, May 13, 2018.

Although of course too much detail can overwhelm and so the interactive plots in this Notebook are much better mechanism to share this information, as in you just have to hover the mouse over the event and its details come to the fore.

Figure 2: Pass Events Tottenham Hotspur – Leicester City, May 13, 2018.
 
Figure 3: Foul Events Tottenham Hotspur – Leicester City, May 13, 2018.
 
Figure 4: Fouls by a specific player Tottenham Hotspur – Leicester City, May 13, 2018.

This is a great Jupyter Notebook, firstly to really learn about Jupyter Notebooks, and then of course to be able to see the structure and how to use WyScout data. It is so important given this data set is used by so many tops clubs for the scouting, analyses and recruitment of players.

There’s more to come, as I plan to complete the match evolution, spatial stats in part II of this blog post and finally cover the advanced statistics: passing networks, flow centrality and playerRank in a part III of this blog post.

LOI Open day predictions not even close

March 21st, 2021

I laid it out there, with opening day predictions for the first set of fixtures for League of Ireland 2021, and not one, not even one came to pass.

By all accounts Drogheda were the better team in the Drogheda 1 vs 0 Waterford match.

I didn’t even come close in any of the other matches. Well I plan to use the same prediction model for the next 2 rounds, just to see if it’s a thing to have the league settle down, and also to evaluate what it is I’m missing from the prediction model.

Football opening day predictions for League of Ireland 2021

March 19th, 2021

The new season (2021) is just about to get underway for the League of Ireland and unfortunately I’m not quite ready with the full league table predictions, but I have got an early version of match prediction analysis software in place (details to follow at a later date) and so I’m going to take a quick look at my local team Waterford FC first and see what we have in store in this first league game against Drogheda United.

What a first match to pick, Waterford and Drogheda haven’t played against each other in the LOI Premier League since July 2007, a 3-0 home win for Drogheda, and with all of my data so far going back to 2012, I’m left a little stumped with having to go on to predict this one. There’s just a model of the home / away goal scoring rates in the LOI since 2012, so in using this the result pops out as:

The Probability of a Home win for Drogheda is 30%
The Probability of an Away win for Waterford is 45%
The Probability of a Draw between Drogheda and Waterford is 25%

Okay an away win for Waterford (maybe), let’s see what happens.

By the way it wasn’t that easy to find a dated version of LOI results from way back when, Whoscored ended up being the best source, with an honourable mention for Goal.

As for the other matches here are the predictions for the opening day

Shamrock Rovers (50%) vs St. Patricks (23%)
Draw (27%)

Finn Harps (24%) vs Bohemians (47%)
Draw (29%)

Longford Town (22%) vs Derry City (53%)
Draw (25%)

Sligo Rovers (24%) vs Dundalk (50%)
Draw (26%)

So wins for Shamrock Rovers, Bohemians, Derry City, Dundalk and Waterford FC for this opening day, let’s see how it pans out.

Top Assister Womens World Cup 2019

March 15th, 2021

As an alternative update to the the first challenge were the Mens World Cup 2018 data was looked at, this time it’s a view of the Womens World Cup 2019.

Again I’m going to look at players that assist a goal and at a glance there was one clear player with the most goal assists at this World Cup 2019, that’s Sherida Spitse from the Netherlands, according to Wikipedia, when I head to another site there is a 2 player tie, both with 4 assists so I’m off again to see what the data highlights.

There’s a fantastic FIFA Technical Report on the Womens World Cup 2019, and while there’s fine details on loads of aspects of the games , the one thing it doesn’t cover is a easy table to see the player with the most assists.

So back to the code base, and using the same code base from the previous challenge the top three that popped out were:

  1. Megan Rapinoe (USA) : 21
  2. Amel Majri (France) : 17
  3. Sherida Spitse (Netherlands) : 16

What actions did they perform

Megan Rapinoe was top of the class with 21 passes that lead to a shot on goal.

Figure 1: Megan Rapinoe passes that assisted a shot on goal

So not only was Rapinoe the Golden Boot winner with six goals, tying with Alex Morgan (6 goals) and Ellen White (6 goals), she also had three assists in the tournament, also tied with Morgan (3 assists), and finally captured the Golden Boot for top scorer on the second tiebreaker, doing it with fewer minutes played than Morgan. Her six goals and three assists also saw her win the Golden Ball as the best player in the tournament.

Figure 2: Expected goals from Megan Rapinoe passes

Clearly Rapinoe was involved in so much of the attacking actions of the USA team, and deserved the accolades it is only lightly worth noting that a number of Rapinoes actions were from set plays (corners and the like).

But this specific write up as about the top assistor, and the next player to look at in the category is Amel Majri of France.

Figure 3: Expected goals from Amel Majri passes

Majri was a left back in the French squad, but wore the number 10 shirt and certainly represented the creative flare of that shirt with 17 passes that lead to a shot on goal. It is also quite noticeable that Majri was very consistent as to where a ball into the box would be placed, a dream for the attacking 3 of France to predict.

However the award for top assistor in the Woman’s World Cup 2019 rightly goes to Sherida Spitse of the Netherlands, with 16 passes that lead to a shot on goal, of which 4 were goals.

Figure 4: Expected goals from Sherida Spitse passes

Spitse played as a right sided defensive (pivot) midfield player for the Netherlands, and here are video clips of all of Spitse assists. This first one is from a special tactic camera.
Of note there are a number of the Womens World Cup matches covered by tactic cameras.

Spitse (Netherlands) assist for a goal in the match Netherlands vs. Canada – Thursday June 20, 2019

Spitse (Netherlands) assist for a goal in the match Netherlands vs. Japan – Tuesday June 25, 2019

First assist for Spitse (Netherlands) in the match Italy vs. Netherlands – Saturday June 29, 2019

Second assist for Spitse (Netherlands) in the match Italy vs. Netherlands – Saturday June 29, 2019

FWWC 2019 – Set-piece specialist World Cup 2019 Sherida Spitse

Mini-challenge: Plotting Actions of an Assister

March 1st, 2021
  1. Think of a player who you enjoyed watching at the recent Men’s or Women’s World Cups.
  2. What actions did they perform that were important and why?
  3. Plot the actions and describe how the data supports or contradicts your own analysis.
  4. Write a short text using at most two figures that illustrate your point.

I’ll address this challenge with a view on a player (or set of players as it turns out), and later in the piece I’ll also share some code snippets on how the information was extracted from the StatsBomb data.

Think of a player

The first challenge and I must admit I’m floundering a little already as I can barely remember the Mens 2018 World Cup, bar the eventual winners, the golden boot winner and the best player award.

However the one thing I do like in football is the player assisting goals.
So for this challenge I thought I would look at the one player that came out on top in this regard at the 2018 World Cup and to state the important actions they performed.

However on first glance it is the case that there is a 16 way tie for the most goal assists at the World Cup 2018, well according to Wikipedia, when I head to another site there is a 19 player tie.

So the first thing I’ve done is take the Team names for all the players listed as the top assist players, have a look at all the passes, and especially all the passes that lead to a goal (or more so a shot on goal) and try and find out the top three players that assisted shots on goal.

This lead to a surprise, for me anyway, because the top three that popped out from this exercise was:

  1. Kieran Trippier (England) : 25
  2. Neymar da Silva Santos Junior (Brazil) : 24
  3. Philippe Coutinho Correia (Brazil) : 13

What actions did they perform

Kieran Trippier had 25 passes that lead to a shot on goal.

Figure 1: Kieran Trippier passes that assisted a shot on goal

 
However Kieran Trippier does not appear on the top player to assist goals chart because for all these passes only one of them lead to an assisted goal (for John Stones).

Now it’s time to look at the Expected Goal plot of the shots that happened, straight after Kieran Trippier gave in the pass for that shot. As far as I can tell Kieran Trippier could have had at least 2, if not 3, other assisted goals, however there are many of those passes that are into areas where the Expected Goal of that next shot is low.

 

Figure 2: Expected goals from Kieran Trippier passes

It is also worth noting that a larger number of Trippiers actions are from set plays (corners and the like).

So who was the top assistor at the 2018 World Cup, is it Neymar of Brazil ?

Neymar comes in second on the list gathered earlier, however he only assisted 1 goal also.

 

Figure 3: Expected goals from Neymars passes

 

Therefore it must be Philippe Coutinho, with 13 passes that assisted a shot on goal and 2 actual goal assists he is the top player in this category.

 

Figure 4: Expected goals from Philippe Coutinho passes

 

Or is he ? A little addendum, when I look to the positions that Neymars passes went into and the Expected Goal setting for each one of those shots taken after a Neymar pass, for me he should be the player of note.

 

FWC 2018 – Group E – SRB v BRA Neymar Jr

 

Figure 5: Scatter plot of expected goals from Top 3 player passes

 

A large number of Neymars assists for a shot are close to the goal (120 is the goal line) and central to the goal (40 is the centre of the goal).

Code snippets

I also want to share some of the code snippets that helped gather the data from Statsbomb in regards to this challenge.

Extracting data from competitions.json

I found it handy to extract the season_id from the competitions.json file and using this to find all the matches with teams I was interested in. This also helped to identify which matches in the events folder had to be picked up.

The Assisted Shot Id

When iterating through the passes finding the pass_assisted_shot_id was very handy, but there was a bit that stumped me for a while when a pass didn’t turn into an assisted shot then that id is set as NaN or not a number, which is a little off putting at first.
There are also times when there are duplicate entries for the pass_assisted_shot_id for related events which in one iteration of this code had Kieran Trippier (England) with 37 actions.

        #Find passes with pass_assisted_shot_id set
        if isinstance(passasid, str):
            #If the pass_assisted_shot_id is a nan (Not a Number) then
            # we don't want it. Usually the assisted_shot_id is some hex value
            playersAsisstingShotsOnGoal.append(tpassplayerdir)

Given that the dataframe of shots for the matches set’s the index name as the Id of the event, well I took me a while to figure how to re-access that index name when doing a compare later on in the code. Of course it’s simple when you see how with the .name.

    for shotOnGoal in matchesShotsOnGoal:
        if (shotOnGoal.name in assistedShotId):
            x=shotOnGoal['location'][0]
            y=shotOnGoal['location'][1]

Acknowledgements

Thanks to feedback from Eoin O’Brien, Eoin Slattery, Michael Kerley, Oliver Critchfield and David Sumpter as this has lead to a revision of the text and images.