Skip to content

A Fantasy Premier League optimiser to maximise expected points.

License

Notifications You must be signed in to change notification settings

dannybozbay/FPL-Optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Winning FPL With Linear Optimisation

Harnessing the power of linear programming to optimise your team selection, captain choice and transfers!
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Results
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Winning your fantasy football leagues can be tough and frustrating process, but a rewarding one if you get things right. Unfortunately grabbing that first place position usually requires getting many things right...on many occasions. Most importantly your initial team selection, your weekly captain choice and your weekly transfers. But how often do we just guess these decisions from instinct? And why should we when there is so much DATA available to us?

The goal of this project is to use that data with PuLP (an open-source linear programming package for python) to maximise the expected points of your Fantasy Premier League team. By formulating constraints and objectives, the algorithm aims select most effective lineup, captain and transfers for each gameweek. No more blind guessing!

(back to top)

Built With

  • Python
  • Pandas

(back to top)

Getting Started

Prerequisites and installation

  1. Clone the repo

    git clone https://github.com/dannybozbay/FPL-Optimization.git
  2. Create a Python (3.11 or higher) environment with the required dependencies

    cd fpl-optimization
    python3 -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
  3. Download the latest points projection from FPLForm and save it under data/external with the name fpl-form-predicted-points.csv. Be sure to set the upper range of gameweeks to GW38 and select With Extra Columns before generating the CSV file.

(back to top)

Usage

After installing the optimiser, you can run it by following these steps:

  1. Set your FPL Team ID (team_id) and the number of gameweeks you wish to optimise for (horizon) in the src/settings.json file and save it.

  2. Run src/models/RunOptimiser.py

(back to top)

Results

Running the optimiser will provide the following:

  • CSV table located under data/results with information about your optimal lineup, captain and transfers (both in and out) for each gameweek.

  • TXT file located under reports containing a summary of actions for each gameweek, including the teams total expected points, its cost, its captain and its transfers.

  • Solved LP model located under models.

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Danny Bozbay - dannybozbay@gmail.com

Project Link: https://github.com/dannybozbay/fpl-optimization

(back to top)

Acknowledgments

A special thanks to Sertalpbila for not only inspiring this project with his own work, but for also providing some incredibly useful video tutorials on how to approach this problem. I could not recommend them enough if you wish to tackle this problem yourself!

(back to top)

Releases

No releases published

Packages

No packages published

Languages