I was adopting lmfit
to do a curve fitting and use that fitted model to do prediction. However, the following code did not achieve what I want. Could you please help? Thanks.
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