Coder Social home page Coder Social logo

draftkings-nba-lineup-generator's Introduction

DraftKings-NBA-Lineup-Generator

Usage

% python generate.py player_data1.csv

Usage of programs is provided here.

scrape.py: Not to be called by user. Walks from DraftKing’s NBA lobby into a contest and downloads that day’s lineup of available players and their salaries into player_data.csv. It then searches for every player in this csv on basketball-reference.com, enters their individual page, and writes to player_data.csv the data it finds on their previous 4 games. Each player’s fantasy projection is written as the average of their last two games in the column ‘last two.’ If they scored more in the two games prior to their most recent two then they are removed from player_data.csv as we do not want players with negative momentum.

optimize.py: Not to be called by user. Uses scrape.py generated csv to print best lineup. First creates list of all players playing that night, the list is sorted by a value column which is equal to the player’s projection / (their salary / 1000). Then determines best lineup by populating the guard, forward, and utility positions with the first 3 players in the sorted playerlist who can legally fill the 3 positions. To fill the 5 remaining positions (PG,SG,SF,PF,C), the program brute force tries every legal combination. It then prints the best lineup, unless that lineup is projected to score less than 270 points (270 is the safety threshold point I determined where larger scores could usually win DraftKings 50-50 contests). Optimize.py can alternatively just print the best value players at a specified position as explained below.

generate.py: Main function to be called by user. Calls the other two programs dependent on what arguments it is passed. Called in the following ways from shell:

% python generate.py

calls scrape.py (which can take up to 10 minutes) and then optimize.py. Prints optimal lineup.

% python generate.py player_data.csv

runs optimize.py on csv specified (csv must have been previously generated by scrape.py). Prints optimal lineup..

% python generate.py player_data.csv position

Prints list of players in the specified csv sorted by value . List include only players who play specified position. position options are: "powerforward", "smallforward","guard", "pointguard”, "shootingguard, "util", “forward”, ”center”:

Future

The next step is to use the gathered data to put in a real model for predicting each night's performance. Currently the projection is just an average of recent performance.

draftkings-nba-lineup-generator's People

Contributors

shanefenske avatar

Watchers

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