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

Stefan van der Walt stefanv at berkeley.edu
Thu Jan 24 13:45:44 EST 2019


Hi Josef,

On Thu, 24 Jan 2019 11:26:09 -0500, josef.pktd at gmail.com wrote:
> I think making initial values compulsory is too much of a break with
> tradition.
> IMO, a warning and better documentation would be more appropriate.
> https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html
> does not show an example with starting values.
> curve_fit could issue a warning if p0 is not specified, or warn if
> convergence fails and p0 was not specified.

Isn't the greater danger that convergence succeeds, with p0 unspecified,
and the resulting model not being at all what the user had in mind?

> I think it should also be possible to improve the default starting values,
> e.g. if the function fails or if bounds are provided.

This is the type of magic I hope we can avoid.  Having different
execution paths based on some vaguely defined notion of perceived
failure seems dangerous at best.

> I'm not a user of curve_fit, but I guess there might be a strong selection
> bias in use cases when helping out users that run into problems.

I agree; and I think this can be accomplished by better documentation,
helpful warnings, and assisting the user in choosing correct parameters.

Best regards,
Stéfan


More information about the SciPy-Dev mailing list