This app displays the best NFL players for users to pick for their teams during their fantasy football drafts. First, I used Beautiful Soup to scrape the most important stats for each position (QB, RB, WR, TE, D/ST, K) into CSV files. Then, I used these stats to calculate a "recomendation rating" for each player–each statistic is assigned a certain weight based on their importance for fantasy points and then I divided the sum of the weighted values by the sum of the weights to normalize the result. This ensures that the combined rec_rating is within a reasonable range and reflects a weighted average of the individual percentages.
Players are displayed to users from those with the highest to the lowest recommendation ratings. Note: the calculations are simplified and not based on those used by actual fantasy football sites.
My calculations are based on the research I did using these links: Quarterbacks, Running Backs, Wide Receivers, Tight Ends, Defense/Special Teams, Kickers
Link: https://www.youtube.com/watch?v=XnlI7SXFZvk
- Python
- Flask
- Beautiful Soup
- Pandas
To run this app locally, first clone this repository to your local machine...
git clone url-to-this-repository
... and then do the following:
This command creates a new virtual environment with the name .venv
:
python3 -m venv .venv
To activate the virtual environment named .venv
...
On Mac:
source .venv/bin/activate
On Windows:
.venv\Scripts\activate.bat
The file named, requirements.txt
contains a list of dependencies - other Python modules that this app depends upon to run.
To install the dependencies into the currently-active virtual environment, use pip
, the default Python "package manager" - software that takes care of installing the correct version of any module into your in the correct place for the current environment.
pip3 install -r requirements.txt
- define two environment variables from the command line: on Mac, use the commands:
export FLASK_APP=app.py
andexport FLASK_ENV=development
; on Windows, useset FLASK_APP=app.py
andset FLASK_ENV=development
. - copy the file named
env.example
into a new file named.env
, and enter your own MongoDB database connection credentials into that file where indicated. - start flask with
flask run
- this will output an address at which the app is running locally, e.g. https://127.0.0.1:5000. Visit that address in a web browser. - in some cases, the command
flask
will not be found when attemptingflask run
... you can alternatively launch it withpython3 -m flask run --host=0.0.0.0 --port=10000
.