Skip to content

A Fantasy Premier League optimiser that leverages linear programming techniques to maximise team points and make data-driven decisions for better results each game week.

License

Notifications You must be signed in to change notification settings

dbozbay/FPL-Optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 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 league can be a challenging and sometimes frustrating journey—but when you get it right, it’s incredibly rewarding. The path to victory often requires nailing multiple decisions, consistently. The key elements? Your initial team selection, weekly captain choice, and timely transfers. Yet, how often do we rely purely on instinct for these decisions? Why guess when we have a wealth of data at our fingertips?

This project leverages that data with PuLP, an open-source linear programming package in Python, to maximize your Fantasy Premier League team's expected points. By setting up constraints and objectives, the algorithm optimizes your lineup, captain, and transfers for each gameweek. Say goodbye to blind guessing and hello to data-driven success!

(back to top)

Installation

To get started with the optimiser, follow these steps to set up your development environment:

1. Clone the Repository

First, clone the repository to your local machine using Git:

git clone https://github.com/dannybozbay/FPL-Optimization.git

2. Navigate to the Project Directory

Change to the project directory:

cd FPL-Optimization

3. Create a Python Virtual Environment

It's recommended to use a virtual environment to manage dependencies. Create a virtual environment with venv:

python3 -m venv venv

Activate the virtual environment:

  • On Windows:

    venv\Scripts\activate
  • On macOS/Linux:

    source venv/bin/activate

4. Install Dependencies

Install the required packages listed in requirements.txt:

pip install -r requirements.txt

5. Download Points Projection Data

Download the latest points projection from FPLForm and save it inside data/external with the name fpl-form-predicted-points.csv. Be sure to set the upper range of gameweeks to GW3 and select With Extra Columns before generating the CSV file.

6. Start Using the Project

You are now ready to use the optimiser. Follow the documentation and examples provided in the repository to get started.

(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 settings.json file and save it.

  2. Run the script run_optimiser.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

Email: [email protected]

(back to top)

Acknowledgments

A special thanks to Sertalpbila for inspiring this project with his own work and for providing invaluable video tutorials on how to approach the problem. If you're looking to tackle this challenge yourself, I highly recommend checking them out!

(back to top)

About

A Fantasy Premier League optimiser that leverages linear programming techniques to maximise team points and make data-driven decisions for better results each game week.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages