sansbacon / pangadfs Goto Github PK
View Code? Open in Web Editor NEWPandas-based genetic algorithm for NFL dfs
License: MIT License
Pandas-based genetic algorithm for NFL dfs
License: MIT License
An unused variable take up space in the code, and can lead to confusions. It should be removed. If this variable is necessary, name the variable _
or start the name with unused
or _unused
.
There are 8 occurrences of this issue in the repository.
See all occurrences on DeepSource → deepsource.io/gh/sansbacon/pangadfs/issue/PYL-W0612/occurrences/
Complete framework for transformers - convert projections from various sources and lineups from pydfs-lineup-optimizer for use in pangadfs by 11/22/2020.
Here is my code:
from pathlib import Path
from pangadfs import GeneticAlgorithm
import numpy as np
import logging
ctx = {
'ga_settings': {
'csvpth': Path(__file__).parent.parent / 'appdata' / 'pool.csv',
'n_generations': 20,
'population_size': 30000,
'stop_criteria': 10,
'verbose': True
},
'site_settings': {
'flex_positions': ('RB', 'WR', 'TE'),
'lineup_size': 9,
'posfilter': {'QB': 14, 'RB': 8, 'WR': 8, 'TE': 5, 'DST': 4, 'FLEX': 8},
'posmap': {'DST': 1, 'QB': 1, 'TE': 1, 'RB': 2, 'WR': 3, 'FLEX': 7},
'salary_cap': 50000
}
}
# set up GeneticAlgorithm object
ga = GeneticAlgorithm()
# create pool and pospool
pop_size = ctx['ga_settings']['population_size']
pool = ga.pool(csvpth=ctx['ga_settings']['csvpth'])
posfilter = ctx['site_settings']['posfilter']
flex_positions = ctx['site_settings']['flex_positions']
pospool = ga.pospool(pool=pool, posfilter=posfilter, column_mapping={}, flex_positions=flex_positions)
# create salary and points arrays
points = pool[cmap['proj']].values
salaries = pool[cmap['salary']].values
# create initial population
initial_population = ga.populate(
pospool=pospool,
posmap=ctx['site_settings']['posmap'],
population_size=pop_size
)
# apply validators (default are salary and duplicates)
initial_population = ga.validate(
population=initial_population,
salaries=salaries,
salary_cap=ctx['site_settings']['salary_cap']
)
population_fitness = ga.fitness(
population=initial_population,
points=points
)
# set overall_max based on initial population
omidx = population_fitness.argmax()
best_fitness = population_fitness[omidx]
best_lineup = initial_population[omidx]
# create new generations
n_unimproved = 0
population = initial_population.copy()
for i in range(1, ctx['ga_settings']['n_generations'] + 1):
# end program after n generations if not improving
if n_unimproved == ctx['ga_settings']['stop_criteria']:
break
# display progress information with verbose parameter
if ctx['ga_settings'].get('verbose'):
logging.info(f'Starting generation {i}')
logging.info(f'Best lineup score {best_fitness}')
# select the population
# here, we are holding back the fittest 20% to ensure
# that crossover and mutation do not overwrite good individuals
elite = ga.select(
population=population,
population_fitness=population_fitness,
n=len(population) // ctx['ga_settings'].get('elite_divisor', 5),
method='fittest'
)
selected = ga.select(
population=population,
population_fitness=population_fitness,
n=len(population),
method='roulette'
)
# cross over the population
crossed_over = ga.crossover(population=selected, method='uniform')
# mutate the crossed over population (leave elite alone)
mutated = ga.mutate(population=crossed_over, mutation_rate=.05)
# validate the population (elite + mutated)
population = ga.validate(
population=np.vstack((elite, mutated)),
salaries=salaries,
salary_cap=ctx['site_settings']['salary_cap']
)
# assess fitness and get the best score
population_fitness = ga.fitness(population=population, points=points)
omidx = population_fitness.argmax()
generation_max = population_fitness[omidx]
# if new best score, then set n_unimproved to 0
# and save the new best score and lineup
# otherwise increment n_unimproved
if generation_max > best_fitness:
logging.info(f'Lineup improved to {generation_max}')
best_fitness = generation_max
best_lineup = population[omidx]
n_unimproved = 0
else:
n_unimproved += 1
logging.info(f'Lineup unimproved {n_unimproved} times')
# show best score and lineup at conclusion
print(pool.loc[best_lineup, :])
print(f'Lineup score: {best_fitness}')
An unused argument can lead to confusions. It should be removed. If this variable is necessary, name the variable _
or start the name with unused
or _unused
.
There are 26 occurrences of this issue in the repository.
See all occurrences on DeepSource → deepsource.io/gh/sansbacon/pangadfs/issue/PYL-W0613/occurrences/
Performance improvements in algorithm, better use of multiprocessing, etc. by 11/30/2020.
Port over setting framework from pydfs-lineup-optimizer by 10/30/2020.
Write basic documentation by 10/31/2020
Complete initial functionality by 10/22/2020.
Local variable name hides the variable defined in the outer space, making it inaccesible. It may cause confusion.
There is 1 occurrence of this issue in the repository.
See all occurrences on DeepSource → deepsource.io/gh/sansbacon/pangadfs/issue/PYL-W0621/occurrences/
Release version 0.2 by 2/1/2021. The only predicate at this point is completing documentation.
Complete framework for plugins - allow custom populate, breed, and mutate methods by 11/15/2020.
Need full documentation by 1/31/2021.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.