OxfordIonTrapGroup / oitg

Python package of helper routines (result loading, fitting, etc) for the Oxford Ion-Trap Group (OITG).
https://oxfordiontrapgroup.github.io/oitg/
13 stars 9 forks source link

FitBase: expose **kwargs of curve_fit #6

Open pathfinder49 opened 5 years ago

pathfinder49 commented 5 years ago

Fitting with parameter values far from unity can be improved by passing characteristic parameter scales to curve_fit using the optional the x_scale keyword argument. This argument is documneted under scipy.optimize.least_squares. curve_fit calls this function internally. **kwargs to curve_fit are passed to scipy.optimize.least_squares.

pathfinder49 commented 5 years ago

We might just want to give the option of passing **kwargs to FitBase.fit.

dnadlinger commented 5 years ago

If set to ‘jac’, the scale is iteratively updated using the inverse norms of the columns of the Jacobian matrix (as described in [JJMore]).

That's more or less what I was referring to – would this work for us? If we can avoid having to manually set this in 99.999% of cases, this seems like a huge win.

pathfinder49 commented 5 years ago

That might do the trick. Would it hurt to expose **kwargs though?

dnadlinger commented 5 years ago

Probably not – at least if it's a named dictionary (curve_fit_args? fit_args? algorithm_options?), where it doesn't make the FitBase API more convoluted. I'd just like to avoid making the common case more complex.

pathfinder49 commented 5 years ago

I've modified FitBase to use x_scale='jac'. However, **kwargs should still be exposed.

dnadlinger commented 5 years ago

Will do that later.

dnadlinger commented 5 years ago

We might need update scipy in our artiq-env for that to work, by the way.

dnadlinger commented 4 years ago

Un-assigning myself, as FitBase seems like a lost cause (or, to be more precise, requires serious amounts of work to be generally useful for my experiments, like proper support for multi-dimensional data), and I'm thus unlikely to do much work on it.