bingo.stats package#
Submodules#
bingo.stats.hall_of_fame module#
The Hall of Fame captures the best individuals that have occurred in a population’s history. The individuals in the hall of fame are kept in order of ascending fitness/key value. If multiple individuals have the same fitness, the earliest occurring is ordered first. Thus, the earliest occurrence of the best fitness/key value was achieved with the individual at index 0.
The hall of fame can – for the most part – be treated like a list: e.g., slicing, iterating and retrieving its length.
- class bingo.stats.hall_of_fame.HallOfFame(max_size, key_function=None, similarity_function=None)#
Bases:
object
Keeping track of the best individuals in a population.
The best individuals that have occurred in a population are tracked in the hall of fame. They are kept in order, with the best/earliest occurring individuals first. ‘Best’ is quantified by the fitness value of the individual unless specified otherwise by the key parameter. When a similarity function is given, the earliest occurrence of similar individuals is tracked.
- Parameters:
max_size (int) – The maximum number of individuals to track.
key_function (function (optional)) – Function used to quantify “best” individuals. Default is the use of an individual’s fitness attribute. The signature of the function should be func(chromosome)
similarity_function (function (optional)) – The function used to identify similar individuals. The signature of the function should be`func(chromosome, chromosome)`
- clear()#
Remove all hall of fame members
- insert(item)#
Manually Insert an individual into the Hall of Fame.
Inserts an individual, keeping correct order, into the hall of fame. The hall of fame will not be resized to maintain maximum size.
- Parameters:
item (Chromosome) – The individual to be added to the hall of fame
- remove(index)#
Remove a specific hall of fame member
- Parameters:
index (int) – index in the hall of fame to be removed
- update(population)#
Update the hall of fame based on the given population
- Parameters:
population (list of Chromosome) – The list of individuals to be considered for induction into the hall of fame
bingo.stats.pareto_front module#
The Pareto Front is an extension of hall of fame to construct a list of all the non-dominated individuals. An individual dominates another if all of it’s keys are not worse and at least one is better (smaller) than the other’s keys.
- class bingo.stats.pareto_front.ParetoFront(secondary_key, primary_key=None, similarity_function=None)#
Bases:
HallOfFame
A hall of fame object for storing the pareto front of individuals
The Pareto front is the group of individuals who are not dominated by any other individuals in a population. Domination is calculated based on two keys given to the constructor.
- Parameters:
secondary_key (function) – Function used to specify the second key to be used in domination calculations in the Pareto front. The signature of the function should be func(chromosome)
primary_key (function (optional)) – Function used to specify the second key to be used in domination calculations in the Pareto front. Default is the use of an individual’s fitness attribute. The signature of the function should be func(chromosome)
similarity_function (function (optional)) – The function used to identify similar individuals. The signature of the function should be`func(chromosome, chromosome)`
- update(population)#
Update the Pareto front based on the given population
- Parameters:
population (list of Chromosome) – The list of individuals to be considered for induction into the Pareto front