[英]lmfit extract fit statistics parameters after fitting
This is a question about extracting fit statistics from the lmfit
fit_report()
( 1 ) object 这是一个关于从
lmfit
fit_report()
( 1 )对象中提取拟合统计数据的问题
In this lmfit
example, the following partial output is returned: 在此
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
.
.
.
.
.
.
I am trying to extract all the quantities in the Fit Statistics
section as separate variables. 我试图将
Fit Statistics
部分中的所有数量提取为单独的变量。
eg. 例如。 to extract the model parameters, we could use (per 1 , 2 ):
提取模型参数,我们可以使用(每1 , 2 ):
for key in fit.params:
print(key, "=", fit.params[key].value, "+/-", fit.params[key].stderr)
However, this only gives the model parameters; 但是,这只给出了模型参数; it does not give the fit statistics parameters, which are also useful.
它没有给出拟合统计参数,这也是有用的。 I cannot seem to find this in the documentation.
我似乎无法在文档中找到它。
Is there a similar way to extract the Fit Statistics parameters ( chi-square
, reduced chi-square
, function evals
, etc.) separately? 是否有类似的方法分别提取拟合统计参数(
chi-square
, reduced chi-square
, function evals
等)?
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
Yes, sorry the reporting of the fit statistics in Model.fit_report()
was inadvertenly turned off in the 0.9.6 release. 是的,抱歉,在0.9.6版本中无意中关闭了
Model.fit_report()
中的拟合统计信息的报告。 This is fixed in the main github repo. 这是在主github仓库中修复的。
As user1753919 has shown, you can get at these individual values. 正如user1753919所示,您可以获得这些单独的值。 These attributes of
ModelResult
are documented at https://lmfit.github.io/lmfit-py/model.html#modelresult-attributes ModelResult
这些属性记录在https://lmfit.github.io/lmfit-py/model.html#modelresult-attributes中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.