Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add current formation and opponent formation info to event, start with parser for Opta #243

Conversation

DriesDeprest
Copy link
Contributor

I want to add current formation and current opponent formation information to events. This would allow us to more easily filter out events of a team or player when they were playing in a certain formation or against a certain formation. E.g. only analyse events where Lionel Messi was playing as a LW in a 4-4-2 against a 4-3-3.

@DriesDeprest
Copy link
Contributor Author

DriesDeprest commented Dec 1, 2023

@koenvo @JanVanHaaren sorry to bother, but I'm failing to understand why I'm getting this error in the test logs below:
TypeError: GenericEvent.init() missing 2 required positional arguments: 'formation' and 'opponent_formation'

Why is the error message saying 'formation' and 'opponent_formation' are required, while I label them as Optional in my class?

formation: Optional[FormationType]
opponent_formation: Optional[FormationType]

@koenvo
Copy link
Contributor

koenvo commented Dec 1, 2023

Thanks for the PR Dries!

In this case the state builder would be a good fit. Have you seen https://kloppy.pysport.org/examples/state/#Add-state---lineup ? Would this work for your case?

@DriesDeprest
Copy link
Contributor Author

I forgot about the state builder. Yes, indeed, the state builder solves my use case.

However, Wyscout doesn't have a formation change event, it rather encapsulates the formation and opponent formation in each event, see: https://github.com/PySport/kloppy/blob/master/kloppy/tests/files/wyscout_events_v3.json#L57-L127. How would you suggest that we pass the current (opponent) formation information to the events for this data provider?

Would you save the formation information of the prior event in the Wyscout deserializer and check for a difference, and if so create an "artificial" formation change event?

@koenvo
Copy link
Contributor

koenvo commented Dec 4, 2023

The "artificial" formation change event sounds like a great solution.

@DriesDeprest
Copy link
Contributor Author

Okay, will make a new PR which creates artificial formation change event for Wyscout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants