[SciPy-Dev] curve_fit() should require initial values for parameters

josef.pktd at gmail.com josef.pktd at gmail.com
Thu Jan 24 15:35:14 EST 2019


On Thu, Jan 24, 2019 at 3:01 PM Stefan van der Walt <stefanv at berkeley.edu>
wrote:

> On Thu, 24 Jan 2019 14:19:09 -0500, josef.pktd at gmail.com wrote:
> > i.e. I think
> > Try automatic first, and if that does not succeed, then the user has to
> > think again,
> > is more convenient, than
> > "you have to think about your problem first, don't just hit the
> > button".
>
> My question is: can you ever know with certainty when you did not
> succeed?  In many cases, you'll probably think you did fine?
>
> But, consider, e.g., an alternative implementation that tries 5
> different fitting methods, and then picks the solution with the lowest
> error.  That, while not computationally optimal, is a process you can
> explain clearly.
>
> In this case, how do you communicate to the user through which steps
> there data went to obtained the returned result?  This is what I mean by
> avoiding the magic; making sure the user knows where their results came
> from.  I am not opposed to convenience, as long as there is clear
> communication.
>

Trying out different starting values and check convergence is similar to
what global optimizers like basinhopping do.

curve_fit has optional returns, which are not mentioned in the docstring,
no description of `full_output`.

Any systematic method, like "try again if convergence failed" can be
described.
The actual search path, which methods have been tried, can be included in
some `fit_history` in the `full_output`.

(E.g. statsmodels includes in most models some extra information about the
last optimization method used that includes which starting values were
used, which optimizer and similar. AFAIR, we don't return information about
earlier, preliminary optimization steps to get good starting values for the
final optimization.)

I never tried whether leastsq can be used inside basinhopping and I have
not tried the new global optimizers yet.
There would be options to make it work for more cases without requiring
users to specify starting values and possibly to switch to fancier
optimizers.

(I'm mainly arguing this position because curve_fit was initially sold as a
function that is more convenient to use than leastsq, i.e. it should put
less demand on the user than just using the underlying optimizers
directly.)

Josef




>
> Stéfan
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at python.org
> https://mail.python.org/mailman/listinfo/scipy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20190124/988c9740/attachment.html>


More information about the SciPy-Dev mailing list