Skip to content

Releases: brian-team/brian2modelfitting

brian2modelfitting v0.4

18 Jun 16:27
Compare
Choose a tag to compare

This new release adds a number of new features and fix some important bugs. We strongly encourage all users to update.

New features

  • A new method TraceFitter.refine will use a standard gradient-based optimization method to further minimize the error after fitting. This can greatly enhance the quality of fits when the TraceFitter.fit method is close to the optimal solution and only advances very slowly. This functionality is based on the lmfit package. It can optionally analytically calculate the gradient of the model equations (instead of numerically approximating them), but note that depending on the equations this process can take a long time or fail. (#28, #29).
  • As an alternative to specifying t_start, you can now individually weigh different parts of the simulation/recording with the t_weights argument, to emphasize/deemphasize the error at certain times (#31).
  • Values returned to the user (parameters found during the fit, total error), as well as values displayed in the progress reports (callback) now use physical units. Since this is a change that can break existing code that expects values to be dimensionless, the feature can be switched off by creating the Fitter object with use_units=False
  • The model equations now have access to some properties of the fitting process. E.g. when fitting a variable x, the target value can be accessed as target_x. In addition, a variable iteration stores the current round of the fitting process (by default it is set to a very high value in generate and refine, based on the assumption that it is used to implement some coupling to the target variable that inversely depends on the iteration). The starting value, and the constant value used in TraceFitter.refine and Fitter.generate can be configured using arguments (#33, #36)
  • During fitting, a penalty term (that should correspond to the name of an expression defined in the model) can be defined. This term will be added to the total error and can be used for regularization.
  • Fitter.generate can now generate traces for multiple variables at the same time (#34)

Bug fixes

  • There were some issues with the "recommendation" obtained from Nevergrad (see issue #16). With the fix, the parameters returned at the end of the fitting process are now simply the parameters that resulted in the smallest error so far.
  • Running Fitter.fit again after a call to Fitter.generate is now handled better and also works in standalone mode. (#15)
  • A warning during the import of scikit-learn is now suppressed.

Backward-incompatible changes

  • The "Gamma Factor with rate correction", implemented by the GammaFactor metric, previously defined the best possible match as having error -1, whereas smallest error for the Gamma Factor without rate correction was 0. The error has been shifted so that it is now >=0 in both cases (#32)