【问题标题】:scipy.odr output intercept and slopescipy.odr 输出截距和斜率
【发布时间】:2016-09-14 22:27:14
【问题描述】:

我正在尝试绘制 ad odr 回归。我以这篇文章中的代码为例: 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

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

谢谢

【问题讨论】:

    标签: python scipy regression


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2018-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-16
      • 2021-10-22
      • 1970-01-01
      • 2020-06-03
      相关资源
      最近更新 更多