floodlight-sports / floodlight

Python package for streamlined analysis of sports data.
https://floodlight.readthedocs.io/en/latest/index.html
MIT License
58 stars 14 forks source link

[FEAT] Add a pressure model #128

Closed Alek050 closed 4 months ago

Alek050 commented 1 year ago

Checklist

Is your feature request related to a problem? Please describe. There is not really a problem, the package would just be more complete when a pressure model is added.

Describe the solution you'd like I want a pressure model to be added to the package. In 2016, Adrienko et al. published a paper with a pressure model for soccer specific purposes. The model makes an estimate of the pressure on a player based on the location of the defenders relative to the attacker and the distance between the defenders and the player. The parameters described in the paper are optimized for field soccer situations, but can of course be addapted to fit other field sports. Later Herold et al (2022) updated the model of Adrienko et al since they argued that the pressure parameters should change based on the location on the pitch: pressure is location dependent. A new model could be added to the floodligth package that calculates the pressure on a specific player during a specified time period based on tracking data.

sources:

Describe alternatives you've considered A alternative could be to calculcate the pressure of all players of both teams for the whole match. But I would argue this is not really computational efficient since pressure is mainly interesting during on ball events (take ons or 1-vs-1 actions). Calculating pressure for all players and teams would probably take to long and without any added value. However, if we can make the code computational efficient and fast enough it might make it easier to use since some of the other models also calculate everything for all players during the whole match (Kinematics model) if I'm not mistaken.

Additional context

draabe commented 1 year ago

Hi @Alek050!

Thanks for the suggestion. First off, I think this feature fits our scope and would be a great addition! We should probably include a new submodule along the lines of floodlight.models.pressure and give the model a descriptive name.

Regarding the implementation, my first thoughts are:

Alek050 commented 1 year ago

Hey @draabe ,

Thanks for you positive reaction!

The propper naming of variables is always a difficult subject of course. Maybe PlayerPressure would suffice, since it leaves the oppertunity to add a feature later on that finds the pressure on a whole team. A more descriptive name could be PressureOnPlayer, to make clear it is a metric for the degree of pressure a player 'receives' rather than 'gives'.

Regarding your first thoughts:

I would suggest starting on making a floodlight.models.pressure model PressureOnPlayer. It receives (a slice of) a xy.player() object, the xy object of the opponent team over the same timestamps, and parameters of the pressure model and it returns a PlayerProperty with the pressure of that specific player over that specific timestamp.

Any other suggestions or thoughts?

draabe commented 1 year ago

Hi,

sounds good to me. I'd opt for a bit more specific name (given that there are other pressure models that could be included in the future), but the naming part is rather cosmetic and shouldn't stop us from starting!

Also sounds like a good plan to get going. In case you haven't seen yet (it's a bit hidden), there is a BaseModel class that implements stuff like the @requires_fit decorator and also handles Pitch objects supplied by the user (see again the Voronoi model on how this looks like in action). This might be useful if you want to calculate distances to goals etc.

draabe commented 4 months ago

Hi @Alek050, closing this due to inactivity.

Alek050 commented 4 months ago

Hi @draabe,

Thanks for the update and I understand that you are closing it. I was having problems with dependencies and poetry back when we discussed the issue. I see that the dependencies have been updated since, but have less time now to implement it in your package. I did implement the same idea here, so if you are still interested in the feature being added to Floodlight this could be a good starting point.

draabe commented 4 months ago

Hi @Alek050 , thanks for the heads up! I will look into it