https://github.com/alan-turing-institute/airsenal

Machine learning Fantasy Premier League team

https://github.com/alan-turing-institute/airsenal

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    9 of 39 committers (23.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.6%) to scientific vocabulary

Keywords

hacktoberfest hut23 hut23-222

Keywords from Contributors

transformer data-safe-haven hut23-1304 hut23-190 hut23-448 hut23-612 interactive hut23-837 archival projection
Last synced: 10 months ago · JSON representation

Repository

Machine learning Fantasy Premier League team

Basic Info
  • Host: GitHub
  • Owner: alan-turing-institute
  • License: mit
  • Language: Jupyter Notebook
  • Default Branch: main
  • Homepage:
  • Size: 82.5 MB
Statistics
  • Stars: 329
  • Watchers: 23
  • Forks: 95
  • Open Issues: 106
  • Releases: 21
Topics
hacktoberfest hut23 hut23-222
Created almost 8 years ago · Last pushed 10 months ago
Metadata Files
Readme Contributing License

README.md

AIrsenal

Build Status

AIrsenal is a package for using Machine learning to pick a Fantasy Premier League team.

Background and News

For some background information and details see https://www.turing.ac.uk/research/research-programmes/research-engineering/programme-articles/airsenal.

AIrsenal Details for 2025/26 season

We have made a mini-league "Prem-AI League" for players using this software. To join, login to the FPL website, and navigate to the page to join a league: https://fantasy.premierleague.com/leagues then click "Join a League". The code to join is: xoz7vm. Hope to see your AI team there!! :)

Our own AIrsenal team's ID for the 2025/26 season is 742663.

Installation

Installation from source [Recommended]

We recommend using uv for managing Python versions and dependencies. For instructions on how to install uv, go to: https://docs.astral.sh/uv/getting-started/installation/

With uv installed, run these commands in a terminal to download and install AIrsenal:

Linux and macOS

**With uv (recommended):** ```shell git clone https://github.com/alan-turing-institute/AIrsenal.git cd AIrsenal uv sync ``` **With pip:** If not using `uv` you can replace `uv sync` with `pip install .` above, but we recommend you do so in a virtual environment, e.g. ```shell git clone https://github.com/alan-turing-institute/AIrsenal.git cd AIrsenal python -m venv .venv source .venv/bin/activate pip install . ```

Windows

