scipy.optimize.curve_fit
함수에 예상 추측 시작 값을 입력하려고합니다. 는 this link 및 another linkscsi.optimize.curve_fit에서 leastsq() 인수 'x0'오류가 발생했습니다.
에 따르면 그러나 나는 내가 다른 방법으로 시도의 X0에서 그들을 defind해야하며, 나는 다음과 같은 오류가 발생합니다. (참고 : x0 인수가 없으면 정상적으로 작동 함)
TypeError : leastsq() 인수 'x0'에 대해 여러 값이 있습니다.
나는 재현 예를 들어 아래 제공 :
import numpy as np
import pandas as pd
from sklearn.datasets import load_iris
import scipy.optimize
iris = load_iris()
data1 = pd.DataFrame(data= np.c_[ iris['target'], iris['data']], columns= ['target'] + iris['feature_names'])
def formula_nls(data, pot, sp):
return pot * np.tanh(data1.iloc[:,2] * sp/2)
scipy.optimize.curve_fit(f = formula_nls, xdata= data1.iloc[:,1:],
ydata= data1.iloc[:,0], method = 'lm',
sigma = 1/data1.iloc[:,1], absolute_sigma=False,
x0 = np.ndarray([ 1, 2]))
어쩌면 내가 실종 오전 간단한 일입니다. least_squares, 예를 들어, 이것은 API와 다른
p0 : None, scalar, or N-length sequence, optional
Initial guess for the parameters. If None, then the initial values will all be 1 (if the number of parameters for the function can be determined using introspection, otherwise a ValueError is raised).
가의 최소화 : 감사
는 는
그건'np.array'하지'np.ndarray' – percusse