Is an open-source Python library for building the genetic algorithm and optimizing machine learning algorithms. It works with Keras and PyTorch. More
- For more information about parameters visit PyGad Parameters
These variables are assigned values and passed to GA class
Parameter | Description | Usage Example |
---|---|---|
fitness_function | Declare your fitness function and assign it to | fitness_function = fitness_func |
num_generations | Declare number of generation | num_generations = 50 |
num_parents_mating | Declare number of parents mating | num_parents_mating = 4 |
sol_per_pop | Number of solutions (i.e. chromosomes) within the population. This parameter has no action if initial_population parameter exists | sol_per_pop = 8 |
num_genes | Number of genes in the solution/chromosome. It is not needed if the user feeds the initial population to the initial_population parameter | num_genes = 4 |
init_range_low init_range_high | lower and upper value of the random range from which the gene values in the initial population | init_range_low = 0 init_range_high = 6 |
random_mutation_min_val random_mutation_max_val | Used with random mutation they specify the min and max for the random range values | random_mutation_min_val = 0 random_mutation_max_val = 6 |
parent_selection_type |
Parent selection type are:
|
parent_selection_type = "sss" |
keep_parents | Number of parents to keep in the current population -1 (default) means to keep all parents in the next population 0 means keep no parents in the next population | keep_parents = 1 |
crossover_type |
Types of the crossover operation are:
|
crossover_type = "single_point" |
mutation_type |
Mutation operations are:
|
mutation_type = "random" |
|
|
mutation_percent_genes = 10 |
- PyGad initialize_population with the following (init_range_low, init_range_high, allow_duplicate_genes, True, gene_type)