alan-turing-institute / AIrsenal

Machine learning Fantasy Premier League team
MIT License
285 stars 86 forks source link

Output results to file? #325

Open RajeshTailor1 opened 3 years ago

RajeshTailor1 commented 3 years ago

Another feature request is there a way to output the results of the optimisation (just the results) to a file?

jack89roberts commented 3 years ago

Thanks for the suggestion @RajeshTailor1 , this shouldn't be too hard to implement. The results of previous optimisations are already stored in the database, I think (in the transfer_suggestions table), so we could both make it possible to save to file and/or have a quick command to run that retrieves previous results.

RajeshTailor1 commented 3 years ago

Thats brilliant - How can I find the schema I could look at running a sql script to extract the suggestions.

nbarlowATI commented 3 years ago

Hi @RajeshTailor1 , if you look in airsenal/framework/schema.py you can see the SQLAlchemy class definitions, which map onto the tables in the database.
So the TransferSuggestion class corresponds to a table called "transfer_suggestion", and the data members of this class are the columns of the table. Hope this helps - let us know if more info would be useful!

RajeshTailor1 commented 3 years ago

Thanks for this help I have got this up and running (not in a clean way). How do I find where the optimisation script is located? I have also been working on automation which I will test over xmas and new years and share the results.

nbarlowATI commented 3 years ago

Hi @RajeshTailor1 , good work! The optimization script is airsenal/scripts/fill_transfersuggestion_table.py (to find this out, one can look in setup.py to see where the airsenal_run_optimization endpoint points to). Most of the functions that this script calls are in airsenal/framework/optimization_utils.py. Hope this helps!

RajeshTailor1 commented 3 years ago

Hi @nbarlowATI this is exactly what I was looking for, thanks again. Something I have noticed since using this project this season, is the absence of Bruno Fernandes from the top 5 players list. Is this due to him being new and the top 5 players list is calculated from previous seasons as well as current? Or is there something else behind the algorithms that determine the top 5 players from the predictions?

jack89roberts commented 3 years ago

We're hoping to explore these kinds of things in more detail soon. Last time I looked AIrsenal ranked Fernandes 4th overall for midfielders in terms of the probability of scoring or assisting one of Man Utd's goals (behind Salah, Aubameyang and Son). I think the reason he doesn't often appear in the top 5 lists for predicted points is because Man Utd are predicted to score fewer goals than Man City, Liverpool and (marginally) Spurs (so even though Fernandes is predicted to be involved in most of Man Utd's goals, it thinks other players will do better because their teams score more). But Man Utd have probably started to score more since they signed Fernandes, and this won't be reflected in AIrsenal very well at the moment as it uses the last 3 seasons equally, we haven't yet figured out how to incorporate form (but it's near the top of our list of things to look at!)

There's a Jupyter notebook notebooks/player_model.ipynb which looks into the results of the player model a bit (plus a team_model one for the team model).

RajeshTailor1 commented 3 years ago

@jack89roberts Thanks for this info it makes sense, I'll also take a look at the notebook (just out of curiosity).