biophysics_fittingevaluatorEvaluator

Evaluator

class biophysics_fitting.evaluator.Evaluator

Extract features from voltage traces.

This class can be used to extract features from (usually) voltage traces of different stimuli. The voltage traces are (usually) computed with a Simulator object by calling its run method.

In an optimization the features returned by Evaluator.evaluate are saved together with to corresponding parameter values.

For a Simulator object s and a Evaluator object e, the typical usecase is:

>>> voltage_traces_dict = s.run(params)
>>> features = e.evaluate(voltage_traces_dict)

The workflow in the Evaluator can be split in two parts:

  1. Apply an evaluate_fun on each matching key in voltage_traces_dict

    These extract features from the voltage trace. These functions are registered under Evaluator_Setup.evaluate_funs.

  2. Perform arbitrary operations on the resulting dictionary

    (e.g. merge it from a nested to a flat dictionary or compute more complex features by combineing features from different stimuli)

An example set up can be found in get_Evaluator().

Example

>>> def examplary_evaluate_fun(**kwargs):
>>>    # kwargs are keys and values of voltage_traces_dict[in_name]
>>>    # extract features from kwargs
>>>    return out_dict # keys are names of features, values are features
>>> def finalize_fun(dict_):
>>>    # dict_ is a dictionary with out_name of the evaluate_funs as keys.
>>>    # and the returned dictionary out_dict as values,
>>>    # i.e. out_dict is a nested dictionary.
>>>    # dict_ can now be arbitrarily modified, e.g. flattened.
>>>    return modified_dict
>>> e = Evaluator()
>>> e.setup.evaluate_funs.append([in_name, evaluate_fun, out_name])  # corresponds to step (1)
>>> e.setup.finalize_funs.append(finalize_fun)  # corresponds to step (2)

Note

Combining features to reduce the number of objectives should be done with the Combiner object.

Attributes:

setup

A Evaluator_Setup object that keeps track of the evaluation functions.

Type:

Evaluator_Setup

Methods:

evaluate(features_dict, raise_)

Extracts features from a simulation result computed by biophysics_fitting.simulator.Simulator.run()