brian2modelfitting.optimizer module¶
-
class
brian2modelfitting.optimizer.
NevergradOptimizer
(method='DE', use_nevergrad_recommendation=False, **kwds)[source]¶ Bases:
brian2modelfitting.optimizer.Optimizer
NevergradOptimizer instance creates all the tools necessary for the user to use it with Nevergrad library.
Parameters: - parameter_names (
list
ordict
) – List/Dict of strings with parameters to be used as instruments. - bounds (
list
) – List with appropriate bounds for each parameter. - method (
str
or callable, optional) – The optimization method. By default differential evolution, can be chosen by name from any method in Nevergrad registry. Alternatively, a callable object can be provided. - use_nevergrad_recommendation (bool, optional) – Whether to use Nevergrad’s recommendation as the “best result”. This recommendation takes several evaluations of the same parameters (for stochastic simulations) into account. The alternative is to simply return the parameters with the lowest error so far (the default). The problem with Nevergrad’s recommendation is that it can give wrong result for errors that are very close in magnitude due (see github issue #16).
- budget (int or None) – number of allowed evaluations
- num_workers (int) – number of evaluations which will be run in parallel at once
-
ask
(n_samples)[source]¶ Returns the requested number of samples of parameter sets
Parameters: n_samples (int) – number of samples to be drawn Returns: parameters – list of drawn parameters [n_samples x n_params] Return type: list
-
initialize
(parameter_names, popsize, rounds, **params)[source]¶ Initialize the instrumentation for the optimization, based on parameters, creates bounds for variables and attaches them to the optimizer
Parameters: Returns: popsize – The actual population size that will be used by the algorithm. Does not always correspond to
popsize
, since some algorithms have minimal/maximal population sizes.Return type:
- parameter_names (
-
class
brian2modelfitting.optimizer.
Optimizer
[source]¶ Bases:
object
Optimizer class created as a base for optimization initialization and performance with different libraries. To be used with modelfitting Fitter.
-
ask
(n_samples)[source]¶ Returns the requested number of samples of parameter sets
Parameters: n_samples (int) – number of samples to be drawn Returns: parameters – list of drawn parameters [n_samples x n_params] Return type: list
-
initialize
(parameter_names, popsize, rounds, **params)[source]¶ Initialize the instrumentation for the optimization, based on parameters, creates bounds for variables and attaches them to the optimizer
Parameters: Returns: popsize – The actual population size that will be used by the algorithm. Does not always correspond to
popsize
, since some algorithms have minimal/maximal population sizes.Return type:
-
-
class
brian2modelfitting.optimizer.
SkoptOptimizer
(method='GP', **kwds)[source]¶ Bases:
brian2modelfitting.optimizer.Optimizer
SkoptOptimizer instance creates all the tools necessary for the user to use it with scikit-optimize library.
Parameters: - parameter_names (list[str]) – Parameters to be used as instruments.
- bounds (list) – List with appropiate bounds for each parameter.
- method (
str
, optional) – The optimization method. Possibilities: “GP”, “RF”, “ET”, “GBRT” or sklearn regressor, default=”GP” - n_calls (
int
) – Number of calls tofunc
. Defaults to 100.
-
ask
(n_samples)[source]¶ Returns the requested number of samples of parameter sets
Parameters: n_samples (int) – number of samples to be drawn Returns: parameters – list of drawn parameters [n_samples x n_params] Return type: list
-
initialize
(parameter_names, popsize, rounds, **params)[source]¶ Initialize the instrumentation for the optimization, based on parameters, creates bounds for variables and attaches them to the optimizer
Parameters: Returns: popsize – The actual population size that will be used by the algorithm. Does not always correspond to
popsize
, since some algorithms have minimal/maximal population sizes.Return type: