SciPy provides two functions for nonlinear least squares problems:
optimize.leastsq() uses the Levenberg-Marquardt algorithm only.
optimize.least_squares() allows us to choose the Levenberg-Marquardt, Trust Region Reflective, or Trust Region Dogleg algorithm.
Should we always use least_squares() instead of leastsq()?
If so, what purpose does the latter serve?
                        
Short answer
Yes.
Backward compatibility.
Explanation
The
least_squaresfunction is new in 0.17.1. Its documentation refers toleastsqasThe original commit introducing
least_squaresactually calledleastsqwhen the method was chosen to be 'lm'. But the contributor (Nikolay Mayorov) then decided thatand so he did. So,
leastsqis no longer required byleast_squares, but I'd expect it to be kept at least for a while, to avoid breaking old code.