gpt4 book ai didi

python - Scipy Leastsq 可选输出变量(Mesg)

转载 作者:太空宇宙 更新时间:2023-11-04 01:39:04 24 4
gpt4 key购买 nike

SciPy 关于 LeastSq 的文档是 here .它指出 ier

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

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在那条线上。

最佳答案

使用 full_output参数:

import scipy.optimize as optimize
p,cov,infodict,mesg,ier = optimize.leastsq(
residuals,p_guess,args=(x,y),full_output=True)

关于python - Scipy Leastsq 可选输出变量(Mesg),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6949049/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com