Genetic algorithm library to generate fantasy basketball lineups
Project description
fantasy-ga
fantasy-ga is a Python module and a command line tool that uses genetic algorithm to automate the generation of fantasy sports linesups. Currently supports DraftKings basketball rules.
Installation
- Dependency
- Python >= 3.9
numpy
pip install fantasy-ga
Usage
Provide a numpy.ndarray
where the columns correspond to player ID, salary, fantasy points (FPTS) and position information i.e. player_id,salary,fpts,PG,SG,SF,PF,C,G,F,Util
.
Python
import numpy as np
from fantasy_ga import LineupGenerator
m = np.loadtxt('examples/mat.csv', delimiter=',', skiprows=1)
n_pop = 1000
n_breed = 30
n_mutate = 30
n_gen = 16
n_compound = 5
model = LineupGenerator(m, n_pop, n_gen, n_breed, n_mutate, n_compound)
lineups, fit = model.compound()
optimal_lineups, top_n_scores = model.get_top_n_lineups(lineups, fit, 1)
CLI
As a module
$ python -m fantasy_ga --filepath=examples/mat.csv --n_pop=100 --n_gen=5 --n_breed=100 --n_mutate=100 --n_compound=10 --top_n_lineups=1
> PlayerIDs: [ 17. 106. 70. 0. 63. 33. 1. 108.], FPTS: 308.62082
or a command
$ fantasy-ga --filepath=examples/mat.csv --n_pop=100 --n_gen=5 --n_breed=100 --n_mutate=100 --n_compound=10 --top_n_lineups=1
> PlayerIDs: [ 17. 106. 70. 0. 63. 33. 1. 108.], FPTS: 308.62082
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fantasy-ga-0.1.0.tar.gz
(12.9 kB
view hashes)
Built Distribution
fantasy_ga-0.1.0-py3-none-any.whl
(12.3 kB
view hashes)
Close
Hashes for fantasy_ga-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a84eedfc80cc2e18f0fdf539c9d1b3bfaa33f0d8d5ad9f6743c17436bbde2b3 |
|
MD5 | c2467fcb05fd36ae5b24c5b689b7a4a5 |
|
BLAKE2b-256 | 64b4c5eb4442a1d1f7390a8da3554b39bdefa93c2bc13aeb4aba6d98587741c2 |