Genetist: optimization with genetic algorithms
Project description
Genetist: A genetic algorithm powered hyperparameter optimization framework
Genetist is a high level framework that helps optimizing functions using the power of genetic algorithms.
Installation
Genetist is available at PyPI
$ pip install genetist
Quickstart
from genetist.environment import Environment
#defining a 4 variable search space of float values from -100.0 to 100.0
params = {
'x': {'low': -100.0, 'high': 100.0},
'y': {'low': -100.0, 'high': 100.0},
'z': {'low': -100.0, 'high': 100.0},
'k': {'low': -100.0, 'high': 100.0}
}
#defining an objective function
def objective(individual):
x = individual['x']
y = individual['y']
z = individual['z']
k = individual['k']
return (x**2 - 4*y**3 / z**4) * k**3
if __name__ == '__main__':
#defining our Environment instance with a population of 1000 individuals, 250 generation,
#one-point crossover and a single gene mutation with a 25% probability of mutation
environment = Environment(
params=params,
num_population=1000,
generations=250,
crossover_type='one_point',
mutation_type='single_gene',
prob_mutation=0.25,
verbose=0
)
#minimizing the objective function
results = environment.optimize(objective=objective, direction='minimize')
print()
print(f'EXECUTION TIME={results.execution_time}')
print(f'BEST SCORE={results.best_score}')
print(f'BEST INDIVIDUAL={results.best_individual}')
print('BEST PER GENERATION:')
print(results.best_per_generation_dataframe)
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
genetist-0.9.8.tar.gz
(8.1 kB
view hashes)
Built Distribution
Close
Hashes for genetist-0.9.8-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2508d1eba45eed1418fb01cf3140b4af3182cf28286b5a19ca6a8c43bb3c44cf |
|
MD5 | 3bbb7b6c51f7f0ccf3ffe633ff599e91 |
|
BLAKE2b-256 | 264d377a1b8cf42600d7a4bfd2bd7ae2d42859c9edd4698fa5191f5deb0d2089 |