Skip to content
Code that show how to optimize a DFS NBA lineup, which is a version of a knapsack problem
Jupyter Notebook Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data much more work on the notebooks Jul 27, 2019
.gitignore
README.md Update README.md Jul 29, 2019
basic_optimize.py
brisk_optimize.py variable name changes from cost to sal Jul 27, 2019
example_basic_optimize.ipynb changing where the notebook data is Jul 27, 2019
example_brisk_optimize.ipynb changing where the notebook data is Jul 27, 2019
example_fast_optimize.ipynb
fast_optimize.py variable name changes from cost to sal Jul 27, 2019
requirements.txt jupyter requirements. It's a lot, but figure it's worth it Jul 26, 2019
utils.py adding decorator to handling the timing of the optimizations Jul 26, 2019

README.md

nba-optimize

Code that show how to optimize a Daily Fantasy Sports (DFS) NBA lineup, which is a version of a knapsack problem.

Assiciated blog post where I talk about the code.

Three files included, basic_optimize.py, brisk_optimize.py, and fast_optimize.py each show different ways to perform the optimization.

I included csv data files for us to use. I used other code to get the data from nba.com and the info from FanDuel csv files that list the players and their salaries.

I'm assuming you'll have a virtualenv running python3. If so, run the following:

(nbaoptimize) $ pip install -r requirements
  .....
(nbaoptimize) $ python fast_optimize.py 2018-10-24

where the second argument is the data file to use.

Three files are also included to show examples of how the three solutions were done using Jupyter notebooks: example_basic_optimize.ipynb, example_brisk_optimize.ipynb, and example_fast_optimize.ipynb.

To run the Jupyter notebooks, instead of looking at the files here, run

$ jupyter notebook

which opens a new tab in browser where you can click the notebook files and run them yourself.

You can’t perform that action at this time.