ML-KULeuven / soccer_xg

A Python package for training and analyzing expected goals (xG) models in soccer.
Apache License 2.0
163 stars 21 forks source link

Pretrained xG models #3

Closed joaomcalves closed 2 months ago

joaomcalves commented 2 months ago

Hi @probberechts , you mentioned in a previous issue that there are pretrained xG models. I was trying to find one but wasn't able. Do you have any link from where I can download a pretrained model to apply to an event df with the spadl format.

probberechts commented 2 months ago

See https://github.com/ML-KULeuven/soccer_xg/tree/master/soccer_xg/models. The README explains how you can load them.

joaomcalves commented 2 months ago

Thanks @probberechts! I should have read it more carefully.

joaomcalves commented 2 months ago

Sorry for bothering you again @probberechts .. Is there an easy way to compute the xg when having a df in the spadl_format? I am downloading data from whoscored using soccerdata package. I was trying something like: xg_model = XGModel.load_model('openplay_xgboost_advanced') xg_model.estimate(spadl_df) But it seems that it is only prepared for DataAPI objects

joaomcalves commented 2 months ago

I am trying to use the repos that you created to have a rating like whoscored or flashscore has and I am trying to have something as complete as possible.

probberechts commented 2 months ago

The input of the estimate function can also be a dataframe with features. You can use this function to compute the features for a single game: https://github.com/ML-KULeuven/soccer_xg/blob/b9489d929e0fa34771267d429256366d0fda27ad/soccer_xg/xg.py#L601

joaomcalves commented 2 months ago

Thanks @probberechts for being always so helpful!