Code Monkey home page Code Monkey logo

airsenal's Introduction

AIrsenal

Build Status

AIrsenal is a package for using Machine learning to pick a Fantasy Premier League team. For some background information and details see https://www.turing.ac.uk/research/research-programmes/research-engineering/programme-articles/airsenal.

Install

It is recommended that you use a conda or virtualenv environment to install and run AIrsenal.
The Stan model used to predict match results is in the package https://github.com/anguswilliams91/bpl, and to run this you will need a working (recent) C++ compiler. An example setup could be:

conda create -n airsenalenv python=3.7 pystan=2.18.0.0
conda activate airsenalenv
conda install -c psi4 gcc-5
pip install https://github.com/anguswilliams91/bpl/archive/master.zip
git clone https://github.com/alan-turing-institute/AIrsenal.git
cd AIrsenal
pip install .

Getting started

Once you've installed the module, you will need to set five environment variables (or alternatively you can put the values into files in the airsenal/data/ directory, e.g. airsenal/data/FPL_TEAM_ID:

  1. FD_API_KEY: an API key for football data (this is only needed for filling past seasons results if not already present as a csv file in the data/ directory.)
  2. FPL_TEAM_ID: the team ID for your FPL side.
  3. FPL_LEAGUE_ID: a league ID for FPL (this is only required for a small subset of functionality).
  4. FPL_LOGIN: your FPL login, usually email (this is only required to get league standings)
  5. FPL_PASSWORD: your FPL password (this is only required to get league standings)

Once this is done, run the following command

setup_airsenal_database

You should get a file /tmp/data.db. This will fill the database with all that is needed up to the present day.

Updating, running predictions and optimization.

To stay up to date in the future, you will need to fill three tables: match, player_score, and transaction with more recent data, using the command

update_airsenal_database

The next step is to use the team- and player-level Stan models to predict the expected points for all players for the next fixtures. This is done using the command

run_airsenal_predictions --weeks_ahead 3

(we normally look 3 weeks ahead, as this is an achievable horizon to run the optimization over, but also because things like form and injuries can change a lot in 3 weeks!)

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).

run_airsenal_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).

airsenal's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.