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
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!
-
Clone the repo
git clone https://github.com/dannybozbay/FPL-Optimization.git
-
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
-
Download the latest points projection from FPLForm and save it under
data/external
with the namefpl-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.
After installing the optimiser, you can run it by following these steps:
-
Set your FPL Team ID (
team_id
) and the number of gameweeks you wish to optimise for (horizon
) in thesrc/settings.json
file and save it. -
Run
src/models/RunOptimiser.py
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
.
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Danny Bozbay - dannybozbay@gmail.com
Project Link: https://github.com/dannybozbay/fpl-optimization
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!