Skip to content

Comments

⚽ Polars implementation#6

Merged
UnravelSports merged 10 commits intomainfrom
feat/kloppy-polars
Jan 27, 2025
Merged

⚽ Polars implementation#6
UnravelSports merged 10 commits intomainfrom
feat/kloppy-polars

Conversation

@UnravelSports
Copy link
Owner

@UnravelSports UnravelSports commented Jan 26, 2025

  • Added a SoccerGraphConverterPolars that is about 2x faster than SoccerGraphConverter.
  • Added improved functionality (and breaking changes) to SoccerGraphConverterPolars
  • For now we keep SoccerGraphConverter as separate functionality, with a deprecation warning to move to SoccerGraphConverterPolars
  • Additionally aligned AmericanFootballGraphConverter (which already had a Polars backend) with syntax used in SoccerGraphConverterPolars

Change Log

KloppyPolarsDataset

We introduce a KloppyPolarsDataset that converts the kloppy_dataset to a Polars dataframe and does a number of conversions and checks. Use it as follows:

kloppy_dataset = skillcorner.load_open_data(
      match_id=match_id,
      coordinates="secondspectrum",
      include_empty_frames=False,
      limit=500,  # limit to 500 frames in this example
  )
  kloppy_polars_dataset = KloppyPolarsDataset(
      kloppy_dataset=kloppy_dataset,
      ball_carrier_threshold=25.0
  )
  kloppy_polars_dataset.load()
  
  # This is where you add your own training labels
  kloppy_polars_dataset.add_dummy_labels()
  kloppy_polars_dataset.add_graph_ids()
  • ball_carrier_threshold has been moved to KloppyPolarsDataset
  • KloppyPolarsDataset sets orientation to Orientation.BALL_OWNING_TEAM (ball owning team plays left to right). Except when we don't know who the ball owning team is. This can happen when a data provider does not provide the ball owning team information.
  • If our dataset does not have the ball owning team we infer the ball owning team automatically using the ball_carrier_threshold and subsequently change the orientation automatically to be left to right for the ball owning team too.
    Note: In SoccerGraphConverter if the ball owning team was not available we set the orientation to STATIC_HOME_AWAY meaning attacking could happen in two directions. I felt this was undesirable.

SoccerGraphConverterPolars

  • boundary_correction has been removed as a parameter
  • infer_ball_ownership has been removed as a parameter, this is now always handled automatically when necessary
  • infer_goalkeepers has been removed as a parameter, this is now always handled automatically when necessary. If we have position labels (e.g. "GK") we use that.
  • labels, graph_id, graph_ids have been removed as parameters. We can now use label_col and graph_id_col as parameters, they default to "label" and "graph_id".

@UnravelSports UnravelSports merged commit 7c8fc7e into main Jan 27, 2025
3 checks passed
@UnravelSports UnravelSports deleted the feat/kloppy-polars branch June 20, 2025 11:28
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.

1 participant