bingo.local_optimizers package#
Submodules#
bingo.local_optimizers.local_opt_fitness module#
Fitness evaluation with local optimization
This module contains the implementation of a fitness function wrapper that will perform local optimization of a Chromosome as necessary using a LocalOptimizer before evaluating it.
- class bingo.local_optimizers.local_opt_fitness.LocalOptFitnessFunction(fitness_function, optimizer)#
Bases:
FitnessFunction
Fitness function wrapper for individuals that want local optimization
A class for fitness evaluation of individuals that may or may not need local optimization before evaluation.
- Parameters:
fitness_function (FitnessFunction) – A FitnessFunction for evaluating the fitness of a Chromosome.
optimizer (LocalOptimizer) – An optimizer that will perform local optimization on a Chromosome before evaluation as needed.
- eval_count#
the number of evaluations that have been performed by the wrapped fitness function
- Type:
int
- training_data#
data that can be used in the wrapped fitness function
- Type:
TrainingData
- property eval_count#
the number of evaluations that have been performed
- Type:
int
- property training_data#
data that can be used in fitness evaluations
- Type:
bingo.local_optimizers.local_optimizer module#
This module contains the abstract definition of an optimizer that can be used for local optimization of a Chromosome.
bingo.local_optimizers.normalized_marginal_likelihood module#
Normalized marginal likelihood calculation using SMCPy
This module contains the implementation of a fitness function wrapper that will perform probabilistic local optimization of a Chromosome using SMCPy. The normaized marginal likelihood from the SMC optimization is returned.
- class bingo.local_optimizers.normalized_marginal_likelihood.NormalizedMarginalLikelihood(fitness_function, deterministic_optimizer, log_scale=True, **kwargs)#
Bases:
FitnessFunction
Normalized marginal likelihood calculation using SMCPy
A class for fitness evaluation of individuals that have local optimization parameters
- Parameters:
fitness_function (FitnessFunction) – A FitnessFunction for evaluating the fitness of a Chromosome.
deterministic_optimizer (LocalOptimizer) – An optimizer that will perform deterministic local optimization on a Chromosome. Used in proposals of SmcpyOptimizer
**kwargs – other keyword arguments are passed to the SmcpyOptimizer initialization
- eval_count#
the number of evaluations that have been performed by the wrapped fitness function
- Type:
int
- training_data#
data that can be used in the wrapped fitness function
- Type:
TrainingData
- property eval_count#
the number of evaluations that have been performed
- Type:
int
- property training_data#
data that can be used in fitness evaluations
- Type:
bingo.local_optimizers.scipy_optimizer module#
Local optimization using scipy
Specifies ScipyOptimizer which is a class for local optimization of `Chromosome`s using scipy’s minimize or root methods. Also specifies ROOT_SET, a set of methods that will use scipy’s root method; MINIMIZE_SET, a set of methods that will use scipy’s minimize method; and JACOBIAN_SET, a set of methods that will use jacobian information.
- class bingo.local_optimizers.scipy_optimizer.ScipyOptimizer(objective_fn, **options)#
Bases:
LocalOptimizer
An optimizer that uses scipy.minimize or scipy.root for local optimization
A class for optimizing the parameters of a Chromosome using either scipy.minimize or scipy.root depending on the method specified.
- Parameters:
objective_fn – A function to minimize which can be evaluated by passing in a Chromosome.
options –
Additional arguments for optimization. e.g. (…, tol=1e-8, options={“maxiter”: 1000})
- e.g. param_init_bounds: iterable
[low, high) bounds that are used to initialize params, formatted as an iterable defaults to [-10000, 10000)
- e.g. method: string
method to use for optimization (e.g. BFGS, lm, etc.) defaults to BFGS
- e.g. tol: float
tolerance used for method defaults to 1e-6
- e.g. optionsdict
method-specific options (e.g. maxiter, ftol, etc.)
- objective_fn#
A function to minimize which can be evaluated by passing in a Chromosome
- options#
Additional arguments for clo options
- Type:
dict
- Raises:
KeyError – method must be a method supported by scipy
TypeError – objective_function must suit the specified method
- property objective_fn#
function to minimize, must take a Chromosome as input and return a number
- property options#
optimizer options (e.g. param_init_bounds, method, tol, options, etc.)
- Type:
dict
bingo.local_optimizers.smcpy_optimizer module#
A module for probabilistic calibration of parameters.
Probabilistic calibration of model parameters can be useful in cases where data is sparse and/or noisy. Using a calibration of this type can allow for a better estimate of true fitness while being a bit more robust to overfitting.
- class bingo.local_optimizers.smcpy_optimizer.SmcpyOptimizer(objective_fn, deterministic_optimizer, num_particles=150, mcmc_steps=12, ess_threshold=0.75, std=None, num_multistarts=1, uniformly_weighted_proposal=True)#
Bases:
LocalOptimizer
An optimizer that uses SMCPy for probabilistic parameter calibration
A class for probabilistic parameter calibration for the parameters of a Chromosome using SMCPy
- Parameters:
objective_fn (VectorBasedFunction, VectorGradientMixin) – A VectorBasedFunction with VectorGradientMixin (e.g., ExplicitRegression). It should produce a vector where the target value is 0.
deterministic_optimizer (LocalOptimizer) – A deterministic local optimizer e.g., ScipyOptimizer
num_particles (int) – The number of particles to use in the SMC approximation
mcmc_steps (int) – The number of MCMC steps to perform with each SMC update
ess_threshold (float (0-1)) – The effective sample size (ratio) below which SMC particles will be resampled
std (float) – (Optional) The fixed noise level, if it is known
num_multistarts (int) – (Optional) The number of deterministic optimizations performed when developing the SMC proposal
uniformly_weighted_proposal (bool) – Whether to equally weight particles in the proposal. Default True.
- objective_fn#
A function to minimize which can be evaluated by passing in a Chromosome
- options#
Additional arguments for clo options
- Type:
dict
- property eval_count#
the number of evaluations that have been performed
- Type:
int
- evaluate_model(params, individual)#
Evaluate an individual given a set of parameters
- Parameters:
params (numpy array) – parameters for which to evaluate the individual
individual (Equation) – individual for which to evaluate fitness
- Returns:
numpy array
- Return type:
fitness vector outputs for the individual w/ the params
- property objective_fn#
A VectorBasedFunction with VectorGradientMixin (e.g., ExplicitRegression). It should produce a vector where the target value is 0.
- property options#
optimizer’s options
- Type:
dict
- property training_data#
Training data used in objective function