bingo.evaluation package#

Submodules#

bingo.evaluation.evaluation module#

The genetic operation of evaluation.

This module defines the basic form of the evaluation phase of bingo evolutionary algorithms.

class bingo.evaluation.evaluation.Evaluation(fitness_function, redundant=False, multiprocess=False)#

Bases: object

Base phase for calculating fitness of a population.

A base class for the fitness evaluation of populations of genetic individuals (list of chromosomes) in bingo. All individuals in the population are evaluated with a fitness function unless their fitness has already been set.

Parameters:
  • fitness_function (FitnessFunction) – The function class that is used to calculate fitnesses of individuals in the population.

  • redundant (bool) – Whether to re-evaluate individuals that have been evaluated previously. Default False.

  • multiprocess (int or bool) – Number of processes to use in parallel evaluation or False for serial evaluation. If using multiple processes, individuals and fitness functions need to be pickle-able. Default False.

fitness_function#

The function class that is used to calculate fitnesses of individuals in the population.

Type:

FitnessFunction

eval_count#

the number of fitness function evaluations that have occurred

Type:

int

property eval_count#

the number of evaluations that have been performed

Type:

int

bingo.evaluation.fitness_function module#

The definition of fitness evaluations for individuals.

This module defines the basis of fitness evaluation in bingo evolutionary analyses.

class bingo.evaluation.fitness_function.FitnessFunction(training_data=None)#

Bases: object

Fitness evaluation metric for individuals.

An abstract base class for the fitness evaluation of genetic individuals (chromosomes) in bingo.

Parameters:

training_data (TrainingData) – (Optional) data that can be used in fitness evaluation

eval_count#

the number of evaluations that have been performed

Type:

int

training_data#

(Optional) data that can be used in fitness evaluation

Type:

TrainingData

class bingo.evaluation.fitness_function.VectorBasedFunction(training_data=None, metric='mae')#

Bases: FitnessFunction

Fitness evaluation based on vectorized fitness

Parameters:
  • training_data (TrainingData) – data that is used in fitness evaluation.

  • metric (str) – String defining the measure of error to use. Available options are: ‘mean absolute error’/’mae’, ‘mean squared error’/’mse’, and ‘root mean squared error’/’rmse’

abstract evaluate_fitness_vector(individual)#

Calculate a vector of fitness values for the passed in individual

Parameters:

individual (Chromosome) – individual for which fitness will be calculated

Returns:

vector_fitness – a vector of fitness values for the passed in individual

Return type:

array of numeric

bingo.evaluation.fitness_function.mean_absolute_error(vector, individual=None)#

Calculate the mean absolute error of an error vector

bingo.evaluation.fitness_function.mean_squared_error(vector, individual=None)#

Calculate the mean squared error of an error vector

bingo.evaluation.fitness_function.negative_nmll_laplace(vector, individual)#

Calculate the nmll squared error of an error vector

bingo.evaluation.fitness_function.root_mean_squared_error(vector, individual=None)#

Calculate the root mean squared error of an error vector

bingo.evaluation.gradient_mixin module#

Mixin classes used to extend fitness functions to be able to use gradient- and jacobian-based continuous local optimization methods.

This module defines the basis of gradient and jacobian partial derivatives of fitness functions used in bingo evolutionary analyses.

class bingo.evaluation.gradient_mixin.GradientMixin#

Bases: object

Mixin for using gradients for fitness functions

An abstract base class/mixin used to implement the gradients of fitness functions.

abstract get_fitness_and_gradient(individual)#

Fitness function evaluation and gradient

Get the fitness of the individual and the gradient of this function with respect to the individual’s constants.

Parameters:

individual (Chromosome) – individual for which the fitness and gradient will be calculated for

Returns:

fitness of the individual and the gradient of this function with respect to the individual’s constants

Return type:

fitness, gradient

class bingo.evaluation.gradient_mixin.VectorGradientMixin(training_data=None, metric='mae')#

Bases: GradientMixin

Mixin for using gradients and jacobians in vector based fitness functions

An abstract base class/mixin used to implement the gradients and jacobians of vector based fitness functions.

Parameters:
  • training_data (ExplicitTrainingData) – data that is used in fitness evaluation (passed to parent).

  • metric (str) – String defining the measure of error to use. Available options are: ‘mean absolute error’, ‘mean squared error’, and ‘root mean squared error’

get_fitness_and_gradient(individual)#

Fitness evaluation and gradient of vector based fitness function using metric (i.e. the fitness function returns a vector that is converted into a scalar using its metric function)

Get the fitness of the individual and the gradient of this function with respect to the individual’s constants.

Parameters:

individual (chromosomes) – individual for which the fitness and gradient will be calculated for

Returns:

fitness of the individual and the gradient of this function with respect to the individual’s constants

Return type:

fitness, gradient

abstract get_fitness_vector_and_jacobian(individual)#

Returns the vectorized fitness of this individual and the jacobian of this vector fitness function with respect to the individual’s constants

jacobian = [[\(df_1/dc_1\), \(df_1/dc_2\), …],

[\(df_2/dc_1\), \(df_2/dc_2\), …], …]

where \(f_\#\) is the fitness function corresponding with the #th fitness vector entry and \(c_\#\) is the corresponding constant of the individual

Parameters:

individual (chromosomes) – individual used for vectorized fitness evaluation and jacobian calculation

Returns:

the vectorized fitness of the individual and the partial derivatives of each fitness function with respect to the individual’s constants

Return type:

fitness_vector, jacobian

bingo.evaluation.random_subset_evaluation module#

Evaluation phase with random subsampling

In cases where evaluation is expensive it is sometimes useful to evaluate fitness only on a subset of the underlying training data. This class does this by randomly selecting subsets of the data for fitness evaluation. The random subset selection occurs each time this evaluation phase is called.

class bingo.evaluation.random_subset_evaluation.RandomSubsetEvaluation(fitness_function, subset_size, redundant=True, multiprocess=False)#

Bases: Evaluation

Phase which evaluates population using random subsets of training data

A class for fitness evaluation of populations using random subsamples of training data. A random subset of the training data is chosen each call. All individuals in the population are then evaluated with a fitness function using that same random subset.

Parameters:
  • fitness_function (FitnessFunction) – The function class that is used to calculate fitnesses of individuals in the population.

  • subset_size (int) – The size of the subset of training data that will be used for fitness evaluation.

  • redundant (bool) – Whether to re-evaluate individuals that have been evaluated previously. Default True. Using False may lead to unexpected results where individuals are compared on disimilar subsets of the training data.

  • multiprocess (int or bool) – Number of processes to use in parallel evaluation or False for serial evaluation. If using multiple processes, individuals and fitness functions need to be pickle-able. Default False.

fitness_function#

The function class that is used to calculate fitnesses of individuals in the population.

Type:

FitnessFunction

eval_count#

the number of fitness function evaluations that have occurred

Type:

int

bingo.evaluation.training_data module#

This module contains the abstract definition of the data containers that store training data for bingo evolutionary analysis.

class bingo.evaluation.training_data.TrainingData#

Bases: object

An index-able data containing class

An abstract base class for a training data container.

Module contents#