Skip to content

Latest commit

 

History

History
192 lines (186 loc) · 5.43 KB

README-PyGad.md

File metadata and controls

192 lines (186 loc) · 5.43 KB

PyGad

Is an open-source Python library for building the genetic algorithm and optimizing machine learning algorithms. It works with Keras and PyTorch. More

GA class parameters in PyGad library

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:
  1. steady-state selection (sss)
  2. roulette wheel selection (rws)
  3. stochastic universal selection (sus)
  4. rank selection (rank selection)
  5. random selection (random)
  6. tournament selection (tournament)
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:
  1. single-point crossover (single_point)
  2. two points crossover (two_points)
  3. uniform crossover (uniform)
  4. scattered crossover (scattered)
crossover_type = "single_point"
mutation_type Mutation operations are:
  1. random mutation (random)
  2. swap mutation (swap)
  3. inversion mutation (inversion)
  4. scramble mutation (scramble)
  5. adaptive mutation (adaptive)
mutation_type = "random"
  1. mutation_percent_genes
  2. mutation_probability
  3. mutation_num_genes
  1. Percentage of genes to mutate, it must be > 0 and <=100, has no action if mutation_probability or mutation_num_genes exist
  2. probability of selecting a gene for applying the mutation operation, has no need for the 2 parameters mutation_percent_genes and mutation_num_genes
  3. Number of genes to mutate which defaults to None meaning that no number is specified, has no action if the parameter mutation_probability exists
mutation_percent_genes = 10
  • PyGad initialize_population with the following (init_range_low, init_range_high, allow_duplicate_genes, True, gene_type)