Scipy Leastsq 可选输出变量 (Mesg) [英] Scipy Leastsq Optional Output Variable (Mesg)
问题描述
SciPy 关于 LeastSq 的文档在这里.它指出 ier
是
SciPy's documentation on LeastSq is here. It states that ier
is
一个整数标志.如果它等于 1、2、3 或 4,则找到了解决方案.否则,找不到解决方案.无论哪种情况,可选的输出变量mesg"都会提供更多信息.
An integer flag. If it is equal to 1, 2, 3 or 4, the solution was found. Otherwise, the solution was not found. In either case, the optional output variable ‘mesg’ gives more information.
但是我如何检索可选变量 mesg
?
But how do I retrieve the optional variable mesg
?
x,ier=leastsq(residuals, plsq, args=(x_vals, y_vals))
只给了我两次回报
x,mesg,ier=leastsq(residuals, plsq, args=(x_vals, y_vals))
给出错误信息 ValueError: need more than 2 values to unpack
在那条线上.
x,mesg,ier=leastsq(residuals, plsq, args=(x_vals, y_vals))
gives the error message ValueError: need more than 2 values to unpack
on that line.
推荐答案
使用 full_output 参数:
import scipy.optimize as optimize
p,cov,infodict,mesg,ier = optimize.leastsq(
residuals,p_guess,args=(x,y),full_output=True)
这篇关于Scipy Leastsq 可选输出变量 (Mesg)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!