scipy.odr 输出截距和斜率

scipy.odr output intercept and slope

我正在尝试绘制 ad odr 回归。我使用 post 中的代码作为示例: sample code 这是我的代码:

# 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

在哪里可以找到画线的截距和斜率?

谢谢

属性 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)