2

这是一个关于从lmfit fit_report()( 1 ) 对象中提取拟合统计信息的问题

lmfit示例中,返回以下部分输出:

[[Model]]
    Model(gaussian)
[[Fit Statistics]]
    # function evals   = 31
    # data points      = 101
    # variables        = 3
    chi-square         = 3.409
    reduced chi-square = 0.035
    Akaike info crit   = -336.264
    Bayesian info crit = -328.418
.
.
.
.
.
.

我试图将该Fit Statistics部分中的所有数量提取为单独的变量。

例如。要提取模型参数,我们可以使用 (per 1 , 2 ):

for key in fit.params:
    print(key, "=", fit.params[key].value, "+/-", fit.params[key].stderr)

然而,这只给出了模型参数;它没有给出拟合统计参数,这些参数也很有用。我似乎在文档中找不到这个。

是否有类似的方法可以分别提取拟合统计参数(chi-squarereduced chi-squarefunction evals等)?

4

2 回答 2

5

result holds all the fit statistics. you can get the required parameters as shown below

result = gmodel.fit(y, x=x, amp=5, cen=5, wid=1)
# print number of function efvals
print result.nfev
# print number of data points
print result.ndata
# print number of variables
print result.nvarys
# chi-sqr
print result.chisqr
# reduce chi-sqr
print result.redchi
#Akaike info crit
print result.aic
#Bayesian info crit
print result.bic
于 2017-04-13T01:11:45.687 回答
2

Model.fit_report()是的,很抱歉,在 0.9.6 版本中无意中关闭了适合统计信息的报告。这是在主 github 存储库中修复的。

正如 user1753919 所示,您可以获得这些单独的值。这些属性ModelResult记录在https://lmfit.github.io/lmfit-py/model.html#modelresult-attributes

于 2017-04-14T00:08:17.213 回答