Skip to main content

Genetist: optimization with genetic algorithms

Project description

alt text

Genetist: A genetic algorithm powered hyperparameter optimization framework

Python pypi License

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)

Uploaded Source

Built Distribution

genetist-0.9.8-py2.py3-none-any.whl (9.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page