2016-09-14 43 views
0

我試圖繪製廣告odr迴歸。我使用的代碼從該柱作爲一個例子: sample code 這是我的代碼:scipy.odr輸出攔截和斜率

# regressione ODR 
import scipy.odr as odr 
def funzione(B,x): 
    return B[0]*x+B[1] 
linear= odr.Model(funzione) 
variabili=odr.Data(database.valore_rut,database.valore_cap) 
regressione_ortogonale=odr.ODR(variabili,linear,beta0=[1., 2.]) 
output=regressione_ortogonale.run()  
output.pprint() 

這是輸出

Beta: [ 1.00088365 1.78267543] 
Beta Std Error: [ 0.04851125 0.41899546] 
Beta Covariance: [[ 0.00043625 -0.00154797] 
[-0.00154797 0.03254372]] 
Residual Variance: 5.39450361153 
Inverse Condition #: 0.109803542662 
Reason(s) for Halting: 
Sum of squares convergence 

在哪裏可以找到截距和畫線的斜率?

感謝

回答

0

屬性output.beta持有的係數,這在您的代碼中調用B。所以斜率爲output.beta[0],截距爲output.beta[1]

要畫一條線,你可以這樣做:

# xx holds the x limits of the line to draw. The graph is a straight line, 
# so we only need the endpoints to draw it. 
xx = np.array([start, stop]) 
yy = funzione(output.beta, xx) 
plot(xx, yy)