【发布时间】:2018-11-07 10:41:34
【问题描述】:
我采用lmfit 进行曲线拟合并使用该拟合模型进行预测。但是,下面的代码并没有达到我想要的效果。能否请你帮忙?谢谢。
import numpy as np
from lmfit import Model
def linearModel(x, a0, a1):
return a0+a1*x
#main code begin here
X=[1,2,4] # data for fitting
y=[2,4,6] # data for fitting
gmodel = Model(linearModel) #select model
params = gmodel.make_params(a0=1, a1=1) # initial params
result = gmodel.fit(y, params, x=X) # curve fitting
x1=[1, 2, 3] # input for prediction
a=result.eval(x) # prediction
【问题讨论】:
-
那么,你想要实现什么?请提供Minimal, Complete, and Verifiable example 这包括输入、预期输出和实际输出。
标签: python optimization curve-fitting lmfit