The best ways to run AIrsenal on Windows are either to use [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install) (WSL), which allows you to run AIrsenal in a Linux environment on your Windows system, or Docker (see below). You can then follow the installation instructions for Linux and macOS above. You're free to try installing and using AIrsenal in Windows itself, but so far we haven't got it working. The main difficulties are with installing [jax](https://github.com/google/jax#installation) and some database/pickling errors (e.g. #165). If you do get it working we'd love to hear from you!

Docker

Rather than building and running natively on your machine, you can instead use a Docker image if you prefer. Build the docker-image: ```console $ docker build -t airsenal . ``` Create a volume for data persistance: ```console $ docker volume create airsenal_data ``` Run commands with your configuration as environment variables, eg: ```console $ docker run -it --rm -v airsenal_data:/tmp/ -e "FPL_TEAM_ID=" -e "AIRSENAL_HOME=/tmp" airsenal bash ``` or ```console $ docker run -it --rm -v airsenal_data:/tmp/ -e "FPL_TEAM_ID=" -e "AIRSENAL_HOME=/tmp" airsenal airsenal_run_pipeline ``` `airsenal_run_pipeline` is the default command.

AIrsenal on PyPi [Work in Progress]

⚠️ There are currently dependency issues with installing AIrsenal from PyPI (see #733), so it's not recommended. We're working on it. ⚠️ You can now do `pip install airsenal` in your Python virtual environment of choice, and it should work out-of-the-box, allowing you to run all the `airsenal_*` commands listed in the [Getting Started section](#getting-started). However, a couple of caveats: * Due to a dependency using an older version of `jaxlib` this currently doesn't work on Python 3.13 or later. * We will aim to keep the version on PyPi relatively up-to-date, but if you want the very latest developments, they will appear first in Github (on the `develop` branch if you're feeling brave, or `main` if you want a more stable version), which would require [building from source](#installation-from-source)

Optional dependencies

AIrsenal has optional dependencies for plotting, running notebooks, and an in development AIrsenal API. To install them run: - With uv: `uv sync --all-extras` - Without uv: `pip install ".[api,notebook,plot]"`

Running Python commands with uv

If using AIrsenal with uv you must either prepend uv run to all the AIrsenal commands below (e.g. uv run airsenal_setup_initial_db), or activate the virtual environment created by uv and then run them as normal. By default the virtual environment can be activated with source .venv/bin/activate.

Configuration

Once you've installed the module, you will need to set the following parameters:

Required:

  1. FPL_TEAM_ID: the team ID for your FPL side.

Recommended:

  1. FPL_LOGIN: your FPL login, usually email (this is required to get any changes made to your team since the last gameweek deadline).

  2. FPL_PASSWORD: your FPL password (this is required to get any changes made to your team since the last gameweek deadline).

Optional:

  1. FPL_LEAGUE_ID: a league ID for FPL (this is only required for plotting FPL league standings).

  2. AIRSENAL_DB_FILE: Local path to where you would like to store the AIrsenal sqlite3 database. If not set AIRSENAL_HOME/data.db will be used by default.

The values for these should be defined either in environment variables with the names given above, or as files in AIRSENAL_HOME (a directory AIrsenal creates on your system to save config files and the database).

To view the location of AIRSENAL_HOME and the current values of all set AIrsenal environment variables run:

bash airsenal_env get

Use airsenal_env set to set values and store them for future use. For example:

bash airsenal_env set -k FPL_TEAM_ID -v 123456

See airsenal_env --help for other options.

Getting Started

Note: Most the commands below can be run with the --help flag to see additional options and information.

Run the Full AIrsenal Pipeline

The easiest way to run AIrsenal is to use the pipeline script:

shell airsenal_run_pipeline

This will create or update the database, compute points predictions, and suggest transfers. Add --help to see the available options, by default predictions and transfers are calculated for the next 3 gameweeks.

Alternatively, you can run each step of AIrsenal independently, as follows:

1. Creating the database

Run the following command to create the AIrsenal database:

shell airsenal_setup_initial_db

This will fill the database with data from the last 3 seasons, as well as all available fixtures and results for the current season.

2. Updating the database

Once the database has been created, you just need to update it each time before you run predictions or optimisations. This pulls all the latest data from the FPL API, such as recent match results, changes to fixtures, new players, and player injury/suspension statuses.

shell airsenal_update_db

3. Running predictions

The next step is to predict the expected points for all players for the next fixtures. Player points predictions are computed using two models, a team-level model to predict match scorelines, and a player level model to predict player goal involvements, as well as several heuristics based on historical averages.

This is done using the command

shell airsenal_run_prediction --weeks_ahead 3

Predicting the next 3 gameweeks of fixtures is the default but this can be configured with the argument above.

4. Transfer or Squad Optimization

Finally, we need to run the optimizer to pick the best transfer strategy over the next weeks (and hence the best team for the next week).

shell airsenal_run_optimization --weeks_ahead 3

This will take a while, but should eventually provide a printout of the optimal transfer strategy, in addition to the teamsheet for the next match (including who to make captain, and the order of the substitutes). You can also optimise chip usage with the arguments --wildcard_week <GW>, --free_hit_week <GW>, --triple_captain_week <GW> and --bench_boost_week <GW>, replacing <GW> with the gameweek you want to play the chip (or use 0 to try playing the chip in all gameweeks).

Note that airsenal_run_optimization should only be used for transfer suggestions after the season has started. If it's before the season has started and you want to generate a full squad for gameweek one you should instead use:

shell airsenal_make_squad --num_gameweeks 3

5. Apply Transfers and Lineup

To apply the transfers recommended by AIrsenal to your team on the FPL website run airsenal_make_transfers. This can't be undone! You can also use airsenal_set_lineup to set your starting lineup, captaincy choices, and substitute order to AIrsenal's recommendation (without making any transfers). Note that you must have created the FPL_LOGIN and FPL_PASSWORD files for these to work (as described in the "Configuration" section above).

⚠️ Also note that this command can't currently apply chips such as "free hit" or "wildcard", even if those were specified in the airsenal_run_optimization step. If you do want to use this command to apply the transfers anyway, you can play the chip at any time before the gameweek deadline via the FPL website.

Contributing

We welcome all types of contribution to AIrsenal, for example questions, documentation, bug fixes, new features and more. Please see our contributing guidelines. If you're contributing for the first time but not sure what to do a good place to start may be to look at our current issues, particularly any with the "Good first issue" tag. Also feel free to just say hello!

Issues and New Features

AIrsenal is regularly developed to fix bugs and add new features. If you have any problems during installation or usage please let us know by creating an issue (or have a look through existing issues to see if it's something we're already working on).

You may also like to try the development version of AIrsenal, which has the latest fixes and features. To do this checkout the develop branch of the repo and reinstall:

shell git checkout develop git pull uv sync # or "pip install --force-reinstall ." if not using uv

If there have been database changes you may also need to run airsenal_setup_initial_db --clean after the above.

Development

If you're developing AIrsenal we further recommend using uv.

We also have a pre-commit config to run the code quality tools we use automatically when making commits. To setup the commit hooks run:

shell pre-commit install --install-hooks

And tests can be run with

shell pytest airsenal/tests

Owner

  • Name: The Alan Turing Institute
  • Login: alan-turing-institute
  • Kind: organization
  • Email: info@turing.ac.uk

The UK's national institute for data science and artificial intelligence.

GitHub Events

Total
  • Create event: 14
  • Release event: 2
  • Issues event: 56
  • Watch event: 26
  • Delete event: 14
  • Issue comment event: 109
  • Push event: 66
  • Pull request review event: 4
  • Pull request review comment event: 3
  • Pull request event: 31
  • Fork event: 10
Last Year
  • Create event: 14
  • Release event: 2
  • Issues event: 56
  • Watch event: 26
  • Delete event: 14
  • Issue comment event: 109
  • Push event: 66
  • Pull request review event: 4
  • Pull request review comment event: 3
  • Pull request event: 31
  • Fork event: 10

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 1,469
  • Total Committers: 39
  • Avg Commits per committer: 37.667
  • Development Distribution Score (DDS): 0.532
Past Year
  • Commits: 22
  • Committers: 2
  • Avg Commits per committer: 11.0
  • Development Distribution Score (DDS): 0.045
Top Committers
Name Email Commits
Jack Roberts j****s@t****k 688
nbarlowATI n****w@t****k 438
anguswilliams91 a****1@g****m 60
rchan r****n@t****k 57
callummole c****e@t****k 42
Dr Griffith Rees g****s@g****m 23
Chahak Mehta c****3@g****m 22
radka-j r****a@g****m 14
Helen Duncan h****n@t****k 12
dependabot[bot] 4****] 11
Alfie Bowman a****n@p****m 10
Abelarm l****0@g****m 10
Matt Craddock 5****m 7
chiefsan s****1@g****m 7
tdarnell t****s@d****k 7
Nicholas Barlow n****w@N****n 5
Ian Sealy g****t@i****m 5
Luke Hare l****e@t****k 5
crangelsmith c****h@t****k 5
Louise Bowler L****r 4
Luigi l****i@c****m 4
Chahak Mehta c****3@g****m 3
georgewhewell g****w@g****m 3
callistusndemo c****o 3
Tarek Allam t****r@g****m 3
Callistus Ndemo c****i@n****u 3
Helen Duncan 4****n 2
Oscar Giles o****s@t****k 2
Robert Hickman r****n@g****m 2
Tahmeed Tarek t****k@g****m 2
and 9 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 122
  • Total pull requests: 110
  • Average time to close issues: about 1 year
  • Average time to close pull requests: about 2 months
  • Total issue authors: 52
  • Total pull request authors: 18
  • Average comments per issue: 2.34
  • Average comments per pull request: 0.89
  • Merged pull requests: 63
  • Bot issues: 1
  • Bot pull requests: 40
Past Year
  • Issues: 30
  • Pull requests: 23
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 2 days
  • Issue authors: 18
  • Pull request authors: 6
  • Average comments per issue: 1.83
  • Average comments per pull request: 0.65
  • Merged pull requests: 16
  • Bot issues: 1
  • Bot pull requests: 1
Top Authors
Issue Authors
  • jack89roberts (27)
  • mildfuzz (8)
  • rohanday3 (7)
  • RajeshTailor1 (7)
  • nbarlowATI (5)
  • markajam (4)
  • sam-cutter (4)
  • pentatonicfunk (3)
  • Zonkil9 (3)
  • griff-rees (3)
  • rchan26 (3)
  • negmeme2001 (3)
  • lukehare (2)
  • Tdarnell (2)
  • SeamusBradbury (2)
Pull Request Authors
  • dependabot[bot] (40)
  • jack89roberts (35)
  • nbarlowATI (8)
  • rchan26 (6)
  • crangelsmith (4)
  • radka-j (2)
  • helendduncan (2)
  • craddm (2)
  • negmeme2001 (2)
  • lukehare (1)
  • iansealy (1)
  • ppapadatis (1)
  • vishnuprksh (1)
  • whrit (1)
  • chahak13 (1)
Top Labels
Issue Labels
bug (31) enhancement (22) good first issue (7) Hacktoberfest (7) help wanted (2) question (1) idea (1) dependencies (1) python:uv (1)
Pull Request Labels
dependencies (40) hacktoberfest-accepted (1) python:uv (1)

Dependencies

poetry.lock pypi
  • 134 dependencies
.github/workflows/main.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
Dockerfile docker
  • python 3.8-slim-buster build
.github/workflows/docker-ci.yml actions
  • actions/checkout main composite
docker-compose.yml docker
pyproject.toml pypi
environment.yml pypi