a = [10, 25, 30]
b = [13720000, 9090000, 3900000]
from scipy.stats import linregress
linregress(a, b)
如何更改代码以获得x
的系数?
答案 0 :(得分:1)
根据docs:
from scipy.stats import linregress
a = [10, 25, 30]
b = [13720000, 9090000, 3900000]
lr = linregress(a, b)
要查询结果:
print(lr)
print(lr.slope)
返回:
LinregressResult(slope=-448923.0769230769, intercept=18630000.0, rvalue=-0.9511220069021482, pvalue=0.1998650358314477, stderr=145758.73719079647)
-448923.0769230769